Apache

- This document covers the compilation, installation and basic configuration of the Apache webserver. More advanced configuration is covered in many books and online documents. A good place to start is the Apache website.
- If you install this software it is highly recommended that you keep up-to-date with security advisories published on the Apache website.
- I cannot be held responsible for the security of your webserver. The setup I detail is fairly standard and to the best of my knowledge reasonably secure. However, it is up to you to understand the software you are running. You must not rely on this page to secure your webserver for you.
- If you do spot any major security problems that configuring Apache as detailed here may cause, please e-mail me using the link above.
- It is assumed that this installation takes place on a computer on which Core Linux has been successfully installed.
- No software other than the packages bundled with Core Linux have been installed.
- As described in the installation guide, it is assumed that any downloaded application source code is stored in a directory called
/appson the CD-R. - It is assumed that the Core Linux computer is attached to a network on which there is at least one other machine with internet access and a CD burner. It must also be running a web browser.
- It is assumed that the webpages have been developed on a separate system and are to be copied to the Apache server after configuration. They could of course be created by hand on the Core Linux PC using the
nanotext editor, but this procedure is beyond the scope of this page, and unlikely to be used by many people. It is assumed that the webpages are stored in a directory called/htmlon the CD-R.
Preparation
- Download the Apache source code from httpd.apache.org.
- Burn the file
httpd-2.0.40.tar.gzand your webpages to a CD. This page assumes that the subdirectory/appsis used for the.tar.gzfile and that the subdirectory/htmlis used for the webpages. The CD-ROM can be a multi-session disk.
Booting
- Boot your Core Linux PC.
- Login as
root. You will need to enter the password at the prompt.
Extract the source
- Place the CD-R in the CD-ROM drive. Mount the CD-ROM drive under
/mnt/cdrom. - Change to the
/appsdirectory on the CD-R. - Copy the
httpd-2.0.40.tar.gzfile to the directory/usr/src. - Change to the
/usr/srcdirectory and extract the source from the.tar.gzfile.
Configure and compile
- Change to the
/usr/src/httpd-2.0.40directory. - Run the
./configurescript. - Run the
makeprogram. - Run the
makeprogram with the argumentinstall.
Initial Testing
- If you are certain that the networking elements of your Core Linux PC are set up correctly, and that the Apache software was correctly compiled and installed then you may want to skip this section.
- Add the user
nobody. - Start the Apache webserver using
/usr/local/apache2/bin/apachectl start. - Using your other computer, see if you can access the web server.
- If the test page loaded successfully then you have correctly compiled and installed the Apache webserver. You may want to spend some time browsing the site to learn about more advanced configuration of the Apache webserver.
Setting up Apache
- These stages are discretionary, but demonstrate a typical Apache configuration.
- Change to the
/usr/local/apache2/confdirectory. - Backup
httpd.conftohttpd.conf.bak - Edit the
httpd.conffile. - Configure the Server Name. If you are planning to access your webserver using only its IP address then you do not need to complete this stage. Also, you will not be able to access your webserver using the specified address just be including in the configuration file. As there will be no DNS servers referencing it, no potential clients will be able to convert find the IP address for your machine from the given Server Name.
- Configure the Server Admin e-mail address.
- Configure the user and group as which Apache will run.
- Configure the Document Root. This is the directory from which your webpages will be served. The default location is the location of the "Test Page for Apache Installation" files.
- Save the file and exit the text editor.
Creating the Document Root
- Change to the
/homedirectory. - Create the directory
httpd/html. - Add the user and group
httpd. - Change the ownership of the
/home/httpddirectory to the userhttpdand the grouphttpd. - Change the access permissions of the
/home/httpddirectory to 0755.
Copying the webpages
- Copy the webpages from the CD-R to the Document Root directory.
- Change to the
/home/httpd/htmldirectory. - Change the ownership of the files in the
/home/httpd/htmldirectory to the userhttpdand the grouphttpd. - Change the access permissions of the files in the
/home/httpd/htmldirectory to 0755.
Checking and restarting Apache
- Check the syntax of your edited
httpd.conffile using/usr/local/apache2/bin/apachectl configtest. - Restart Apache using the command
/usr/local/apache2/bin/apachectl restart.
Stopping Apache
- Stop the Apache webserver using
/usr/local/apache2/bin/apachectl stop.
Automating Apache
- Append the following line to the
/etc/rc.d/rc.muscript:You can also add comments and echoes for your own information./usr/local/apache2/bin/apachectl start - Insert the following line at the second line of the
/etc/rc.d/rc.rbscript:You can also add comments and echoes for your own information./usr/local/apache2/bin/apachectl stop - Insert the following line at the second line of the
/etc/rc.d/rc.hascript:You can also add comments and echoes for your own information./usr/local/apache2/bin/apachectl stop - Reboot the system and check that Apache is running.

The text of this page is licensed under a Creative Commons License.
