ELS Howto: Apache Web Server


Synopsis

This document gives provides instructions for setting up a web server on an Elemental Linux Server (ELS) system using the Apache project's httpd.


Prerequisites

You should have the following items available before proceeding with this document:


Installation

The steps below will guide you through the installation of Apache httpd using the ELS CD-ROM.

  1. Extract the httpd package into the root of the server's directory hierarchy.
  2. Create symbolic links for the httpd package's binaries in /opt/bin.
  3. Create a directory to hold your HTML documents and put a test document in it.
  4. Create a directory to store server log files and change the ownership of that directory to the user httpd will run as.

Example

The following example shows how you might install Apache with your HTML documents stored in /home/httpd and your logs in /var/opt/httpd.

cd /
tar -zxf /media/cdrom/extra/httpd-2.2.9.i586.tar.gz

cd /opt/bin
ln -s ../httpd-2.2.9/bin/* .

mkdir /home/httpd
cp /media/cdrom/doc/install.html /home/httpd/index.html

mkdir /var/opt/httpd
chown daemon /var/opt/httpd

Configuration

Once installation is complete, you will need to edit the httpd.conf file to set up your web site.

  1. Copy the httpd.conf file included with the package to the /etc/opt/httpd directory.
  2. Edit /etc/opt/http/httpd.conf and customize the following directives:
  3. Open the firewall for web traffic and restart the network subsystem to refresh the rules.
  4. Set the httpd service to start automatically at boot-up.

Example

The following example shows how to copy and edit the httpd.conf file, configure the firewall and set httpd for automatic start-up.

cp /opt/httpd-2.2.9/conf/httpd.conf /etc/opt/httpd

vi /etc/opt/httpd/httpd.conf

ServerAdmin webmaster@localnet.lan
ServerName www.localnet.lan
DocumentRoot /home/httpd
<Directory "/home/httpd">
ErrorLog "/var/opt/httpd/error.log"
CustomLog "/var/opt/httpd/access.log" common

vi /etc/firewall

# Allow web traffic from the local network.
-A INPUT -p tcp -s 192.168.1.0/24 --dport 80 -j ACCEPT

/etc/init.d/network restart

chmod +x /etc/init.d/httpd

Notes


Testing

The instructions below will help you test you web server installation.

  1. Start the web server with the command /etc/init.d/httpd start.
  2. Navigate to the web server's URL from a browser on a client workstation.
  3. Verify that the HTML document from /home/httpd appears.

The following example shows a successful test using the lynx web browser.

login: root
password:

# /etc/init.d/httpd start
Web Server is starting.

lynx -dump http://127.0.0.1/

                          Elemental Linux Server Help
     __________________________________________________________________

System requirements and limitations

   The Elemental Linux Server (ELS) is a niche distribution and is not
   intended to run on every imaginable hardware configuration.
   Specifically, it is designed to run on standard x86 PC architecture

If you cannot view documents on your web server, try the following steps to help pinpoint the problem:

  1. Run netstat -tl to verify that httpd is listening on port 80.
  2. Start the web server manually using the command httpd -f /etc/opt/httpd/httpd.conf and note any error messages.
  3. Use the command iptables -L -n to verify that firewall rules allow unrestricted access for on port 80 for any hosts trying to access the server.
  4. Test network connectivity to the server by pinging it from another machine.

Additional Information

For more help installing and configuring Apache, see the Apache httpd documentation at: http://httpd.apache.org/docs/2.2/.