>
How to set up Server Side Includes (SSI) on [[ApacheMySQLPHP|Apache]], assuming you already have Apache installed.
Server Side Includes are a very simple way of performing a limited Server Side Programming. For instance, you can have the server assemble one single document by merging smaller ones (with the #include directive), you can display data on the file itself (with the date_local directive, and many more), and if security is none of your concern, you can even execute local programs.
== Enable the Includes module ==
{{{
sudo a2enmod include
}}}
This creates a symlink in mods-enabled of the config file in mods-available.
== Editing config ==
Open the /sites-available/default file...
{{{
gksudo gedit /etc/apache2/sites-available/default
}}}
find this section...
{{{
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
}}}
and edit it to look like this:
{{{
Options Indexes FollowSymLinks MultiViews Includes
AllowOverride None
Order allow,deny
allow from all
}}}
You need to add `Includes` to the end of the end of the `Options`. If you only want to
run server side includes from your user directory, the /etc/apache2/mods-available/userdir.conf file aready has a `IncludesNoExec` in the `Options` line.
If you want includes in index pages then edit the /etc/apache2/mods-available/dir.conf file from this:
{{{
DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm
}}}
to this (indent changed to fit onto one line in this document):
{{{
DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm index.shtml
}}}
Note that on some older versions of Ubuntu, the /etc/apache2/mods-available/mime.conf might not contain the required `AddType` and `AddOutputFilter` directives for .shtml. and so another two lines will be required in /etc/apache2/sites-available/default:
{{{
Options Indexes FollowSymLinks MultiViews Includes
AllowOverride None
Order allow,deny
allow from all
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
}}}
== Restart Apache ==
For the changes to take effect you will need to restart Apache with
{{{
sudo service apache2 restart
}}}
== Test it works ==
Create a SSI test file and save it under /var/www/ssi-test.shtml.
{{{
SSI Test Page
}}}
In your WebBrowser, go to `http://127.0.0.1/ssi-test.shtml`.
If your browser displays the local date (eg Sunday, 18-Mar-2012 11:12:56 PDT), SSI is working!
Tested on Ubuntu 9.04, 12.04, 13.04
-----
Based on [[http://www.unet.univie.ac.at/%7Ea9826090/en/projects/linux/ubuntu-apache2-ssi.html|Rafael Gattringer's Ubuntu Apache2 SSI Installation guide]], with permission.
For usage examples, see also [[http://httpd.apache.org/docs/2.2/howto/ssi.html|SSI on apache.org]], but do not use it as a how to enable SSI reference, use this guide.
----