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:
- ELS 'Extra Applications' CD-ROM mounted on /media/cdrom or the ability to download the httpd package from the ELS Distribution Site.
- A client workstation with a web browser.
Installation
The steps below will guide you through the installation of Apache httpd using the ELS CD-ROM.
- Extract the httpd package into the root of the server's directory hierarchy.
- Create symbolic links for the httpd package's binaries in /opt/bin.
- Create a directory to hold your HTML documents and put a test document in it.
- 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.
- Copy the httpd.conf file included with the package to the /etc/opt/httpd directory.
- Edit /etc/opt/http/httpd.conf and customize the following directives:
- Set ServerAdmin to a valid email address.
- Set ServerName to your web server's DNS name.
- Set DocumentRoot the HTML documents directory created in the installation steps.
- Change the Directory statement that refers to /opt/httpd-2.2.8/htdocs to match your DocumentRoot statement.
- Change ErrorLog and CustomLog to match the directory you created to store log files.
- Open the firewall for web traffic and restart the network subsystem to refresh the rules.
- 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
- The example above only highlights necessary changes to /etc/opt/httpd/httpd.conf and /etc/firewall and does not show complete files.
- The administrator's email address, server name and IP addresses shown are for demonstration purposes only and should be changed to fit your network configuration.
Testing
The instructions below will help you test you web server installation.
- Start the web server with the command /etc/init.d/httpd start.
- Navigate to the web server's URL from a browser on a client workstation.
- 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:
- Run netstat -tl to verify that httpd is listening on port 80.
- Start the web server manually using the command httpd -f /etc/opt/httpd/httpd.conf and note any error messages.
- 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.
- 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/.