2

The web server is Apache 2.2.22 running on Ubuntu 12.04 LTS.

This is my http.conf file:

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>

According to this http://httpd.apache.org/docs/current/mod/mod_include.html I need to have the AddType entry (got it), the AddOutputFilter entry (got it), and the Options +Includes entry (got it). It says I need to put that in a section (got it).

According to this http://httpd.apache.org/docs/current/howto/ssi.html I need Options +Includes (got it), AddType (got it) AddOutputFilter (got it), and XBitHack On may help.

This is the /var/www/index.shtml file:

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

The permissions on that file are set to -rwxr-xr-x.

When I load the file in my web browser, it loads and renders fine but the SSI part is not processed. All I see is "The current date is".

Here's the entry from /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"

Here is the error from /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

Options +Includes wasn't set? I see it right there in my http.conf file. I Googled around but couldn't figure out what the problem is.

4

2 回答 2

5

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

这足以让它工作:

<Directory "/var/www">
    # ... other stuff appears here
    # add the three lines below:
    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml
    Options +Includes
</Directory>
于 2013-10-06T19:07:26.690 回答
0

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

Macintosh HD⁩ ▸ ⁨private⁩ ▸ ⁨etc⁩ ▸ ⁨apache2⁩ ▸ ⁨users⁩▸ {username}.conf
于 2019-05-23T07:52:06.307 回答