12

I'm trying to get SSI to work on Debian running Apache, however the .shtml files are not being parsed. From a PHP file with phpinfo() I can see that the following show up in the loaded modules section:

mod_mime_xattr mod_mime mod_mime_magic

In /etc/apache2/mods-enabled/mime.conf I have (among other things):

AddType text/html .shtml
AddOutputFilter INCLUDES .shtml

In /etc/apache2/sites-enabled/domain.com.conf (for the virtual host in question) I have:

<Directory /home/username/public_html>
Options +Includes
allow from all
AllowOverride All 
</Directory>

and for good measure, I added the following as well:

<Directory />
Options +Includes
</directory>

In the user's .htaccess file, I tried adding:

Options +Includes
AddType text/html shtml
AddHandler server-parsed shtml

Nothing seems to work. How can I even debug this?

Edit:

Here is the output of ls /etc/apache2/mods-enabled/ in case this helps

actions.conf          dav_svn.load         proxy_balancer.load
actions.load          deflate.conf         proxy.conf
alias.conf            deflate.load         proxy_connect.load
alias.load            dir.conf             proxy_http.load
auth_basic.load       dir.load             proxy.load
auth_digest.load      env.load             python.load
authn_file.load       fcgid.conf           reqtimeout.conf
authz_default.load    fcgid.load           reqtimeout.load
authz_groupfile.load  mime.conf            rewrite.load
authz_host.load       mime.load            ruby.load
authz_user.load       mime_magic.conf      setenvif.conf
autoindex.conf        mime_magic.load      setenvif.load
autoindex.load        mime-xattr.load      ssl.conf
cgi.load              negotiation.conf     ssl.load
dav_fs.conf           negotiation.load     status.conf
dav_fs.load           php5.conf            status.load
dav.load              php5.load            suexec.load
dav_svn.conf          proxy_balancer.conf
Mike
  • 669
  • 2
  • 9
  • 25
  • When you visit a `.shtml` page do you see anything in the Apache error log? – Zoredache Jul 11 '12 at 00:24
  • Actually, yes. In error.log `[error] an unknown filter was not added: includes` – Mike Jul 11 '12 at 00:27
  • Commenting out the line `AddOutputFilter INCLUDES .shtml` gets rid of the error, but still doesn't solve the problem – Mike Jul 11 '12 at 00:33
  • OK I figured it out. I'll post my answer in case others are having the same problems. – Mike Jul 11 '12 at 00:47

1 Answers1

12

In order to get server side includes to work, the include module also needs to be loaded. You can do this by executing the following as root:

a2enmod include

Or execute the following:

ln -s /etc/apache2/mods-available/include.conf /etc/apache2/mods-enabled/include.conf
ln -s /etc/apache2/mods-available/include.load /etc/apache2/mods-enabled/include.load

Then restart apache.

Note, if you were adding SSI to .shtml files from .htaccess you would do AddOutputFilter INCLUDES .shtml. Or substitute .shtml for whatever file type you want to be parsed by the server side includes.

The current Debian config file /etc/apache2/mods-available/mime.conf contains an error in that it adds the following:

<IfModule mod_mime.c>
[...]
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
[...]
</IfModule>

without first checking whether mod_include.c has been loaded. To get around this, you can change those lines to:

<IfModule mod_mime.c>
[...]
<IfModule mod_include.c>
    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml
</IfModule>
[...]
</IfModule>

The <IfModule> tags can be nested. This will get rid of the error messages that you are experiencing in the event that mod_include.c is not loaded.

Eko3alpha
  • 147
  • 1
  • 8
Mike
  • 669
  • 2
  • 9
  • 25