Article

Installing Apache Tutorial

Page: 1 2 3 4 Next

Starting Off


Installing Apache and starting it up is generally thought to be a gruelling task, which it shouldn't be. In fact, with these tips and tutorials, it should be quite easy for anyone. The installation of the Unix version of Apache is just like installing most other applications, you download the source, compile it, and voila! The Windows version also makes it easy; using the setup wizard, it's just like installing any other Windows application.

Anyway, first we need to download a copy of Apache. Since it is relatively small (the size ranges from 1 to 3MB, depending on the platform), this should be a painless procedure. After that, it's just a matter of installing it. The following tips will make this procedure as painless as possible.

Download Apache


To get Apache, obviously you have to go to their site at http://www.apache.org/. Proceed to the downloads (http://www.apache.org/dist/) section or find the closest Apache mirror to you (http://www.apache.org/dyn/closer.cgi) to get your copy.

If you would like the Unix version of Apache, go through the well-named list of files and grab the gzipped copy (apache_1.3.9.tar.gz). For the Windows version, download the Windows binary setup file (apache_1_3_9_win32.exe).

Since installing the Windows version is easiest, I will talk about that first. After the file is downloaded, just open it as usual and the setup wizard will open and install the server for you. Since Apache has just started making Windows versions, the code is not as stable as it is for Unix. Windows support is entirely experimental, and is recommended only for experienced users. The Apache Group does not guarantee that this software will work as documented, or even at all. During the installation, you will be asked for

  • the directory to install Apache into
  • the start menu name
  • the installation type

Typical installs everything except the source code. Minimum doesn't install the manuals or source code, and Custom allows you to 'customize' what is installed.

Now to the Unix version. Since you downloaded a "tarball" distribution, you have to decompress it. Simply type tar -zxf apache_1.3.9.tar.gz. A directory called apache_1.3.9 will be created. You will have to go to this directory to proceed to the next step and compile the source code.

Compiling the Source


With all the source code neatly placed in this directory (and it's sub-directories), you will have to compile it to make it work. Here we will be using the GNU cc (gcc is the shortform) compiler to compile the source. It is free and distributed with most Unix operating systems. If it is not on your computer, download and install it from http://www.fsf.org/software/gcc/gcc.html.

Anyway, once in the apache_1.3.9 directory, from the prompt type

./configure

This will create a makefile with the default configuration. To change the configuration, you must edit apache_1.3.9/src/Configuration.tmpl before running configure. You can add/remove modules from the list, and tweak many other options. Normally though, you should just let it use the defaults, especially if this is your first time installing Apache.

For more information on editing the Configuration file, check out the README.configure file included with the distribution.

Two more command line commands to execute. Type

make

to compile the server, and

make install

to put it in the proper directories. The default is /usr/local/apache/, though this can be changed in Configuration.tmpl. Now that your Apache binaries have finally been installed, we can proceed with learning how to use them.

Using Apache


After all of this work, we are now ready to start running Apache. There are obviously two methods for running it, one is for Windows and the other is for Unix.

Windows

Since Apache is just another Windows application, just go to the start menu, then the Apache Web Server program group. If you are not running Windows NT, just select "Start Apache as console app". If you are running Apache on NT though, you can hit the "Install Apache as Service (NT only)" option and Apache will be installed as a service on your computer. This means it will automatically start everytime NT is booted up.

To shutdown the server, there are two other options available in the start menu that should be self-explanatory.

Unix

To startup Apache in Unix, all you have to do is run httpd. This would look something like this

/usr/local/apache/httpd

but this also depends on where you installed the binary. It will automatically use the configuration file it created on compilation called httpd.conf. If you would like to use another configuration file, you can use the -f argument.

Ex. /usr/local/apache/httpd -f /usr/local/apache/conf/httpd.conf

The Apache distribution does come with another method of starting, stopping, and restarting Apache. The script is called apachectl. In the Apache src directory (apache_1.3.9/src), type make at the prompt. You will see a few more files compiled. After make is done, go to the support directory (apache_1.3.9/src/support), where you will find a bunch of new files created. Among them, you'll find a few helper scripts, including apachectl, htpasswd (used to make Apache passwords for protected directories), and rotatelogs (its use is explained later). There are a few other files, but these are the most important.

Make a copy of these three files to your Apache binary directory. If you did not change the default settings, this would be located at /usr/local/apache/bin/.

To start the server, use

/usr/local/apache/bin/apachectl start

There is also

/usr/local/apache/bin/apachectl stop

and

/usr/local/apache/bin/apachectl restart

available, obviously to stop or restart the server.

To have Apache start upon booting up your system, make a copy of apachectl in your startup directory (typically /etc/rc.d/init.d or /etc/rc3.d/....)

Check it all out to make sure everything is working. From your browser, check out http://localhost/ right afterwards. You will know if it worked or not if you see anything....

Phew! Now that everything works, it's time to configure our server.

If you liked this article, share the love:
Print-Friendly Version Suggest an Article

Sponsored Links