Apache2 und SSI mit mod_include
SSI wird mit dem Apache Module mod_include bereit gestellt. Dieses Modul muss nur mit folgenden Befehl geladen werden.
root:~# a2enmod include
Nun erstellen wir für das Include Modul eine Konfigurationsdatei.
root:~# vi /etc/apache2/mods-available/include.conf
# SSI settings - mod_include.c
#
<IfModule mod_include.c>
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
<FilesMatch "\.shtml(\..+)?$">
SetOutputFilter INCLUDES
</FilesMatch>
</IfModule>
Damit die Konfigurationsdatei für das Include Modul auch geladen wird, erstellen wir noch einen Symlink im /etc/apache2/mods-enabled
Verzeichnis.
root:~# cd /etc/apache2/mods-enabled/
root:/etc/apache2/mods-enabled# ln -s ../mods-available/include.conf
Nun erstellen wir unter /var/www
eine test.shtml um SSI zu testen.
root:~# cd /var/www
root:/var/www# vi test.shtml
<html>
<head>
<title></title>
</head>
<body>
<!--#echo var="DATE_LOCAL" --> Uhr<br>
</body>
</html>
Damit die Änderungen aktiv werden, müssen wir nur noch den Apache Webserver neu starten.
root:/var/www# /etc/init.d/apache2 restart
In dieser oben beschriebenen Methode ist SSI für den kompletten Server aktiviert. Will man SSI nur für bestimmte Virtual Host einstellen, bindet man die include.conf einfach im entsprechenden vhost Datei mit Include ein. Dann sollte man natürlich den Symlink include.conf in /etc/apache2/mods-enabled/
wieder entfernen.
root:/var/www# vi /etc/apache2/sites-available/default
# default vhost
<VirtualHost *:80>
ServerName localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www>
Options Indexes Includes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
# SSI Modul einbinden
Include /etc/apache2/mods-available/include.conf
ErrorLog /var/log/apache2/error.log
CustomLog /var/log/apache2/access.log combined
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
</VirtualHost>