Cloud Service >> Knowledgebase >> Plesk >> Why CGI Scripts Are Not Working In Plesk?
submit query

Cut Hosting Costs! Submit Query Today!

Why CGI Scripts Are Not Working In Plesk?

When CGI (Common Gateway Interface) scripts aren't operating in Plesk, several factors might be inflicting the issue, ranging from configuration problems to permission settings. Below is an in depth manual to help you troubleshoot and resolve issues with CGI scripts in Plesk:

1. Verify CGI Is Enabled for the Domain

Log in to Plesk: Access your Plesk control panel using your credentials.

Navigate to Hosting Settings:

Go to Websites & Domains.

Click on the domain where you're trying to run the CGI script.

Click on Hosting Settings.

Check CGI Support:

Ensure that the "CGI support" checkbox is checked. If it isn't, check it and save the settings.

If you had to enable it, try running your CGI script again after the change.

2. Check the Script’s File Permissions

Access File Manager:

In Plesk, go to Websites & Domains > File Manager.

Locate Your CGI Script:

Navigate to the cgi-bin directory where your CGI scripts are stored.

Set Correct Permissions:

Right-click on the script file and select Change Permissions (or use the "Permissions" link in the File Manager).

Ensure the script has the correct permissions:

File permissions: Generally, the permissions should be set to 0755 (rwxr-xr-x) to allow the script to be executed.

Owner permissions: Make sure the script is owned by the correct user, usually the one associated with the domain.

3. Ensure the Script Has the Correct Shebang

Edit the Script:

Open the script in a text editor through the File Manager.

Check the Shebang Line:

The first line of your CGI script should indicate the correct path to the interpreter (e.g., #!/usr/bin/perl for Perl scripts).

You can verify the interpreter path by checking with your hosting provider or using SSH to locate the path (which perl or which python).

4. Verify the cgi-bin Directory Configuration

Correct Directory Location:

Make sure that your CGI scripts are placed in the cgi-bin directory of your website. Plesk expects CGI scripts to reside here.

Directory Permissions:

Ensure the cgi-bin directory itself has the correct permissions, typically set to 0755.

5. Check for Syntax Errors in the CGI Script

Review the Code:

Open the script and carefully review the code for any syntax errors or typos.

Run in a Terminal (Optional):

If possible, run the script from a terminal to check for syntax errors before executing it in the web environment.

6. Review Server Logs for Errors

Access Error Logs:

In Plesk, go to Websites & Domains > Logs.

Check for Specific Errors:

Look for any error messages related to CGI scripts. Common errors might include "500 Internal Server Error," which could indicate a problem with the script or its permissions.

Debugging Information:

Use the error log information to diagnose what might be going wrong with the script.

7. Check .htaccess File Configuration

Open the .htaccess File:

If your domain uses a .htaccess file, open it from the File Manager.

Verify CGI Settings:

Ensure that the .htaccess file doesn’t contain directives that prevent the execution of CGI scripts. If you're not sure, temporarily rename the .htaccess file to see if the script works without it.

Add the Right Directives:

You might need to add the following line to the .htaccess file:
apache
Copy code
Options +ExecCGI

AddHandler cgi-script .cgi .pl

  •  
  • This allows CGI scripts to run in directories other than cgi-bin.

8. Confirm the Script Is Not Timing Out

Review Script Execution Time:

If the script is long-running, it might be timing out. Check with your cloud hosting provider about script execution limits and see if they can be extended.

9. Server and Script Compatibility

Check Interpreter Versions:

Ensure that the CGI script is compatible with the version of Perl, Python, or another language installed on the server.

Update Scripts:

If the server environment has been updated, you may need to update your script to be compatible with the new environment.

10. Contact Support

Seek Professional Help:

If you’ve tried all of the above steps and your CGI scripts still aren’t working, contact your hosting provider’s support team. Provide them with details about the issue, including any error messages you’ve encountered.

Cut Hosting Costs! Submit Query Today!

Grow With Us

Let’s talk about the future, and make it happen!