Configuring a website on Apache2 with server-side includes

I recently got myself involved in helping with a website for a local club. In order to maintain it, I wanted to set up an Apache instance at home as well.

Luckily, in Ubuntu 9.10, it’s almost all set up by default. The only changes I had to make were to change the DocumentRoot directory and enable server-side includes. Here’s what I did:

Changing the document root

First I edited /etc/apache2/sites-available/default to put my document root in DocumentRoot, and also changed the two directory references that did point to /var/www to my new document root. Then I made sure all the parents of my document root had r+x permission for the Apache user.

Turning on server-side includes

My hosting facility has server-side includes turned on for .html. This is not the best use of resources, but this website doesn’t get enough traffic to make a difference. So I added:

AddType text/html .html
AddHandler server-parsed .html
Option Include (plus whatever options were there before)

to the two directories that used to be /var/www and /. After that, I had to enable mod_include with:

cd /etc/apache2/mods-enabled
sudo ln -s ../mods-available/include.load include.load

Then restart apache with sudo /etc/init.d/apache2 restart

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: