General CGI FAQ

Frequently asked questions about installing and troubleshooting CGI scripts.

Q1: I get a 500 Internal Server Error.

Short Answer:

Check permissions, Perl path, and line endings.

Long Answer:

The dreaded 500 error is usually caused by one of these problems:

Q2: What permissions do I need for CGI scripts?

Short Answer:

Scripts: 755, Data files: 666, Directories: 755

Long Answer:

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

Q3: How do I upload CGI scripts?

Short Answer:

Use FTP in ASCII mode.

Long Answer:

Follow these steps to upload CGI scripts correctly:

  1. Use an FTP program (WS_FTP, CuteFTP, FileZilla, etc.)
  2. Set transfer mode to ASCII (not binary or auto)
  3. Upload to your cgi-bin directory (or wherever your host allows CGI scripts)
  4. Set permissions to 755 using your FTP client or shell access
  5. Test the script by visiting it in a web browser
Why ASCII mode?

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.

Q4: What's the correct path to Perl?

Short Answer:

Usually #!/usr/bin/perl

Long Answer:

The first line of every Perl CGI script must point to your Perl interpreter. Common paths:

Most Common
#!/usr/bin/perl
Also Common
#!/usr/local/bin/perl

Q5: I uploaded the script but it doesn't work.

Short Answer:

Re-upload in ASCII mode.

Long Answer:

If you uploaded in binary mode, the script has DOS line endings which Unix servers can't read. Solutions:

Solution 1: Re-upload

Delete the file, set FTP to ASCII mode, upload again.

Solution 2: dos2unix

If you have shell access: dos2unix script.cgi

Related FAQs

FormMail FAQ

Questions about FormMail script

Guestbook FAQ

Questions about Guestbook script

All FAQs

Browse all script FAQs