“UbuntuHelp:ServerSideIncludes”的版本间的差异
来自Ubuntu中文
小 (新页面: {{From|https://help.ubuntu.com/community/ServerSideIncludes}} {{Languages|UbuntuHelp:ServerSideIncludes}} How to set up [http://httpd.apache.org/docs/2.0/howto/ssi.html Server Side Includ...) |
小 |
||
(未显示同一用户的4个中间版本) | |||
第1行: | 第1行: | ||
{{From|https://help.ubuntu.com/community/ServerSideIncludes}} | {{From|https://help.ubuntu.com/community/ServerSideIncludes}} | ||
{{Languages|UbuntuHelp:ServerSideIncludes}} | {{Languages|UbuntuHelp:ServerSideIncludes}} | ||
+ | <<Include(Tag/StyleCleanup)>> | ||
How to set up [http://httpd.apache.org/docs/2.0/howto/ssi.html Server Side Includes] on [[UbuntuHelp:ApacheMySQLPHP|Apache]], assuming you already have Apache installed. | How to set up [http://httpd.apache.org/docs/2.0/howto/ssi.html Server Side Includes] on [[UbuntuHelp: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 non of your concern, you can even execute local programs. | |
− | + | ||
=== Enable the Includes module === | === Enable the Includes module === | ||
− | |||
<pre><nowiki> | <pre><nowiki> | ||
− | + | a2enmod include | |
− | + | ||
</nowiki></pre> | </nowiki></pre> | ||
− | + | This creates a SymbolicLink in mods-enabled of the config file in mods-available. See also [[UbuntuHelp:RootSudo|RootSudo]]. | |
− | This creates a SymbolicLink in mods-enabled of the config file in mods-available. See also RootSudo. | + | |
− | + | ||
=== Editing config === | === Editing config === | ||
− | |||
Open the /sites-available/default file... | Open the /sites-available/default file... | ||
<pre><nowiki> | <pre><nowiki> | ||
gksudo gedit /etc/apache2/sites-available/default | gksudo gedit /etc/apache2/sites-available/default | ||
</nowiki></pre> | </nowiki></pre> | ||
− | |||
find this section... | find this section... | ||
<pre><nowiki> | <pre><nowiki> | ||
第27行: | 第21行: | ||
Order allow,deny | Order allow,deny | ||
allow from all | allow from all | ||
− | |||
− | |||
− | |||
− | |||
</Directory> | </Directory> | ||
</nowiki></pre> | </nowiki></pre> | ||
− | |||
and edit it to look like this: | and edit it to look like this: | ||
<pre><nowiki> | <pre><nowiki> | ||
第41行: | 第30行: | ||
Order allow,deny | Order allow,deny | ||
allow from all | allow from all | ||
− | |||
− | |||
− | |||
− | |||
AddType text/html .shtml | AddType text/html .shtml | ||
AddOutputFilter INCLUDES .shtml | AddOutputFilter INCLUDES .shtml | ||
+ | DirectoryIndex index.shtml | ||
</Directory> | </Directory> | ||
− | |||
+ | </nowiki></pre> | ||
You need to add `+Includes` to the end of the end of the `Options`, and two new lines after the commented-out lines. | You need to add `+Includes` to the end of the end of the `Options`, and two new lines after the commented-out lines. | ||
− | + | You can leave out the final added line if you don't want includes in index pages. | |
=== Restart Apache2 === | === Restart Apache2 === | ||
<pre><nowiki> | <pre><nowiki> | ||
sudo apache2ctl restart | sudo apache2ctl restart | ||
</nowiki></pre> | </nowiki></pre> | ||
− | |||
=== Test it works === | === Test it works === | ||
Create a SSI test file and save it under /var/www/ssi-test.shtml. | Create a SSI test file and save it under /var/www/ssi-test.shtml. | ||
第69行: | 第54行: | ||
</html> | </html> | ||
</nowiki></pre> | </nowiki></pre> | ||
− | + | In your [[UbuntuHelp:WebBrowser|WebBrowser]], go to `http://127.0.0.1/ssi-test.shtml`. | |
− | 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! | If your browser displays the local date (eg Saturday, 06-Aug-2005 23:05:21 CEST), SSI is working! | ||
− | + | Tested on Ubuntu 9.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. | 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. | ||
---- | ---- | ||
− | |||
[[category:UbuntuHelp]] | [[category:UbuntuHelp]] |
2010年5月20日 (四) 00:10的最新版本
点击翻译: |
English |
请不要直接编辑翻译本页,本页将定期与来源同步。 |
<<Include(Tag/StyleCleanup)>> 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 non of your concern, you can even execute local programs.
Enable the Includes module
a2enmod include
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 </Directory>
and edit it to look like this:
<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>
You need to add `+Includes` to the end of the end of the `Options`, and two new lines after the commented-out lines. You can leave out the final added line if you don't want includes in index pages.
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! Tested on Ubuntu 9.04
Based on Rafael Gattringer's Ubuntu Apache2 SSI Installation guide, with permission.