Recently I tried to install a web perl application that ask me to have CGI module enabled in the Apache Web server. I’m gonna show you how this option is enabled and how it works.
If your application call CGI module you have to put it on authorized directory (this use to have a name like “cgi-bin” on server’s hosts plan). E.g You have a web page in document Root:/var/www/html
and into this directory there’s an index.htm calling, on one of its links, an a application that uses CGI… so to get it work create a subdirectory:/var/www/html/cgi-bin (this subdirectory may be on another system path like $HOME/www/cgi-bin or whatever you like but it has to be able to be read and execute)
and on the httpd.conf or Apache’s configuration file submit this:
ScriptAlias /cgi-bin "/var/www/html/cgi-bin/" <Directory "/var/www/html/cgi-bin/"> AllowOverride all Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch order allow,deny Allow from all </Directory>
and add the file type for the application to be identified as cgi content:
AddHandler cgi-script cgi pl ; in this case is a perl app
Then reload Apache Web Server and put the application into authorized directory and redirect all the links that call it to that path.
note: Before try, make sure that your system has installed the cgi module and perl module and this last is enabled.
FOR MULTIPLE DIRECTORIES
Just make a .htaccess on the directory you want to enable CGI content putting the option:
and obviously you should have the AllowOverride set to all on the apache’s configuration file for that directory:
<Directory /var/www/html/cgi-bin> AllowOverride all </Directory>
But the AddHandler option must be determinated.