What is cgi-bin? | HostGator Support
  1. Knowledge Base
  2. >
  3. Results
  4. >
  5. What is cgi-bin?

What is cgi-bin?

 

In the most basic of terms, CGI or Common Gateway Interface is the process for scripts to communicate with your hosting server. The folder for CGI scripts is what we call the cgi-bin. It is created in the directory root of your website and where your scripts are permitted to run or execute. The cgi-bin folder will store the scripts such as Perl (.pl) used by your website.

For the scripts to run, the permissions of the cgi-bin folder and the scripts within it should all be set to 0755.

Click the links below to find out more about CGI or Common Gateway Interface:


What does CGI do, and why does it matter?

Technically, CGI improves the visualization of your website. This is especially useful for e-commerce websites. CGI provides visitors with great visual content to help them understand the product and ultimately become one of your customers. CGI is used extensively nowadays for marketing, virtual reality, architecture, and even artistic purposes. You can now imagine how useful and advantageous CGI is for a simple website to achieve that 3D look or realistic effect on online visitors.


How do you run your CGI Scripts?

You can create your CGI scripts and store them in your cgi-bin, and then run or access these scripts through your browser by calling them through their URL. These scripts usually have the .pl or .py file extensions (from the Perl and Python programming languages). Please make sure to set the permission of your cgi-bin folder to 0755 to make the scripts executable.

Example:

https://www.example.com/cgi-bin/samplescript.pl

Please refer to this article, CGI Troubleshooting, to troubleshoot your CGI scripts.


Where do you find the cgi-bin?

The cgi-bin is found in the directory root of your website inside your server.

cPanel - File Manager - Directory Root for cgi-bin


Can you delete cgi-bin?

The cgi-bin is located in the directory root of your website. If there are no scripts stored in that folder, you can delete that folder. It should not be a problem with your website. However, if there are scripts in it and you are unsure if those are essential to your website, it is best to leave them there.

If you deleted this folder and later found out that your website does need the scripts, you can still recreate the cgi-bin folder inside the directory root and save your CGI scripts there again.


What is the difference between CGI and Perl?

The CGI scripts or applications are written using different programming languages. Perl is only one of them (with .pl extension). Other common programming languages used are C and Python. This should be applicable in all of our hosting environments.


How do you enable CGI outside of the cgi-bin?

By default, this feature should be enabled in your hosting server. However, if you cannot run CGI scripts out of your cgi-bin folder, you can try enabling CGI through your .htaccess. You can use the following codes in your .htaccess file.

AddHandler cgi-script .cgi .pl
Options +ExecCGI