Enable CGI on apache2 in Debian so scripts actually run

Share your wisdom. Not for support questions!

Moderator: How-to Curator

Enable CGI on apache2 in Debian so scripts actually run

Postby polaris96 » November 4th, 2015, 8:04 pm

THE SYMPTOM:

Even with cgi enabled (mod_cgi) scripts either don't run or run with weird intermittent problems. Sometimes Perl or PHP will run (In this case, you'll notice the perl or PHP modules are installed.) You might also see weird effects with form data, like no env(QUERY_STRING) . sh and bash will only return code without executing.


THE CAUSE:

Debian ships apache2 as a multi-threading (mpm) build. mod_cgi is WRONG for mpm builds. Instead, use mod_cgid. The command syntax is the same for both modules.


THE FIX

Very Simple:

Code: Select all
~$su
~#apache2ctl stop
~#a2dismod cgi
~#a2enmod cgid
~#apache2ctl start



OTHER THINGS YOU MAY NEED TO DO:

IF you've been messing around trying to fix the issue, you may have rearranged things like ScriptAlias, <directory></directory>, AddHandler. In such a case, you need to re-create the vanilla .conf files that apache installed with (internet or aptitude reinstall. if you're using apt[itude] remember to re-enable cgid and restart apache2.

Just point ScriptAlias to your fav cgi directory and it should run good.


STILL NOT WORKING?

There are cgi tutorials ad-nauseum to address the basic issues (permissions, $PATH, etc). I only wrote this because I haven't seen anybody else post this advice and I lost 20 unbillable hours tracking down the problem. If you've tried everything else, this should get you by.


WHERE CAN I FIND MORE?

There isn't much. Start here: https://httpd.apache.org/docs/2.2/mod/mod_cgi.html


Enjoy :)
for as long as the world remains. for as long as time remains. so, too, will I remain. To serve. To help. And to make my contribution. Also please visit old friends at forums.debian.net
polaris96
 
Posts: 161
Joined: July 29th, 2011, 4:45 pm

Return to HowTo

Who is online

Users browsing this forum: No registered users and 2 guests

x