How to troubleshoot CGI scripts

If your CGI (Common Gateway Interface) script isn't working, try the following troubleshooting steps:

Step 1: Check the script file permissions.

CGI scripts are launched by Hostginger Hosting's shared web servers using your user ID. One of the most typical reasons why a CGI script does not run is that the execute permission on the file is not set. Check that the CGI script file has the appropriate permissions.

Step 2: Verify the shebang.

Check that the shebang in the CGI script file is valid. CGI script files must begin with the right shebang, else the Apache web server will fail to recognize the file.

Step 3: Use the command line to run the script.

Trying to debug a CGI script in a web browser can be a tedious experience. If you get a "500 Internal Server Error," for example, the fundamental problem could be file permissions, a syntax mistake, or something else entirely. Logging in to your SSH account and running the script from the command line will provide you with much more helpful information regarding script problems.

Step 4: Examine the web server error logs.

The error log on the web server may give useful information about why a CGI script is not functioning. Scripts that generate a "500 Internal Server Error" or "403 Forbidden" error message are recorded in the error log of the web server. You may view your website's error log using cPanel.

Was this answer helpful?

Related Articles

'403 Forbidden' error message

Problem You get a "403 Forbidden" error notice when you try to access your site with a web...

How to disable entity tags (ETags)

This article will show you how to stop your website from sending entity tags (ETags) in HTTP...

How to install Apache Tomcat

Apache Tomcat is a well-known and dependable open-source Java web server. Tomcat is a Java HTTP...

How to use keep-alive connections to improve performance

This article explains how to use keep-alive connections to improve performance in Apache. How to...

How to use Server-Side Includes (SSI)

This tutorial will show you how to set up and use Apache Server-Side Includes (SSI) on your...