SSI with Apache2 on Debian

Discussion in 'Server Operation' started by jchaven, Feb 13, 2006.

  1. jchaven

    jchaven New Member

    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
     
  2. falko

    falko Super Moderator

    Do you get any errors?

    Yes, on Debian Sarge with Apache 2 it's apache2.conf instead of httpd.conf.


    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:

    Code:
    a2enmod include
    and restart Apche.
     
  3. jchaven

    jchaven New Member

    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
     
  4. falko

    falko Super Moderator

    Do you have these lines in apache2.conf?

    Code:
    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml
     
  5. jchaven

    jchaven New Member

    Yes. Here are the lines from the config:

    Code:
    # 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:
    Code:
    mod_include: Options +Includes (or IncludesNoExec) wasn't set, INCLUDES filter removed

    Here are the only lines in the config that reference "IncludesNoExec":
    Code:
    <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
     
  6. jchaven

    jchaven New Member

    I got it working but, I don't know why. I had to add the following to the apache2.conf:
    Code:
    <Directory /var/www/*>
         Options +Includes
         AddType text/html .shtml
         AddOutputFilter INCLUDES .shtml
    </Directory>
    Why didn't the following existing config work:
    Code:
    # 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
     
  7. falko

    falko Super Moderator

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

    Luckyfox New Member

    Fixed

    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
     

Share This Page