特殊:Badtitle/NS100:ServerSideIncludes:修订间差异
小 新页面: {{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... |
小无编辑摘要 |
||
第2行: | 第2行: | ||
{{Languages|UbuntuHelp:ServerSideIncludes}} | {{Languages|UbuntuHelp:ServerSideIncludes}} | ||
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. | ||
=== Enable the Includes module === | === Enable the Includes module === | ||
<pre><nowiki> | <pre><nowiki> | ||
cd /etc/apache2/mods-enabled | cd /etc/apache2/mods-enabled | ||
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 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> | ||
第33行: | 第26行: | ||
</Directory> | </Directory> | ||
</nowiki></pre> | </nowiki></pre> | ||
and edit it to look like this: | and edit it to look like this: | ||
<pre><nowiki> | <pre><nowiki> | ||
第49行: | 第41行: | ||
</Directory> | </Directory> | ||
</nowiki></pre> | </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. | ||
=== 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行: | 第58行: | ||
</html> | </html> | ||
</nowiki></pre> | </nowiki></pre> | ||
In your 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! | ||
----- | ----- | ||
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. |
2007年11月30日 (五) 21:27的版本
![]() |
文章出处: |
{{#if: | {{{2}}} | https://help.ubuntu.com/community/ServerSideIncludes }} |
![]() |
点击翻译: |
English {{#ifexist: {{#if: UbuntuHelp:ServerSideIncludes | UbuntuHelp:ServerSideIncludes | {{#if: | :}}ServerSideIncludes}}/af | • {{#if: UbuntuHelp:ServerSideIncludes|Afrikaans| [[::ServerSideIncludes/af|Afrikaans]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ServerSideIncludes | UbuntuHelp:ServerSideIncludes | {{#if: | :}}ServerSideIncludes}}/ar | • {{#if: UbuntuHelp:ServerSideIncludes|العربية| [[::ServerSideIncludes/ar|العربية]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ServerSideIncludes | UbuntuHelp:ServerSideIncludes | {{#if: | :}}ServerSideIncludes}}/az | • {{#if: UbuntuHelp:ServerSideIncludes|azərbaycanca| [[::ServerSideIncludes/az|azərbaycanca]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ServerSideIncludes | UbuntuHelp:ServerSideIncludes | {{#if: | :}}ServerSideIncludes}}/bcc | • {{#if: UbuntuHelp:ServerSideIncludes|جهلسری بلوچی| [[::ServerSideIncludes/bcc|جهلسری بلوچی]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ServerSideIncludes | UbuntuHelp:ServerSideIncludes | {{#if: | :}}ServerSideIncludes}}/bg | • {{#if: UbuntuHelp:ServerSideIncludes|български| [[::ServerSideIncludes/bg|български]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ServerSideIncludes | UbuntuHelp:ServerSideIncludes | {{#if: | :}}ServerSideIncludes}}/br | • {{#if: UbuntuHelp:ServerSideIncludes|brezhoneg| [[::ServerSideIncludes/br|brezhoneg]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ServerSideIncludes | UbuntuHelp:ServerSideIncludes | {{#if: | :}}ServerSideIncludes}}/ca | • {{#if: UbuntuHelp:ServerSideIncludes|català| [[::ServerSideIncludes/ca|català]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ServerSideIncludes | UbuntuHelp:ServerSideIncludes | {{#if: | :}}ServerSideIncludes}}/cs | • {{#if: UbuntuHelp:ServerSideIncludes|čeština| [[::ServerSideIncludes/cs|čeština]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ServerSideIncludes | UbuntuHelp:ServerSideIncludes | {{#if: | :}}ServerSideIncludes}}/de | • {{#if: UbuntuHelp:ServerSideIncludes|Deutsch| [[::ServerSideIncludes/de|Deutsch]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ServerSideIncludes | UbuntuHelp:ServerSideIncludes | {{#if: | :}}ServerSideIncludes}}/el | • {{#if: UbuntuHelp:ServerSideIncludes|Ελληνικά| [[::ServerSideIncludes/el|Ελληνικά]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ServerSideIncludes | UbuntuHelp:ServerSideIncludes | {{#if: | :}}ServerSideIncludes}}/es | • {{#if: UbuntuHelp:ServerSideIncludes|español| [[::ServerSideIncludes/es|español]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ServerSideIncludes | UbuntuHelp:ServerSideIncludes | {{#if: | :}}ServerSideIncludes}}/fa | • {{#if: UbuntuHelp:ServerSideIncludes|فارسی| [[::ServerSideIncludes/fa|فارسی]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ServerSideIncludes | UbuntuHelp:ServerSideIncludes | {{#if: | :}}ServerSideIncludes}}/fi | • {{#if: UbuntuHelp:ServerSideIncludes|suomi| [[::ServerSideIncludes/fi|suomi]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ServerSideIncludes | UbuntuHelp:ServerSideIncludes | {{#if: | :}}ServerSideIncludes}}/fr | • {{#if: UbuntuHelp:ServerSideIncludes|français| [[::ServerSideIncludes/fr|français]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ServerSideIncludes | UbuntuHelp:ServerSideIncludes | {{#if: | :}}ServerSideIncludes}}/gu | • {{#if: UbuntuHelp:ServerSideIncludes|ગુજરાતી| [[::ServerSideIncludes/gu|ગુજરાતી]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ServerSideIncludes | UbuntuHelp:ServerSideIncludes | {{#if: | :}}ServerSideIncludes}}/he | • {{#if: UbuntuHelp:ServerSideIncludes|עברית| [[::ServerSideIncludes/he|עברית]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ServerSideIncludes | UbuntuHelp:ServerSideIncludes | {{#if: | :}}ServerSideIncludes}}/hu | • {{#if: UbuntuHelp:ServerSideIncludes|magyar| [[::ServerSideIncludes/hu|magyar]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ServerSideIncludes | UbuntuHelp:ServerSideIncludes | {{#if: | :}}ServerSideIncludes}}/id | • {{#if: UbuntuHelp:ServerSideIncludes|Bahasa Indonesia| [[::ServerSideIncludes/id|Bahasa Indonesia]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ServerSideIncludes | UbuntuHelp:ServerSideIncludes | {{#if: | :}}ServerSideIncludes}}/it | • {{#if: UbuntuHelp:ServerSideIncludes|italiano| [[::ServerSideIncludes/it|italiano]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ServerSideIncludes | UbuntuHelp:ServerSideIncludes | {{#if: | :}}ServerSideIncludes}}/ja | • {{#if: UbuntuHelp:ServerSideIncludes|日本語| [[::ServerSideIncludes/ja|日本語]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ServerSideIncludes | UbuntuHelp:ServerSideIncludes | {{#if: | :}}ServerSideIncludes}}/ko | • {{#if: UbuntuHelp:ServerSideIncludes|한국어| [[::ServerSideIncludes/ko|한국어]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ServerSideIncludes | UbuntuHelp:ServerSideIncludes | {{#if: | :}}ServerSideIncludes}}/ksh | • {{#if: UbuntuHelp:ServerSideIncludes|Ripoarisch| [[::ServerSideIncludes/ksh|Ripoarisch]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ServerSideIncludes | UbuntuHelp:ServerSideIncludes | {{#if: | :}}ServerSideIncludes}}/mr | • {{#if: UbuntuHelp:ServerSideIncludes|मराठी| [[::ServerSideIncludes/mr|मराठी]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ServerSideIncludes | UbuntuHelp:ServerSideIncludes | {{#if: | :}}ServerSideIncludes}}/ms | • {{#if: UbuntuHelp:ServerSideIncludes|Bahasa Melayu| [[::ServerSideIncludes/ms|Bahasa Melayu]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ServerSideIncludes | UbuntuHelp:ServerSideIncludes | {{#if: | :}}ServerSideIncludes}}/nl | • {{#if: UbuntuHelp:ServerSideIncludes|Nederlands| [[::ServerSideIncludes/nl|Nederlands]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ServerSideIncludes | UbuntuHelp:ServerSideIncludes | {{#if: | :}}ServerSideIncludes}}/no | • {{#if: UbuntuHelp:ServerSideIncludes|norsk| [[::ServerSideIncludes/no|norsk]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ServerSideIncludes | UbuntuHelp:ServerSideIncludes | {{#if: | :}}ServerSideIncludes}}/oc | • {{#if: UbuntuHelp:ServerSideIncludes|occitan| [[::ServerSideIncludes/oc|occitan]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ServerSideIncludes | UbuntuHelp:ServerSideIncludes | {{#if: | :}}ServerSideIncludes}}/pl | • {{#if: UbuntuHelp:ServerSideIncludes|polski| [[::ServerSideIncludes/pl|polski]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ServerSideIncludes | UbuntuHelp:ServerSideIncludes | {{#if: | :}}ServerSideIncludes}}/pt | • {{#if: UbuntuHelp:ServerSideIncludes|português| [[::ServerSideIncludes/pt|português]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ServerSideIncludes | UbuntuHelp:ServerSideIncludes | {{#if: | :}}ServerSideIncludes}}/ro | • {{#if: UbuntuHelp:ServerSideIncludes|română| [[::ServerSideIncludes/ro|română]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ServerSideIncludes | UbuntuHelp:ServerSideIncludes | {{#if: | :}}ServerSideIncludes}}/ru | • {{#if: UbuntuHelp:ServerSideIncludes|русский| [[::ServerSideIncludes/ru|русский]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ServerSideIncludes | UbuntuHelp:ServerSideIncludes | {{#if: | :}}ServerSideIncludes}}/si | • {{#if: UbuntuHelp:ServerSideIncludes|සිංහල| [[::ServerSideIncludes/si|සිංහල]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ServerSideIncludes | UbuntuHelp:ServerSideIncludes | {{#if: | :}}ServerSideIncludes}}/sq | • {{#if: UbuntuHelp:ServerSideIncludes|shqip| [[::ServerSideIncludes/sq|shqip]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ServerSideIncludes | UbuntuHelp:ServerSideIncludes | {{#if: | :}}ServerSideIncludes}}/sr | • {{#if: UbuntuHelp:ServerSideIncludes|српски / srpski| [[::ServerSideIncludes/sr|српски / srpski]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ServerSideIncludes | UbuntuHelp:ServerSideIncludes | {{#if: | :}}ServerSideIncludes}}/sv | • {{#if: UbuntuHelp:ServerSideIncludes|svenska| [[::ServerSideIncludes/sv|svenska]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ServerSideIncludes | UbuntuHelp:ServerSideIncludes | {{#if: | :}}ServerSideIncludes}}/th | • {{#if: UbuntuHelp:ServerSideIncludes|ไทย| [[::ServerSideIncludes/th|ไทย]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ServerSideIncludes | UbuntuHelp:ServerSideIncludes | {{#if: | :}}ServerSideIncludes}}/tr | • {{#if: UbuntuHelp:ServerSideIncludes|Türkçe| [[::ServerSideIncludes/tr|Türkçe]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ServerSideIncludes | UbuntuHelp:ServerSideIncludes | {{#if: | :}}ServerSideIncludes}}/vi | • {{#if: UbuntuHelp:ServerSideIncludes|Tiếng Việt| [[::ServerSideIncludes/vi|Tiếng Việt]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ServerSideIncludes | UbuntuHelp:ServerSideIncludes | {{#if: | :}}ServerSideIncludes}}/yue | • {{#if: UbuntuHelp:ServerSideIncludes|粵語| [[::ServerSideIncludes/yue|粵語]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ServerSideIncludes | UbuntuHelp:ServerSideIncludes | {{#if: | :}}ServerSideIncludes}}/zh | • {{#if: UbuntuHelp:ServerSideIncludes|中文| [[::ServerSideIncludes/zh|中文]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ServerSideIncludes | UbuntuHelp:ServerSideIncludes | {{#if: | :}}ServerSideIncludes}}/zh-hans | • {{#if: UbuntuHelp:ServerSideIncludes|中文(简体)| [[::ServerSideIncludes/zh-hans|中文(简体)]]}}|}} {{#ifexist: {{#if: UbuntuHelp:ServerSideIncludes | UbuntuHelp:ServerSideIncludes | {{#if: | :}}ServerSideIncludes}}/zh-hant | • {{#if: UbuntuHelp:ServerSideIncludes|中文(繁體)| [[::ServerSideIncludes/zh-hant|中文(繁體)]]}}|}} |
{{#ifeq:UbuntuHelp:ServerSideIncludes|:ServerSideIncludes|请不要直接编辑翻译本页,本页将定期与来源同步。}} |
{{#ifexist: :ServerSideIncludes/zh | | {{#ifexist: ServerSideIncludes/zh | | {{#ifeq: {{#titleparts:ServerSideIncludes|1|-1|}} | zh | | }} }} }} {{#ifeq: {{#titleparts:ServerSideIncludes|1|-1|}} | zh | | }}
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.