How to Enable Additional CGI Scripts in WHM

How to Enable Additional CGI Scripts in WHM

Overview

Apache version 2.2 allows you to use CGI scripts in directories other than the cgi-bin directory. To prevent the use of CGI scripts in directories other than the cgi-bin, you must disable the ability of individual .htaccess files to override the server settings.

Apache version 2.4 prevents the use of CGI scripts in directories other than the cgi-bin directory. To use CGI scripts in other directories, you must enable the ability of individual .htaccess files to override the server settings.

Change the CGI scripts’ availability.

Click the tabs below for directions about how to prevent the use of CGI scripts, or restore the default settings.

Disable CGI though .htaccess

To disable CGI through .htaccess, perform the following steps:

  1. Log in to your server as the root user via SSH.
  2. Change to the /usr/local/apache/conf/ directory.
  3. Create a backup of your httpd.conf file. For example:
    cp httpd.conf httpd-old.conf

    Note:

    In this example, http-old.conf represents the backup file’s name.

  4. Open your http.conf file with a text editor and locate the section of the file that resembles the following example:
    <Directory "/">
        Options +ExecCGI +FollowSymLinks +Includes +IncludesNOEXEC +Indexes -MultiViews +SymLinksIfOwnerMatch
        AllowOverride All
    </Directory>
  5. Change the AllowOverride line’s value from All to None.
  6. Run the distiller to update the settings. To do this, run the following command:
    /usr/local/cpanel/bin/apache_conf_distiller --update

Your server now only allows CGI scripts to run in the cgi-bin directories.

Restore the .htaccess files’ original setting

To restore the .htaccess files to their original setting, perform the following steps:

  1. Log in to your server via SSH as the root user.
  2. Change to the /usr/local/apache/conf/ directory.
  3. Restore the original httpd.conf file. To do this, run the following command:
    rm httpd.conf
    mv httpd-old.conf httpd.conf

    Remember:

    In this example, http-old.conf represents the backup file’s name.

  4. Run the distiller to update the settings. To do this, run the following command.
    /usr/local/cpanel/bin/apache_conf_distiller --update

You have restored the .htaccess files to their default setting.

Was this article helpful?

Related Articles

Leave A Comment?