“UbuntuHelp:ServerSideIncludes”的版本间的差异
来自Ubuntu中文
小 |
小 |
||
第7行: | 第7行: | ||
sudo ln -s /etc/apache2/mods-available/include.load | sudo ln -s /etc/apache2/mods-available/include.load | ||
</nowiki></pre> | </nowiki></pre> | ||
− | 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. See also [[UbuntuHelp:RootSudo|RootSudo]]. |
=== Editing config === | === Editing config === | ||
Open the /sites-available/default file... | Open the /sites-available/default file... |
2007年12月4日 (二) 11:22的版本
点击翻译: |
English |
请不要直接编辑翻译本页,本页将定期与来源同步。 |
How to set up Server Side Includes on Apache, assuming you already have Apache installed.
Enable the Includes module
cd /etc/apache2/mods-enabled sudo ln -s /etc/apache2/mods-available/include.load
This creates a SymbolicLink in mods-enabled of the config file in mods-available. See also RootSudo.
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 # This directive allows us to have apache2's default start page # in /apache2-default/, but still have / go to the right place # Commented out for Ubuntu #RedirectMatch ^/$ /apache2-default/ </Directory>
and edit it to look like this:
<Directory /var/www/> Options Indexes FollowSymLinks MultiViews +Includes AllowOverride None Order allow,deny allow from all # This directive allows us to have apache2's default start page # in /apache2-default/, but still have / go to the right place # Commented out for Ubuntu #RedirectMatch ^/$ /apache2-default/ AddType text/html .shtml AddOutputFilter INCLUDES .shtml </Directory>
You need to add `+Includes` to the end of the end of the `Options`, and two new lines after the commented-out lines.
Restart Apache2
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 Saturday, 06-Aug-2005 23:05:21 CEST), SSI is working!
Based on Rafael Gattringer's Ubuntu Apache2 SSI Installation guide, with permission.