Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Web Servers»Apache»How To Enable or Disable CGI Scripts in Apache 2.4

    How To Enable or Disable CGI Scripts in Apache 2.4

    By RahulJuly 29, 20192 Mins Read

    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.

    Advertisement

    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

    Apache Apache 2.4 CGI mod_cgi
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    CodeIgniter Remove index.php Using .htaccess

    Configuring the Nginx Reverse Proxy in Front of Apache

    Simple Redirects with .htaccess

    View 3 Comments

    3 Comments

    1. steve on October 10, 2019 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.

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

      Like your site alot thanks

      Reply
    3. O2infosystems on January 27, 2016 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 .

      Reply

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • How to Split Large Archives in Linux using the Command Line
    • System.out.println() Method in Java: A Beginner’s Guide
    • Split Command in Linux With Examples (Split Large Files)
    • Test Your Internet Speed from the Linux Terminal
    • 11 Practical Example of cat Command in Linux
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.