When SSI isn't processing .shtml files on Debian's Apache, the first step is verifying the required modules are enabled. From your phpinfo()
output, I notice mod_include
isn't listed among loaded modules - this is absolutely essential for SSI functionality.
Let's walk through the complete setup process:
# First, enable the include module
sudo a2enmod include
# Verify the module is properly linked
ls -l /etc/apache2/mods-enabled/include*
# Typical output should show:
# include.load -> ../mods-available/include.load
Your virtual host configuration needs these critical elements:
<VirtualHost *:80>
ServerName domain.com
DocumentRoot /home/username/public_html
<Directory /home/username/public_html>
Options +Includes
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Create a simple test file named test.shtml
:
<!--#echo var="DATE_LOCAL" -->
<!--#include virtual="/footer.html" -->
Then check if it's being parsed:
curl -I http://domain.com/test.shtml
# Should show Content-Type: text/html
Enable verbose logging temporarily:
sudo tail -f /var/log/apache2/error.log
# Add this to your virtual host for detailed SSI logging:
LogLevel info include:trace6
- The
XBitHack
directive can interfere with explicit SSI configuration - Missing
AddOutputFilter
directive for .shtml files - Incorrect permissions on .shtml files (should be 644)
After making changes, always:
sudo apache2ctl configtest
sudo systemctl restart apache2
For additional debugging, you can create a phpinfo()
page and verify that "mod_include" appears in the loaded modules section.
When dealing with SSI (Server Side Includes) not parsing .shtml files on Debian with Apache, we need to thoroughly examine several configuration aspects. The key symptom is that .shtml files are being served as plain text rather than being processed by the server.
First, verify that all required modules are properly enabled:
sudo a2enmod include
sudo service apache2 restart
The minimal required modules for SSI are:
mod_include.so
mod_setenvif.so
mod_mime.so
Your virtual host configuration needs these essential directives:
<VirtualHost *:80>
ServerName example.com
DocumentRoot /var/www/html
<Directory "/var/www/html">
Options +Includes
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
AllowOverride All
</Directory>
</VirtualHost>
Create a simple test.shtml file to verify SSI processing:
<!--#echo var="DATE_LOCAL" -->
<!--#include virtual="/footer.html" -->
If this displays the current date and includes the footer file, SSI is working correctly.
1. Check Apache error logs for SSI-related messages:
tail -f /var/log/apache2/error.log
2. Verify module loading order in apache2.conf:
LoadModule include_module /usr/lib/apache2/modules/mod_include.so
3. For debugging purposes, temporarily add this to your configuration:
XBitHack on
For environments needing more granular control:
AddType text/html .shtml
AddHandler server-parsed .shtml
DirectoryIndex index.shtml index.html
Remember to restart Apache after any configuration changes:
sudo systemctl restart apache2
When enabling SSI, be aware of these security implications:
Options +IncludesNOEXEC
This prevents execution of potentially dangerous SSI commands while still allowing basic includes.