繁体   English   中英

Apache不处理基本SSI

[英]Apache not processing basic SSI

Web服务器是在Ubuntu 12.04 LTS上运行的Apache 2.2.22。

这是我的http.conf文件:

DirectoryIndex index.shtml index.html index.cgi index.pl index.php index.xhtml

LoadModule cgi_module /usr/lib/apache2/modules/mod_cgi.so
ScriptAlias /cgi-bin/ /var/www/cgi-bin/
AddHandler cgi-script .cgi .pl

LoadModule include_module /usr/lib/apache2/modules/mod_include.so
<Directory "/var/www">
  Options +Includes
  AddHandler server-parsed .shtml
  AddType text/html .shtml
  AddOutputFilter INCLUDES .shtml
  XBitHack on
</Directory>

根据此http://httpd.apache.org/docs/current/mod/mod_include.html,我需要具有AddType条目(将其获得),AddOutputFilter条目(将其获得)和Options + Includes条目(将其获得)它)。 它说我需要将其放在一个部分中(得到它)。

根据此http://httpd.apache.org/docs/current/howto/ssi.html,我需要Options + Includes(获取它),AddType(获取它),AddOutputFilter(获取它)和XBitHack On可能会有所帮助。

这是/var/www/index.shtml文件:

<html>
<body>
<p>The current date is <!--#echo var="DATE_LOCAL" --></p>
</body>
</html>

该文件的权限设置为-rwxr-xr-x。

当我在Web浏览器中加载文件时,它会加载并呈现良好,但未处理SSI部分。 我看到的只是“当前日期是”。

这是/var/log/apache2/access.log中的条目:

10.0.2.2 - - [05/Oct/2013:16:57:07 +0000] "GET /index.shtml HTTP/1.1" 200 401 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.66 Safari/537.36"

这是/var/log/apache2/error.log中的错误:

[Sat Oct 05 16:57:07 2013] [warn] [client 10.0.2.2] mod_include: Options +Includes (or IncludesNoExec) wasn't set, INCLUDES filter removed

未设置选项+包含? 我在http.conf文件中看到了它。 我四处搜寻,但不知道是什么问题。

解决方案是将显示在此网页开头的指令放在“ 目录”部分中,而不是将它们放在http.conf文件中。 而是它们属于网站可用/默认文件。

这足以使其正常工作:

<Directory "/var/www">
    # ... other stuff appears here
    # add the three lines below:
    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml
    Options +Includes
</Directory>

快速添加:对于MACOS Mojave,请将这些指令放入⁨

Macintosh HD⁩ ▸ ⁨private⁩ ▸ ⁨etc⁩ ▸ ⁨apache2⁩ ▸ ⁨users⁩▸ {username}.conf

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM