
The short answer: Perl and CGI scripts (many old forms and counters) work on hosting, but they are demanding: the file must have execute permission (755), the first line must point to the right Perl, the lines must end as on Linux (LF), and the script must start by writing a header. Failing any one gives the same error: 500.
A minimal script that should work
Create a file called test.cgi with this content:
#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "<h1>It works</h1>";
Upload it to the site’s cgi-bin folder (or to the folder where CGI is enabled), give it permission 755 and open your-domain.com/cgi-bin/test.cgi. If “It works” appears, the rest is your script.
The causes of error 500, in order
| Cause | How to recognise it | What to do |
| The header is missing | The log says “Premature end of script headers”. | The first thing the script writes must be Content-type: text/html followed by an empty line. |
| Wrong permission | The file has no execute permission, or is too open (777). | Set 755 on the script and the folder: File permissions. |
| Wrong Perl path | The first line (#!/usr/bin/perl) does not exist on this server. | Confirm Perl’s path on your server (in a terminal, which perl) or ask us. |
| Windows line endings (CRLF) | The script was written on Windows and uploaded as binary: the first line becomes “/usr/bin/perl^M”, which does not exist. | Save the file with Unix line endings (LF) in the editor, or upload it in text mode by FTP. |
| An error in the code itself | The log shows a line of the script. | Run it in a terminal: perl -c test.cgi checks the syntax. |
| A missing Perl module | “Can’t locate ... in @INC”. | See the modules in cPanel, or ask us to install it. |
| Old scripts are a risk. Many were never updated and have known flaws (forms that let anyone send e-mail, for example). Before using them, see whether there is a current alternative: A safe, spam-free form. To read the log, see Reading the Errors pages. |
| For everything that runs here, Perl included, see Which technologies run here. And for error 500 in general: Error 500. |
|
Does the script still give 500? Open a ticket with the address, the file’s path and the log line. Open a support ticket |
RECOMMENDED PRODUCT Web hosting with cPanel Domain and SSL included, daily backups and the panel you already know. from R118.80/mo (3-year plan, with coupon) See plans |
- 0 Users Found This Useful











