Enabling Apache Server-Side Includes on Ubuntu 14.04

Apache Server-Side Includes (SSIs) allows Apache to serve dynamically generated content to your webpage. This process will be slightly different if you’re familiar with Apache on CentOS. First we’ll need to add some directives to our Apache configuration. This will be located in /etc/apache2/sites-enabled/000-default.conf. We’ll want our site’s directory to at least have to following directives:

This will allow for Apache includes for this directory and will tell Apache to parse files with the extensions .html and .php. Next we’ll enable the include module using the a2enmod command. You can view what modules are available and enabled by taking a look at /etc/apache2/mods-available/ and /etc/apache2/mods-enabled/ respectively. Enable the include module and then restart Apache.

The following is an example of using an SSI with conditional statements to give us a different output depending on the time according to our server.