Troubleshooting CGI scripts
CGI (Common Gateway Interface) scripts allow web servers to run external programs, often written in Perl, Python, or other languages. On ruachost.com, CGI scripts run under your user ID, so proper configuration is essential for them to work correctly.
Common Issues and Fixes
Section titled “Common Issues and Fixes”Step 1: Verify Script File Permissions
Section titled “Step 1: Verify Script File Permissions”-
CGI scripts must have execute permissions.
-
Set permissions using:
Terminal window chmod 755 script.cgi -
Incorrect permissions are one of the most common causes of failure.
Step 2: Verify the Shebang Line
Section titled “Step 2: Verify the Shebang Line”-
The first line of your script must specify the correct interpreter.
-
Example for Perl:
#!/usr/bin/perl -
If the shebang is missing or incorrect, Apache won’t know how to run the file.
Step 3: Run the Script from the Command Line
Section titled “Step 3: Run the Script from the Command Line”-
Debugging through a browser often hides useful error messages.
-
Log in via SSH and run:
Terminal window ./script.cgi -
This will display syntax errors or missing module issues directly.
Step 4: Check Web Server Error Logs
Section titled “Step 4: Check Web Server Error Logs”-
Errors such as 500 Internal Server Error or 403 Forbidden are logged.
-
Access logs via cPanel → Metrics → Errors or SSH:
Terminal window tail -100 /var/log/apache2/error.log -
Review logs for permission issues, syntax errors, or misconfigurations.
Step 5: Contact Support
Section titled “Step 5: Contact Support”- If all else fails, open a Support Ticket.
- Provide details: script name, error messages, and steps you’ve tried.
- The Ruachost support team can assist further.