Frequently asked questions about installing and troubleshooting CGI scripts.
Check permissions, Perl path, and line endings.
The dreaded 500 error is usually caused by one of these problems:
CGI scripts must be executable. Set to 755:
chmod 755 scriptname.cgi
The first line of the script must point to your Perl interpreter. Common paths:
#!/usr/bin/perl (most common)#!/usr/local/bin/perl#!/bin/perlFind your Perl path with: which perl
Upload in ASCII mode, not binary. DOS line endings (CRLF) cause errors on Unix servers.
Check the server error log for details. Contact your hosting provider if you can't access logs.
Scripts: 755, Data files: 666, Directories: 755
Different files need different permissions:
| File Type | Permission | Command | Meaning |
|---|---|---|---|
| CGI Scripts | 755 | chmod 755 script.cgi |
Readable, writable, executable by owner; readable and executable by others |
| Data Files | 666 | chmod 666 data.txt |
Readable and writable by everyone |
| Directories | 755 | chmod 755 directory |
Accessible to everyone, writable by owner |
| HTML Files | 644 | chmod 644 page.html |
Readable by everyone, writable by owner |
Use FTP in ASCII mode.
Follow these steps to upload CGI scripts correctly:
ASCII mode converts line endings from DOS format (CRLF) to Unix format (LF). Binary mode keeps DOS line endings, which cause 500 errors on Unix servers.
Usually #!/usr/bin/perl
The first line of every Perl CGI script must point to your Perl interpreter. Common paths:
#!/usr/bin/perl
#!/usr/local/bin/perl
If you have shell access, run:
which perl
If you don't have shell access, ask your hosting provider.
Re-upload in ASCII mode.
If you uploaded in binary mode, the script has DOS line endings which Unix servers can't read. Solutions:
Delete the file, set FTP to ASCII mode, upload again.
If you have shell access: dos2unix script.cgi
Questions about FormMail script
Questions about Guestbook script
Browse all script FAQs