PDA

View Full Version : SSI with Apache2 on Debian


jchaven
13th February 2006, 06:21
I have several .shtml pages that I have moved from Apache2 on Windows to Apache2 on Debian that are not loading. I can visit the individual pages that are included on the index page and they load normally -- they just do get included.

With Apache2 on Windows I configured SSI using the "httpd.conf" file just as in Apache1. On Debian it appears Apache is configured with the config "apache2.conf" instead of "httpd.conf" -- there is no apache2.conf on my Windows machine.

Furthermore, it appears Apache2 is automatically configured to parse .shtml files. According to information found on the Apache2 documentation site to enable SSI I have to use the httpd.conf or .htaccess files:

http://httpd.apache.org/docs/2.0/howto/ssi.html
"To permit SSI on your server, you must have the following directive either in your httpd.conf file, or in a .htaccess file: Options +Includes"


Yet, according to the comments in the /etc/apache2/httpd.conf file this is only meant for backward compatibility:
# This is here for backwards compatability reasons and to support

And according to the Apache2 documentation you should never use .htaccess:

http://httpd.apache.org/docs/2.0/howto/htaccess.html
"In general, you should never use .htaccess files unless you don't have access to the main server configuration file."


So, what am I supposed to do? Should I edit the httpd.conf? Use .htaccess? I would like to configure this the recommended way but, the documentation appears to contradict itself.

Thanks in advance,
Joey

falko
13th February 2006, 10:27
I have several .shtml pages that I have moved from Apache2 on Windows to Apache2 on Debian that are not loading. I can visit the individual pages that are included on the index page and they load normally -- they just do get included.
Do you get any errors?

With Apache2 on Windows I configured SSI using the "httpd.conf" file just as in Apache1. On Debian it appears Apache is configured with the config "apache2.conf" instead of "httpd.conf" -- there is no apache2.conf on my Windows machine.
Yes, on Debian Sarge with Apache 2 it's apache2.conf instead of httpd.conf.


So, what am I supposed to do? Should I edit the httpd.conf? Use .htaccess? I would like to configure this the recommended way but, the documentation appears to contradict itself.

Thanks in advance,
Joey
Normally, you would edit apache2.conf. But I don't think you must change anything in apache2.conf - I've never had problems with SSI in the standard configuration on Debian. I think the problem is that you did not enable the include module. Please run this:

a2enmod include
and restart Apche.

jchaven
13th February 2006, 15:49
Did not work.

Here is what I did:
debian:/usr/sbin# a2enmod include
Module include installed; run /etc/init.d/apache2 force-reload to enable.
debian:/usr/sbin# apache2ctl -k restart

Here is what is in test.shtml:
<TITLE></TITLE>
</HEAD>
<BODY>
THIS IS TEST.SHTML
<HR>MENU:<br>
<!-- #include file="menu.html" -->
<HR>FILE 1:<br>
<!-- #include virtual="/mrtg/file1.html" -->
<HR>FILE 2:<br>
<!-- #include virtual="http://221.21.21.4/mrtg/file2.html" -->

this is the end
</BODY>
</HTML>


The output is all the HTML including rules. Nothing in the html files appears.

Thanks for your help!
Joey

falko
13th February 2006, 18:58
Do you have these lines in apache2.conf?

AddType text/html .shtml
AddOutputFilter INCLUDES .shtml

jchaven
14th February 2006, 04:08
Yes. Here are the lines from the config:

# To use server-parsed HTML files
#
<FilesMatch "\.shtml(\..+)?$">
SetOutputFilter INCLUDES
</FilesMatch>

AddType text/html .shtml
AddOutputFilter INCLUDES .shtml


Here is an entry from the log that may help:
mod_include: Options +Includes (or IncludesNoExec) wasn't set, INCLUDES filter removed


Here are the only lines in the config that reference "IncludesNoExec":
<IfModule mod_negotiation.c>
<IfModule mod_include.c>
Alias /error/ "/usr/share/apache2/error/"

<Directory "/usr/share/apache2/error">
AllowOverride None
Options IncludesNoExec
AddOutputFilter Includes html
AddHandler type-map var
Order allow,deny
Allow from all
LanguagePriority en es de fr
ForceLanguagePriority Prefer Fallback
</Directory>

ErrorDocument 400 /error/HTTP_BAD_REQUEST.html.var
ErrorDocument 401 /error/HTTP_UNAUTHORIZED.html.var
ErrorDocument 403 /error/HTTP_FORBIDDEN.html.var
ErrorDocument 404 /error/HTTP_NOT_FOUND.html.var
ErrorDocument 405 /error/HTTP_METHOD_NOT_ALLOWED.html.var
ErrorDocument 408 /error/HTTP_REQUEST_TIME_OUT.html.var
ErrorDocument 410 /error/HTTP_GONE.html.var
ErrorDocument 411 /error/HTTP_LENGTH_REQUIRED.html.var
ErrorDocument 412 /error/HTTP_PRECONDITION_FAILED.html.var
ErrorDocument 413 /error/HTTP_REQUEST_ENTITY_TOO_LARGE.html.var
ErrorDocument 414 /error/HTTP_REQUEST_URI_TOO_LARGE.html.var
ErrorDocument 415 /error/HTTP_SERVICE_UNAVAILABLE.html.var
ErrorDocument 500 /error/HTTP_INTERNAL_SERVER_ERROR.html.var
ErrorDocument 501 /error/HTTP_NOT_IMPLEMENTED.html.var
ErrorDocument 502 /error/HTTP_BAD_GATEWAY.html.var
ErrorDocument 503 /error/HTTP_SERVICE_UNAVAILABLE.html.var
ErrorDocument 506 /error/HTTP_VARIANT_ALSO_VARIES.html.var

</IfModule>
</IfModule>

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

# UserDir is now a module
#UserDir public_html
#UserDir disabled root

#<Directory /home/*/public_html>
# AllowOverride FileInfo AuthConfig Limit
# Options Indexes SymLinksIfOwnerMatch IncludesNoExec
#</Directory>

Thanks again,
Joey

jchaven
14th February 2006, 05:28
I got it working but, I don't know why. I had to add the following to the apache2.conf:
<Directory /var/www/*>
Options +Includes
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
</Directory>

Why didn't the following existing config work:
# To use server-parsed HTML files
#
<FilesMatch "\.shtml(\..+)?$">
SetOutputFilter INCLUDES
</FilesMatch>

AddType text/html .shtml
AddOutputFilter INCLUDES .shtml

I appreciate your help anyway.

Thanks!
Joey

falko
14th February 2006, 10:10
Why didn't the following existing config work:
# To use server-parsed HTML files
#
<FilesMatch "\.shtml(\..+)?$">
SetOutputFilter INCLUDES
</FilesMatch>

AddType text/html .shtml
AddOutputFilter INCLUDES .shtml

I appreciate your help anyway.

As the log said, you must set Options +Includes for the directory where you want to use SSI.

Luckyfox
25th August 2008, 18:06
Did not work.

Here is what I did:
debian:/usr/sbin# a2enmod include
Module include installed; run /etc/init.d/apache2 force-reload to enable.
debian:/usr/sbin# apache2ctl -k restart

Here is what is in test.shtml:
<TITLE></TITLE>
</HEAD>
<BODY>
THIS IS TEST.SHTML
<HR>MENU:<br>
<!-- #include file="menu.html" -->
<HR>FILE 1:<br>
<!-- #include virtual="/mrtg/file1.html" -->
<HR>FILE 2:<br>
<!-- #include virtual="http://221.21.21.4/mrtg/file2.html" -->

this is the end
</BODY>
</HTML>


The output is all the HTML including rules. Nothing in the html files appears.

Thanks for your help!
Joey

I know this might sound obvious but I missed it :( Make sure you use single quotes not double quotes eg:

<!-- #include file="menu.html" --> = Wrong
<!-- #include file='menu.html' --> = CORRECT

Worked for me

Nigel