Size: 2263
Comment: tested on 12.04 (beta). Adding link to serverguide 12.04
|
Size: 2635
Comment: Update. Apache link was to 2.0 instead of 2.2. mime now cotains the AddType and AddOutputFilter
|
Deletions are marked like this. | Additions are marked like this. |
Line 3: | Line 3: |
How to set up [[http://httpd.apache.org/docs/2.0/howto/ssi.html|Server Side Includes]] on [[ApacheMySQLPHP|Apache]], assuming you already have Apache installed. | How to set up [[http://httpd.apache.org/docs/2.2/howto/ssi.html|Server Side Includes]] on [[ApacheMySQLPHP|Apache]], assuming you already have Apache installed. |
Line 11: | Line 11: |
a2enmod include | sudo a2enmod include |
Line 14: | Line 14: |
This creates a SymbolicLink in mods-enabled of the config file in mods-available. See also RootSudo. | This creates a SymbolicLink in mods-enabled of the config file in mods-available. |
Line 36: | Line 36: |
Options Indexes FollowSymLinks MultiViews +Includes | Options Indexes FollowSymLinks MultiViews Includes AllowOverride None Order allow,deny allow from all DirectoryIndex index.shtml </Directory> }}} You need to add `Includes` to the end of the end of the `Options`. You can leave out the final added line if you don't want includes in index pages. 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: {{{ <Directory /var/www/> Options Indexes FollowSymLinks MultiViews Includes |
Line 44: | Line 58: |
Line 47: | Line 60: |
You need to add `+Includes` to the end of the end of the `Options`, and two new lines after the commented-out lines. | |
Line 49: | Line 61: |
You can leave out the final added line if you don't want includes in index pages. | |
Line 73: | Line 84: |
If your browser displays the local date (eg Saturday, 06-Aug-2005 23:05:21 CEST), SSI is working! | If your browser displays the local date (eg Sunday, 18-Mar-2012 11:12:56 PDT), SSI is working! |
|
Style Cleanup Required |
How to set up Server Side Includes on 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 SymbolicLink 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...
<Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all </Directory>
and edit it to look like this:
<Directory /var/www/> Options Indexes FollowSymLinks MultiViews Includes AllowOverride None Order allow,deny allow from all DirectoryIndex index.shtml </Directory>
You need to add Includes to the end of the end of the Options. You can leave out the final added line if you don't want includes in index pages.
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:
<Directory /var/www/> Options Indexes FollowSymLinks MultiViews Includes AllowOverride None Order allow,deny allow from all AddType text/html .shtml AddOutputFilter INCLUDES .shtml DirectoryIndex index.shtml </Directory>
Restart Apache
For the changes to effect you will need to restart Apache with
sudo apache2ctl restart
Test it works
Create a SSI test file and save it under /var/www/ssi-test.shtml.
<html> <head> <title>SSI Test Page</title> </head> <body> <!--#echo var="DATE_LOCAL" --> </body> </html>
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
Based on Rafael Gattringer's Ubuntu Apache2 SSI Installation guide, with permission.