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:
- Log in to your server as the
root
user via SSH. - Change to the
/usr/local/apache/conf/
directory. - 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. - 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>
- Change the
AllowOverride
line’s value fromAll
toNone
. - 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:
- Log in to your server via SSH as the
root
user. - Change to the
/usr/local/apache/conf/
directory. - 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. - 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.
Leave A Comment?
You must be logged in to post a comment.