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/conf-available/ssi-enabled.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 systemweit geladen wird, aktivieren wir die Konfiguration wie folgt.
root:~# a2enconf ssi-enabled.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# systemctl restart apache2
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 ssi-enabled.conf einfach im entsprechenden vhost Datei mit Include ein. Dann sollte man natürlich die Konfiguration global mit a2disconf ssi-enabled.conf
deaktivieren.
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/conf-available/ssi-enabled.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>