/*  UberLinux - Procedures - Apache */

Welcome to storm.uberlinux.org
Linux Mandrake release 7.0 (Air)
Kernel 2.2.14-15mdksecure on an i586
login:


home/
procedures/
>apache/
stories/
archive/
links/
portfolio/
about/
>Apache Web Server v1.3.9 www.apache.org

This procedure will outline the steps necessary for setting up a basic Apache web server. This example will use my host IP address of 205.160.100.94 and domain names of uberlinux.net, uberlinux.org, and yeepa.com. There are other ways to setup Apache in local networks and the like but I will not be covering that here.

The first step will be to add your domains in DNS to point to the server that will host the sites. In my case, I added my domains uberlinux.net, uberlinux.org, and yeepa.com to point to the IP 205.160.100.94 which is the address of this computer. I am not currently running DNS on this machine so the configurations were placed elsewhere. Now, every request that comes in for the aforementioned domains will be directed here. This is assuming that you have entered the correct nameserver(s) with your domain registrar.

The file that needs to be configured is httpd.conf. On my Mandrake 7.0 and Red Hat 8 boxes this file is located in the /etc/httpd/conf directory. On my Sun Solaris 8 servers it is located in the /etc/apache directory. Accessing the files is easy. Simply type cd /etc/httpd/conf to go to the directory and open the httpd.conf file to edit the configuration.  You will need to know how to use text editors such as vi or emacs to do this from the command line.

For most sites, the default settings in Apache are more than adequate.  A couple of directives of interest are ServerAdmin and DocumentRoot. The ServerAdmin directive specifies the email contact in case of a problem. I have mine defaulted to root and have created an alias for my user account to receive all root messages. The DocumentRoot directive specifies the directory in which your main web files are located. I have left this as is for my system. If someone goes to storm.uberlinux.org or my IP address they will see the default apache page. I have placed all of my domain web files in a root directory www/. If you do it this way you must create the directory as root. You must also set ownership privileges. Here is what I did in detail.

$ mkdir /www #creates www/ directory
$ cd www #moves into www directory
$ mkdir uberlinux | mkdir yeepa #creates uberlinux and yeepa directories
$ chown chris uberlinux | chown chris yeepa #changes owner from root to chris

Now I can write to these files from my user account. The next step is to setup virtual hosts to point incoming requests for domains to the proper directory where the web site files will be stored. In this example, all files for site www.uberlinux.org will be placed in the /www/uberlinux directory and all files for site www.yeepa.com will be placed in the /www/yeepa directory. There are two main ways to handle this. IP-based virtual hosts and name-based virtual hosts. Prior to Apache release 1.3.13, named-based virtual hosting was not available. Some older clients are also not compatible with name-based virtual hosts. I have elected to go with name-based virtual hosting. The main reason for this is the fact that IP address' with IPv4 are becoming more of a commodity within larger networks. For example, our ISP has an IP-based virtual host web server and it uses well over 100 IP addresses for all of the sites it serves. With name-based virtual hosting all of the sites would use just one!

Setting up virtual hosts is very simple. Here is what I did in detail. All directives were added at the bottom of the httpd.conf file.

NameVirtualHost 205.160.100.94

 

#substitute your IP here - activates name-based virtual hosting
<VirtualHost 205.160.100.94>
ServerName storm.uberlinux.org
DocumentRoot /home/httpd/html
</VirtualHost>

 

#sets IP for virtual host
#identifies client request to storm.uberlinux.org
#location of web site files
#closes this host
<VirtualHost 205.160.100.94>
ServerName www.uberlinux.org
DocumentRoot /www/uberlinux
ServerAlias uberlinux.org
</VirtualHost>

 

#sets IP for virtual host
#identifies client request to www.uberlinux.org
#location of web site files
#aliases uberlinuc.org to www.uberlinux.org
#closes this host
<VirtualHost 205.160.100.94>
ServerName www.uberlinux.net
DocumentRoot /www/uberlinux
ServerAlias uberlinux.net
</VirtualHost>

 

#sets IP for virtual host
#identifies client request to www.uberlinux.net
#location of web site files
#aliases uberlinuc.net to www.uberlinux.net
#closes this host
<VirtualHost 205.160.100.94>
ServerName www.yeepa.com
DocumentRoot /www/yeepa
ServerAlias yeepa.com
</VirtualHost>

 

#sets IP for virtual host
#identifies client request to www.yeepa.com
#location of web site files
#aliases yeepa.com to www.yeepa.com
#closes this host
After entering the configurations save and exit. The httpd daemon which runs Apache can be started by running apachectl. On this system the location is /usr/sbin/apachectl. Simply type the path and command /usr/sbin/apachectl start to begin the web server. That is all there is to it!

Last login: Thu July 17 16:06:33 from uberlinux.org
********************
Hello. Welcome to Storm!
********************
[chris@storm chris]$

home/    procedures/    stories/    archive/    links/    portfolio/    about/

Revised 10/11/2006

Copyright 2003-2006 uberlinux.org