NetworkClue.com
NetworkClue Home PageHome Contact UsContact ConsultingConsult
Bulletin Board
Internet Services covers Secrets to hosting websites, Hosting your own web server, and using DNS Servers.Operating Systems leads you through the decision of Linux vs. Windows, ideal installations and setups to create an efficient and redundant environment for your business, and great features to make management easier.Routing & Firewalls contains articles that will allow you to take control of your router. Learn how to protect your company with access lists and advanced firewall techniques.Hardware answers the common questions about Switches vs. Hubs, recommends SysAdmin Tools, and recommendations for adequate power protection.Utilities will cover fighting spam, using Anti-Virus programs effectively and the must haves for every administrator's software toolbox.

Bulletin Board

Apache 2.0 Configuration

By Joshua Erdman
Digital Foundation, inc.

Installing any of the Linux Services is a snap, you can do it during your Linux installation or just use the RPM program and install the package. But even after you think you got Apache up and running you can easily fall into some snags:

Clue 1: After you install Apache, the RedHat default is to not start it on bootup (even though it is installed it is not running).

Clue 2: You may also need to open the built-in firewall to allow incoming port 80 and port 443 packets.

Below are the configuration steps we must complete to get Apache working as a static HTML only web server.
· Getting Apache to run
· Opening the Firewall (IP Tables)
· The Default Web Content Directory
· Hosting multiple websites

Getting Apache to Run

From the command prompt you will need to:

  1. cd /etc/rc3.d
  2. ls -l | grep httpd
    This will display the current status of the Web Daemon (it is most likely K15httpd).

    Clue: The K means the service is killed and the 15 means it is the 15th service to be killed (if the service is already not running then it is just left off).

  3. mv K15httpd S81httpd
    This will set your Linux server to start Apache on normal bootup. We change it to the 81st service because there are some important services that must start first before you start hosting web pages (like the firewall). (Refer to my tutorial on run-levels to learn more about rc3.d, what the S and K mean and all that)
  4. Repeat steps 1-3 in the /etc/rc5.d directory as well.
  5. /etc/init.d/httpd start
    This will manually start your Apache Server without having to reboot.
  6. If you get the error message:
    Could not determine the server's FQDN using <IP Address> for servername
    You may need to set it manually. Search for the ServerName config line in the Apache config file (mentioned later) and add a web address such as: www.domain.com

Opening the Firewall (IP Tables)

OK, now we need to open the firewall (do not bother doing this if you chose not to install the firewall option when you first set up your Linux box).

Take a look at your current firewall configuration:

pico /etc/sysconfig/iptables

What you are loking at is the current firewall config listing all the allowed incoming traffic. You need to copy one of the configuration lines and then modify it for the web server. To do this:

  1. Move the cursor down to one of the config lines
  2. Press CRTL-K (to cut the whole line)
  3. Press CRTL-U two times.
    This will paste the line twice. WE will edit one of them.
    You need to change the new line you created to make that last part look like this:
    -p tcp -m tcp --dport 80 --syn -j ACCEPT
  4. Save and exit the editor by pressing CTRL-X, then press the ‘Y’ button to save and exit.
    Now we will reload the firewall configuration
    /etc/init.d/iptables restart

Apache Config File

The Apache Config File is located at /etc/httpd/conf/httpd.conf

In it are all the settings to specify default documents, configure virtual hosts (the hosting of multiple websites with one web server), specifying log files settings, etc.

Setting Default Document

The defualt document directive allows someone to see your index page by navigating to www.yoursite.com instead of www.yoursite.com/index.html
Just search for:

DefaultDocuments index.html

Some people prefer the default document to be index.html, it really doesn’t matter, you can even have multiple default documents.

Hosting multiple websites

If you plan to host multiple websites on your web server, you first need to create a virtualhost directive for the default site. The ServerName and DocumentRoot directives should be the same as the Global directives listed higher up in the config file. The format of a typical virtual host can be found below:

#www.defaultsite.com
<VirtualHost *> #asterisk uses all IP addresses
ServerName www.mysite.com
ServerAlias www.yoursite.com www.his-site.com #optional
DocumentRoot /var/www/html
</VirtualHost>

Below are all the common directives you may use for the rest of your virtual hosts:

#www.site1.com
<VirtualHost ip.address.goes.here >
ServerAdmin webmaster@site1.com #optional
ServerName www.site1.com
ServerAlias www.site1.net www.site1.org #optional
ErrorDocument 404 /index.html ErrorDocument 403 /index.html ErrorLog logs/error_log #optional
CustomLog logs/access_log combined #optional
DocumentRoot /home/bob/HTML
</VirtualHost>

ErrorLog
If you do not want the errors of a particular virtual host logged with the default site, you would specify a new location here.

CustomLog
If you want to separate this sites logged activity from the default site, specify a new location here.

Apache Security Contexts

You are not done yet. In addition to setting the correct file security (chmod 711) you need to set the context:

chcon -t httpd_sys_content_t /filepath

See our little article on chcon for more info.

Apache Performance

Neat! - Apache 2.0 also allows you to compress the outgoing data. This does not include graphics, just the static code. Compression will save you precious bandwidth but will also tax more CPU. If you need this you better hope your server is not an old 486.

Article last reviewed: 02/12/2005


del.icio.us

Created by: Digital Foundation, inc.

Copyright © 2002-2005 Digital Foundation, inc.   www.networkclue.com

All content of the NetworkClue website is copyrighted. Articles, notes, outlines, and all other materials may not be stored on the Internet or sold or placed by themselves or with other material in any electronic or printed format in whole or part. However materials may be referenced by links to the site.

 

Related Articles:
Handy HTML
Compression