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 Apache
To 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 Apache
We 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
3 Comments
Thank you. My site hosted on AWS has been subjected to malicious activity. As I do not use CGI I am turning it off.
Like your site alot thanks
I just want to say that I like your posting. In fact I am using your site regularly. Your articles are very effective and i am very thankful to you for sharing this site with knowledgeable content .