Getting SSI’s `exec` to work with apache

apache-2.4server-side-includes

so i have an apache-2.4.25 (as packaged in Debian/stretch), and would like to use SSI's exec method.

<!--#exec cmd="ls" -->

Unfortunately this gives me an error:

[an error occurred while processing this directive]

In the logfiles it says

unknown directive "exec" in parsed doc /path/to/some/user/public_html/ssitest/index.shtml

which I tracked down to having Options +IncludesNOEXEC enabled in my userdir.conf (which disables the exec directive for SSI).
So I tried to turn that option off for a single specific VHost, by putting the following into the VirtualHost section:

Options -IncludesNOEXEC
Options +Includes

Unfortunately this doesn't help.

So I tried with in the Directory section, but still no luck:

Alias /ssitest/ /path/to/some/user/public_html/ssitest/
Options -IncludesNOEXEC
Options +Includes
<Directory /path/to/some/user/public_html/ssitest/>
  Options -IncludesNOEXEC
  Options +Includes
</Directory>

Whenever I try to access my page, I get the an error occurred while processing this directive error.

So is there a way to disable a previously set option?

Best Answer

You need to enable mod_cgi. I now check ssi exec run on Ubuntu 16.04+apache2 - it works if you enable mod_include and mod_cgi, and put Options +Includes in htaccess or in <Directory... >.

Options -IncludesNOEXEC wasn't needed in my case.

Related Topic