Your Daily Source for Apache News and Information |
Breaking News | Preferences | Contribute | Triggers | Link Us | Search | About |
|
By: IntroductionHopefully you know something about Web servers in general, and the Apache Web server in particular, or else you wouldn't be reading this page. This article isn't intended to give background on what Apache is nor why you should use it, but how to get going with it once the decision has been made. In other words, simply how to download it, and install it, and turn it on. I should make it very clear right away that this article is about the latest released version of the server, Apache 1.3. It is not about the still-under-development 2.0 version. You'll have to wait for another article for that. The setting up of an Apache Web server falls naturally into a number of steps. Unfortunately, the steps differ slightly depending upon whether you're going to be using a binary distribution or if you're using Windows; the steps that may not apply are marked as 'optional' below.
Assumptions and ConventionsBefore getting into the nitty-gritty, let's set up a little background. A lot of what follows is going to refer to files and directories and commands and locations and things like that, so let us be sure we both understand them to mean the same things. An Apache server has at least two important directory trees, and possibly three. The first is where the server software lives (called the ServerRoot), the second is where the documents that get served to network visitors live (called the DocumentRoot), and the third is the home of the software sources (called the source tree). In many cases these all live in close proximity; if you install Apache from a package, the DocumentRoot might actually be a subdirectory under the ServerRoot, for instance. For the sake of clarity, the rest of this article makes the following assaumptions about where things are on your system:
These locations will be used by all of the Some formatting conventions used in examples in this article:
PlatformsThe Apache Web server runs on almost every Unix-like system in the world, and quite a few systems that don't resemble Unix at all. It's supported on the server platforms of Microsoft Windows (such as Windows NT and Windows 2000), and runs--but isn't supported--on the Windows 95 and Windows 98 platforms. This breadth of support means that, whatever you're running, you can probably use Apache on it. If you want to use Apache on something that isn't clearly Windows nor Unix, or you are otherwise unsure, check the resources in the 'Going Further' section of this article for places to inquire on how to proceed. Prebuilt Packages--or Building Your OwnSince Apache is developed as an Open Source' project, you have a choice of either using a package that someone else prepared for your platform--if anyone has--or of downloading the source and building it yourself from the ground up. Of course, with the dozens of available platforms, there are sure to be some to which the Apache developers themselves don't have access, and so your options may actually be reduced to building the Apache Web server from scratch yourself. Since different redistributors and repackagers have their own ideas about where to put files, the locations identified in the assumptions section may not be valid if you installed Apache from such a package. If that's the case, you'll just need to make the appropriate translations between the locations in this article and those on your system. Downloading the SoftwareThe latest and greatest released version of Apache is always available from the Apache Web site in the
Exactly how you download the software depends on your Web browser, but it may be as simple as holding down the 'Shift' key and clicking on the name of the file. There are two types of packages you can download from the Apache site:
The source-only packages are located in the top directory of the URL listed above; the prebuilt binaries are located in subdirectories underneath the Package namingThe Apache packages are named according to a formula:
A package that is missing the optional suffix information, such as ' The version number is very important. It's read from left to right, and each component is treated as a number in its own right. So the package named ' Signature FilesIn addition to the packages themselves, there are frequently accompanying signature files. These are used to verify that the packages were really built by the Apache developers, and have the same name as the package with either a ' The MD5 checksum, if one is provided for the package, is easier to check. You simply use your MD5 checksumming tool to generate a checksum of the package, and then you compare that value with what's in the % md5sum apache_1.3.12.tar.gz de3ccff384b0d4ab94c3251cb85d49d2 apache_1.3.12.tar.gz % cat apache_1.3.12.tar.gz.md5 MD5 (apache_1.3.12.tar.gz) = de3ccff384b0d4ab94c3251cb85d49d2 The other signature type, which is replacing MD5 in the Apache distribution process, is a PGP signature. In order to check it, you will need to have loaded the PGP keys of the Apache developers (available on the Apache site at <URL:http://www.apache.org/dist/KEYS>) into your PGP tool. Verify the signature on the file using your PGP tool; for instance, like this: % pgpv apache_1.3.12.tar.gz.asc This signature applies to another message File to check signature against [apache_1.3.12.tar.gz]: [hit Enter] Good signature made 2000-02-23 23:14 GMT by key: 768 bits, Key ID A0BB71C1, Created 1997-06-03 "Jim Jagielski " WARNING: The signing key is not trusted to belong to: Jim Jagielski (The last portion of the message simply means that you haven't marked Jim's key on your keyring as definitely being Jim's.) PGP signatures provide more information about an Apache package. They identify whom of the Apache developers approved it, when, and that the package you downloaded is the same as the one the developer approved. If either of the signatures don't match (that is, PGP reports an error or the MD5 checksum you generated is different from the one in the The CHANGES fileAlso in the main distribution directory are some files with names starting with " Building the Software from SourceIf you download an Apache package, you get the source code -- even if you downloaded a binary distribution. This means that you can always rebuild the Apache binary if you need to (and have the appropriate tools installed). The exact method of rebuilding depends on your platform, but there are really only two different platforms for this process: Windows and Unix (or Unix-like). [Re]Building Apache on UnixIf you want or need to build Apache from source, you can use the following commands as a quick-start. You should download the latest released version of the Apache tarball and unpack it into a working directory. The top-level directory will then be % cd ./apache-1.3 % env CC=gcc CFLAGS="-O2 -Wall" \ > ./configure --enable-shared=max --enable-module=most \ > --with-layout=Apache --prefix=/usr/local/web/apache \ > --with-port=80 Configuring for Apache, Version 1.3.13-dev + using installation path layout: Apache (config.layout) Creating Makefile Creating Configuration.apaci in src [more configuration output] % make [lots of compilation output] % /usr/local/web/apache/bin/apachectl start % make install [lots of output describing file placement]
If you didn't encounter any errors, you should now have a working Apache installation in the location that matches the assumptions described earlier. It's been built to work with dynamic modules rather than static ones for maximum flexibility. The next step is to start the server. [Re]Building Apache on WindowsUnfortunately, this is a pretty esoteric area. Almost every flavour of Unix in the world comes with the tools necessary to turn source code into something you can run; but the same is not true of Windows. All development packages on the Windows platforms are add-ons, and there are a few possibilities. When the Apache developers began working on the Windows version of Apache, they decided to standardise on a single add-on development tool: Visual Studio C++ version 5.0 from Microsoft. So if you don't have a Windows development package, you can't rebuild the Apache software. If you have a different one than Visual Studio, how to get it to work with the Apache sources is a problem you'll have to solve yourself. If, however, you have Visual C++ on your Windows box, then you can rebuild the Apache Web server from source either from a command line in a DOS window, such as: C:\>cd "\Program Files\Apache Group\Apache\src" C:\Program Files\Apache Group\APACHE\src>nmake -f Makefile.nt target The target can be one of the following:
Beyond that you're on your own, as building Apache on Windows is not exactly a 'getting started' topic! You can find more (possibly outdated) information on the Apache site at <URL:http://www.apache.org/docs/windows.html>. Shutting Down ApacheOn Unix systems, you use the # /usr/local/web/apache/bin/apachectl stop If this doesn't work, the alternative is to locate the master On Windows, you can either stop a running Apache server process by choosing the Stop Apache item from the Apache Web Server programme group, or by issuing the following in a DOS window: C:\Program Files\Apache Group\APACHE>apache -k stop De-installing Apache on WindowsIf you have previously installed the Apache Web server on your Windows system, it is a good idea -- a very good idea, in fact -- to uninstall it before upgrading, or even re-installing the same version. To deinstall Apache from your system, choose the Add/Remove Programs control panel item. You should be able to get this from the task bar by choosing Start->Settings->Control Panel and double-clicking on the Add/Remove Programs icon. Apache should be one of the applications available to remove. Select it, and click on the Add/Remove... button.
Installing the Apache ServerHow you install the Apache Web server software depends on your platform and the type of package you downloaded. For example, the Windows installation is a simple point-and-click operation; for Unix it can be a little more complex. Installing a Linux RPMThis is perhaps the simplest option of all. Once you've acquired the RPM file (which you have to get from some other location than the Apache distribution site; the Apache Software Foundation doesn't distribute RPM files), you can just 'make it so' by being logged in as root and issuing the following command from the directory where the Apache RPM file is located: # rpm -Uvh apache* Of course, this may or may not install the source tree, and probably won't put files into the same directories as assumed by this article -- you'll need to find out the differences and make adjustments. Installing a Pre-built Package on UnixAfter you unpack the binary package, there should be a file named # cd /tmp # zcat apache_1.3.12-i386-whatever-linux2.tar.gz | tar xf - # cd apache_1.3.12 # ./install-bindist.sh /usr/local/web/apache This should install the binary and documentation as follows:
In other words, with the exception of the source code, the script will install the Apache elements in the locations mentioned by the assumptions at the beginning of this article. The source directory in the above example is still where you unpacked it, at Installing on WindowsInstalling the prebuilt package on Windows is a snap. Once you've downloaded it into some working directory (such as
Checking the ConfigurationBy this point you should have an Apache binary application on your system, just rarin' to go and start serving files. Before you actually turn it loose, though, you should make sure you've dotted all the eyes and crossed all the teas. Verifying the ServerNameFor a Windows installation, edit the For the very best results, you should verify that the If your system is running Unix, you can find its fully-qualified name by simply typing " % hostname www.foo.bar.com If it only displays a partial name (like " If you're running Windows NT, you can find out your fully-qualified system name by going to the Start->Settings->Control Panel menu choice and double-clicking on the Network icon. Choose the Protocols tab, select TCP/IP Protocol, and click the Properties... button. Finally, choose the DNS tab. Your fully-qualified host name is the Host Name put together with the Domain value, separated by a dot. Validating the Configuration FilesThe last thing to do before starting up your new Apache installation is to make sure it's configured properly. On a Unix system, you do this with the following command: # /usr/local/web/apache/bin/apachectl configtest Syntax OK On Windows, you can do this by typing the following command in a DOS window: C:\Program Files\Apache Group\APACHE>apache -t c:/program files/apache group/apache/conf/httpd.conf: Syntax OK If there's anything syntactically wrong with your configuration files, you'll get an error message describing the problem. But from a vanilla installation everything should be healthy. Starting ApacheOnce the Apache software is ready to go, the next step is to actually activate it. The means of doing this differs depending upon your platform and how you installed it; for instance, if you installed an RPM package, there's a good chance that the installation automatically started the server as well. Starting Apache on UnixOnce you've done the % /usr/local/web/apache/bin/apachectl start /usr/local/web/apache/bin/apachectl start: httpd started Starting Apache on WindowsThere are two ways to start Apache on the Windows platform. One is to select the Start->Programs->Apache Web Server->Start Apache menu item, and the other is to do it in a DOS window: C:\Program Files\Apache Group\APACHE>apache -k start Actually, as a third method you can go into the services control panel and start the Apache servce, if you first select the Start->Programs->Apache Web Server->Install Apache&nsbp;as a service option first -- but I suggest that you leave that option for later, after you're assured that your server is running properly. Customising Your ContentThe very most important thing you should do before you turn the server on and let people start accessing it is: CHANGE THE MAIN PAGE! By default, following an Apache installation the main page in your DocumentRoot directory will say something reassuring -- to you -- about the success of the installation. It's sort of like the ReadMe.txt file you get to see after installing an application on Windows; it's just there to a) give the installer (you) a warm, fuzzy feeling that everything worked, and b) provide something other than a list of files to anyone who hits the site before it's ready. Unfortunately, there are a lot of people on the Internet that don't understand how the Web works, or the whole idea of clients and servers, and if they see that page saying 'Apache has been successfully installed!' they're going to think it's beein installed on their desktop system. Or, if you just upgraded an existing Web site, they're going to think the Apache Software Foundation has just invaded you and taken over your site. So please, please, please replace the default One way to do this, of course, is to modify the Testing Your InstallationIf you didn't get any errors when you started Apache, hopefully that means it's running. Try it out; use a browser to access the default page: <URL:http://localhost/>. You should see a page declaiming that the installation was a success. If you don't, make a note of what you see instead, and the contents of the error log under the ServerRoot location, in the Reloading After ChangesWhevever you make changes to the server configuration files (such as # /usr/local/web/apache/bin/apachectl graceful On Windows, the equivalent command (run in a DOS window) is: C:\Program Files\Apache Group\APACHE>apache -k restart Going FurtherOnce you've got your Apache Web server up and running, the first hurdle has been surmounted. Now you can move on to exploring its capabilities and features. Here are some pointers to resources for further investigation:
ConclusionIf you want to get the Apache Web server up and running, it's really quite simple; most of the hard part has been pre-configured for you. Follow the instructions here and you should be able to start serving simple pages in a matter of minutes. Got a Topic You Want Covered?If you have a particular Apache-related topic that you'd like covered in a future article in this column, please let me know; drop me an email at <>. I do read and answer my email, usually within a few hours (although a few days may pass if I'm travelling or my mail volume is 'way up). If I don't respond within what seems to be a reasonable amount of time, feel free to ping me again. About the AuthorKen Coar is a member of the Apache Group and a director and vice president of the Apache Software Foundation. He is also a core member of the Jikes open-source Java compiler project, a contributor to the PHP project, the author of Apache Server for Dummies, and a contributing author to Apache Server Unleashed. He can be reached via email at <>. |
|
|
About Triggers | Media Kit | Security | Triggers | Login |
All times are recorded in UTC. Linux is a trademark of Linus Torvalds. Powered by Linux 2.4, Apache 1.3, and PHP 4 Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy. |