Frequently asked questions about installing and troubleshooting CGI scripts.
chmod is a Unix command that changes file permissions, allowing users and groups to read, write, and/or execute files.
For CGI scripts, the web server's user ID (uid) must have permission to execute Perl scripts and read/write data files. Different chmod values are used for different purposes:
Perl scripts in the cgi-bin must be executable by the web server:
chmod 755 filename.pl
This allows everyone to read and execute the file, but only you can write to it.
Files that are automatically updated by scripts must be writable and readable by all:
chmod 777 filename.html
chmod 777 filename.txt
This allows everyone to read and write to your files.
If you don't have these, contact your system administrator.
| Number | Permission | Meaning |
|---|---|---|
4 | Read | Can view file contents |
2 | Write | Can modify file |
1 | Execute | Can run as program |
7 | rwx | Read + Write + Execute (4+2+1) |
5 | r-x | Read + Execute (4+1) |
The three digits represent: Owner | Group | Others
755 = Owner: rwx, Group: r-x, Others: r-x777 = Owner: rwx, Group: rwx, Others: rwx644 = Owner: rw-, Group: r--, Others: r--For detailed documentation, type at the Unix prompt:
man chmod
To run our CGI scripts, your server needs:
| Requirement | Details |
|---|---|
| Perl | Version 5.x or higher |
| CGI Support | Server must execute .pl or .cgi files |
| cgi-bin Directory | A directory configured for CGI execution |
| File Permissions | Ability to set 755 permissions |
Optional requirements depending on script:
Follow these steps to upload CGI scripts:
chmod 755 script.plDifferent file types require different permissions:
| File Type | Permission | Command |
|---|---|---|
| CGI Scripts (.pl, .cgi) | 755 | chmod 755 script.pl |
| Data Files | 666 | chmod 666 data.txt |
| Directories | 755 | chmod 755 dirname |
| Configuration Files | 644 | chmod 644 config.txt |
Permission numbers explained:
A 500 error usually indicates one of these problems:
#!/usr/bin/perl
perl -c script.pl
To find your server's Perl path:
which perl
Common Perl paths:
/usr/bin/perl - Most common/usr/local/bin/perl - Alternative location/bin/perl - Some systemsUpdate the first line of your script with the correct path:
#!/usr/bin/perl
Several ways to test your CGI scripts:
http://yourdomain.com/cgi-bin/script.pl
perl -c script.pl # Check syntax
perl script.pl # Run directly
use CGI::Carp qw(fatalsToBrowser);
fatalsToBrowser in production for security.
To enable Server Side Includes:
AddType text/html .html
AddHandler server-parsed .html
SSI syntax examples:
<!--#include virtual="/header.html"-->
<!--#exec cgi="/cgi-bin/script.pl"-->
<!--#echo var="DATE_LOCAL"-->
Yes! All scripts in this archive are free to modify. You may:
We only ask that you:
Several resources are available for help:
External resources:
To check for updates:
When updating:
Follow these security best practices: