CGI (Common Gateway Interface) scripts allow you to run programs or scripts (such as .cgi, .pl, or .py) on your web server to generate dynamic content. By default, many servers only allow CGI scripts in the cgi-bin directory, but you may want to enable CGI for a specific folder within your hosting account.

This guide will show you how to enable CGI in any folder using a .htaccess file.

What is CGI-Bin?

  • cgi-bin is a directory where servers typically store executable CGI scripts.

  • These scripts can perform tasks like form processing, database connections, and generating dynamic web pages.

  • Enabling CGI for other folders gives developers more flexibility in organizing their web applications.

Steps to Enable CGI-Bin for Any Folder

1. Create a .htaccess File

In the folder where you want to enable CGI, create a new file named: “.htaccess“

2. Add Execution Permission

Insert the following directive in the .htaccess file:

“Options +ExecCGI”

3. Define CGI Handlers

Add the handlers for CGI scripts so that the server knows how to process them:

“AddHandler cgi-script .cgi .pl”

4. (Optional) Update Apache Config

If your setup requires additional configuration, you can update the Apache config file:

Include /etc/httpd/conf/site#/enable-cgi
Options +ExecCGI

5. Restart Apache

For changes to take effect, restart the Apache service:

systemctl restart httpd

By creating a .htaccess file and adding the right directives, you can enable CGI-bin functionality for any folder on your server. This allows more flexibility in running scripts and building dynamic web applications. Always remember to set correct file permissions and follow security best practices while working with CGI.

Popular Posts You May Read

Explore more hosting insights, tips and industry updates.

Outlook Express Error Codes and Explanation

0x800CCC00 LOAD_SICILY_FAILED –  Authentication did not load.0x800CCC01 INVALID_CERT_CN – Invalid certificate content0x800CCC02 INVALID_CERT_DATE – Invalid…

How to Reset the Password for a MySQL Database Client in cPanel

In this post, we’ll look at how to reset the password for a MySQL database…

How to View System Users in Ubuntu Linux

This article explains how to view system users in Ubuntu Linux VPS. In Ubuntu Linux,…