How To Enable or Disable CGI Scripts in Apache 2.4
Abstract: LinuxMint and other Debian derivatives use the following command to disable CGI module. a2dismod cgimodule. This tutorial will help you to how to enab
Apache Module mod_cgi/mod_cgid is responsible for handling of CGI Scripts. for worker and event, multi-threaded MPM uses CGI daemon 「mod_cgid」 module. This tutorial will help you to how to enable or disable CGI script in Apache 2.4 server on Linux operating systems.
Enable CGI Module in ApacheTo enable CGI in your Apache server. you need to Load module file mod_cgi.so or mod_cgid.so in your Apache configuration file.
The CentOS, Red Hat, Fedora and other rpm based distributions edit /etc/httpd/conf.modules.d/XX-cgi.conf configuration file and make sure below showing lines are not commented.
<IfModule mpm_worker_module> LoadModule cgid_module modules/mod_cgid.so </IfModule> <IfModule mpm_event_module> LoadModule cgid_module modules/mod_cgid.so </IfModule> <IfModule mpm_prefork_module> LoadModule cgi_module modules/mod_cgi.so </IfModule>
Ubuntu, Debian, LinuxMint and other Debian derivatives use the following command to enable CGI module. This command creates a soft link of the module configuration file to /etc/apache2/mod-enabled/ directory.
sudo a2enmod cgi
After enabling CGI modules in Apache configuration you need to restart Apache service on your system for changes take effect.
Disable CGI Module in ApacheWe recommend keeping CGI disabled on your server until its recommended for your server. CGI scripts are used by hackers to attack servers. Use below options to disable CGI script on your Apache server.
CentOS, Red Hat, Fedora and other rpm based distributions rename /etc/httpd/conf.modules.d/XX-cgi.conf configuration file like below.
mv /etc/httpd/conf.modules.d/XX-cgi.conf /etc/httpd/conf.modules.d/XX-cgi.conf.disable
Ubuntu, Debian, LinuxMint and other Debian derivatives use the following command to disable CGI module.
a2dismod cgi
After disabling CGI modules you need to restart Apache service on your system for changes take effect.
Reference:-
http://httpd.apache.org/docs/2.4/howto/cgi.html