Apache-based websites

The main Apache webserver is now on Cat, though many sites have yet to move across from Dog.

Addresses

Apache binds these addresses on Cat:

IP addressDNS namePurpose
212.74.28.155ap2.ourshack.comMost websites should use this address
212.74.28.153cat.ourshack.comFor sites specific to the machine Cat (e.g. MRTG traffic data)
212.74.28.148smtp.ourshack.comFor sites associated with the mail system (e.g. lists.ourshack.com)

Where to put the files

Website files mostly live in /usr/local/www/sites/<sitename> The convention is to have an html subdirectory for the main tree of web-pages, and other subdirectories if required for things like Templates. Thus, a new website www.example.org should have its files in /usr/local/www/sites/www.example.org/html - this is the Apache DocumentRoot for the site.

Get the DNS right

Your site will need an A-record looking something like this:

www             A       212.74.28.155

See the DNS page for more information on setting this up.

Create an Apache VirtualHost

Each website is described by a VirtualHost section in the Apache config file. We keep each member's sites in a separate file under /usr/local/apache/vhosts for easier management. If you do not already have a file there, you will need to create one and also add an Include clause to the main config file /usr/local/apache/conf/httpd.conf

The VirtualHost section can be very simple. This is sufficient:

<VirtualHost 212.74.28.155>
        ServerName      www.example.org
        ServerAdmin     me@example.org
        DocumentRoot    /usr/local/www/sites/www.example.org/html
</VirtualHost>

Create a homepage

The file index.html in the DocumentRoot directory will become the site homepage. Write some HTML there (do please try to write standard HTML that can be rendered by any browser: you can get your pages checked by the W3C HTML Validator).

Test the config and make it active

When all is in place, check the config with:

/usr/local/apache/bin/apachectl configtest

If no errors are found, you can put the site into production with:

/usr/local/apache/bin/apachectl graceful

Moving sites from Dog to Cat

The first thing is to copy the files over. Note that Cat made automatic copies of all Dog websites until 1st April 2003 so you may well find an old set of files already in place. You may wish to delete them. Please do not do this as root! The files should be owned by your own username.

For a one-off copy it is probably easiest to make a tar file on Dog and use scp to copy that to Cat before unpacking it into /usr/local/www/sites/<sitename>

You next need to sort out the VirtualHost clause in your vhosts file. The main changes from Dog are likely to be:

Make sure you check up on any CGI settings and scripts etc as well.

When all is in place, check it out with:

/usr/local/apache/bin/apachectl configtest

If no errors are found, you can put the site into production with:

/usr/local/apache/bin/apachectl graceful

Now you need to change the DNS to point your web addresses at 212.74.28.155 rather than 212.74.28.150. Remember to update the serial number!


$Id: apache-websites.html,v 1.3 2003/05/12 09:22:45 root Exp $

Andrew Findlay