Apache not processing basic SSI
Asked Answered
G

2

3

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.

Gwinn answered 5/10, 2013 at 17:18 Comment(1)
It looks like the solution is here: aboutlinux.info/2006/02/…. I'll post a solution after I have time to try it.Gwinn
G
6

The solution is to place the directives shown at the beginning of this web page in a Directory section, but not place them in the http.conf file. Instead they belong in the sites-available/default file.

This was sufficient to get it working:

<Directory "/var/www">
    # ... other stuff appears here
    # add the three lines below:
    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml
    Options +Includes
</Directory>
Gwinn answered 6/10, 2013 at 19:7 Comment(1)
I know we're not supposed to thank people, but thank you :) The official documentation is really poor in getting something working: httpd.apache.org/docs/current/howto/ssi.htmlBleeding
Y
0

Quick addition: For MACOS Mojave, place these directives into ‎⁨

Macintosh HD⁩ ▸ ⁨private⁩ ▸ ⁨etc⁩ ▸ ⁨apache2⁩ ▸ ⁨users⁩▸ {username}.conf
Yasui answered 23/5, 2019 at 7:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.