• Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us
TecAdmin
Menu
  • Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us

How To Enable or Disable CGI Scripts in Apache 2.4

Written by Rahul, Updated on July 29, 2019

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

Share it!
Share on Facebook
Share on Twitter
Share on LinkedIn
Share on Reddit
Share on Tumblr
Share on Whatsapp
Rahul
Rahul
Connect on Facebook Connect on Twitter

I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a Red Hat Certified Engineer (RHCE) and working as an IT professional since 2009..

3 Comments

  1. Avatar steve Reply
    October 10, 2019 at 7:37 pm

    Thank you. My site hosted on AWS has been subjected to malicious activity. As I do not use CGI I am turning it off.

  2. Avatar Marco Reply
    December 5, 2018 at 4:23 am

    Like your site alot thanks

  3. Avatar O2infosystems Reply
    January 27, 2016 at 5:23 am

    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 .

Leave a Reply Cancel reply

Popular Posts

  • How to Install Python 3.9 on CentOS/RHEL 7 & Fedora 32/31 0
  • How To Install VNC Server on Ubuntu 20.04 1
  • How To Install NVM on macOS with Homebrew 0
  • (Solved) apt-add-repository command not found – Ubuntu & Debian 0
  • How to Install .NET Core on Debian 10 0
© 2013-2020 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy