TuDols: Setting up Apache Web Server
| what is linux? | distributions | applications | projects | support |
| documentation | security | online magazine | feedback | about |
| system | news | search |

Setting up Apache Webserver

After Installing my first Linux system the joy's of having your own webserver to play with was hard to match. But I have found something that does. Setting apache up to do what you want it to do.

Before we start a few points:

  • Most distributions comes with apache installed so you may already have it installed.
  • Even though you may hava apache installed it may not be actively running.
If you have Apache installed and it's running then I suggest you skip the installation section.
If you have apache installed, but it's not running you'll need to edit your startup scripts to start it up when you boot your system. < see the Documentation of your distribution to see how this is done >

Installing Apache Web Server

Q:) Where to get Apache ?
A:) Best place would be the Apache home page

Q:) What else do I need ?
A:) At the moment just your computer and linux.

Q:) What version do I download ?
A:) RedHat, Debian and other Linux Users that has package managers try and get Apache in your distribution
format or like other get the tarball ( tar.gz file )
NB package versions are usually in pre-compiled format so there is no need to compile it. Just install and start.

Now What ?

Ok once you have your version in whichever format time for installing to start.
For those of you using the Package manager formats install using the package managers that come with your distributions. eg. RedHat will be rpm -i apache-version.rpm

Estaga was kind enought to supply us with the debian package install syntax.
dpkg -i apache-version.rpm

The package managers will install all the pre-compiled versions so there is no compiling needed.
Now for tarball users.

In a directory you created or use for compiling source extract the file using tar and gzip.

tar -zxvf apache-version.tar.gz

tar syntax is : z = use gzip compression x = extract v = verbose ( list all messages ) f = uses a archive device

Enter the newly extracted directory.

So setup apache for compiling you need to setup a few things depending on your system. Luckily there is a programm ( script ) that does this all for you. so at this point type in

./configure --prefix=/www

This will setup apache for your system with the base install path as /www it will create and install apache there for you. After the configuring is complete you can type make to compile the source code make install to install the compiled binaries and configuration files

After all is made and install time to see if everthing worked.

  • type /www/sbin/apachectl start to start the server
  • Open a browser and select localhost as your distination, or if you are in console use lynx localhost and then q to quit. Make sure you get a welcome messgae from Apache Weberver.
  • type /www/sbin/apachectl stop to stop the server

Configuring up Apache Webserver

  • Virtual Domains: Multiple domain on one machine.
Ok first off you need to create a directory where you are going to keep the files. I would suggest using the defealt directory in /www/share/apache/htdocs. We need to create some directories for our use.

mkdir /www/share/apache/htdocs/homepage
this will create a directory to store you main homepage in.

mkdir /www/share/apache/htdocs/newpage1
change newpage1 to the name that you want to host there eg for games.myhost.com make it /games

mkdir /www/share/apache/htdocs/newpage2
same as above. Change the newpage2

Once you have created the directories where the virtual domain are going to be hosted you need to edit the configuration files to know where to look.

use your favorite editor and open /www/etc/apache/http.conf file

go to the end of the file where the virtual domain section is. If you have multiple network cards and IP addresses you'll use the VirtualHost syntax. If you are hosting all the sites on one IP address or host then your use the NameVirtualHost syntax as well. For both do the following.

The template looks like this

#<VirtualHost host.some_domain.com>
#ServerAdmin [email protected]_domain.com
#DocumentRoot /www/docs/host.some_domain.com
#ServerName host.some_domain.com
#ErrorLog logs/host.some_domain.com-error_log
#TransferLog logs/host.some_domain.com-access_log

Now change the infomation to reflect the domain information. Lets say I'm hosting a site called games.tudols.com it will look like this.

#ServerAdmin [email protected]
#DocumentRoot /www/share/apache/htdocs/games
#ServerName games.tudols.com
#ErrorLog logs/games-error_log
#TransferLog logs/games-access_log

P.S. please note I used an IP address. The IP address is that which the hostname, games.tudols.com, resolves to.

If you are going to host only one site .. then this addition to your http.conf file will be enough. If however you want more then one and you only have one IP address you'll have to use the _NEW_ NameVirtualHost syntax. ( only relevant for apache 1.3.3 and after )

To do so add the line NameVirtualHost before the VirtualHost settings. Also make sure that the IP addresses is correct. Then just have the IP address that you specify in your NameVirtualHost in the VirtualHost part of the Host setup.

Now run apachectl start to start up your webserver again. Now you have installed apache, configured it for hosting and restarted it with the new settings.

You'll have to do some editing of your /etc/rc.d/rc.local file to get apache to start up everytime linux boots up < see the Documentation of your distribution to see how this is done >, otherwise your Apache Webserver is now Up and running.

Unfortunately because Apache is such a big program with so much settings I cannot cover every possible setup or install setting ( there is lots ) please refer to the documentation you get with Apache or visit their website for more information.

If you have any suggestions or additions to this install guide please mail me at [email protected]

| Submit an Application | Submit a Review |

| what is linux? | distributions | applications | projects | support |
| documentation | security | online magazine | feedback | about |
| system | news | search |

copyright © TuDols 1998: comments and suggestions to webmaster