CGI overview



Running a CGI script at DreamHost

To run, copy the script to a web-accessible directory (e.g., /home/username/ You don't have to put your CGI scripts in a cgi-bin directory, as CGI scripts can run from any directory within your domain on DreamHost. The server understands several file extensions (e.g., .pl), but if you see the source code of your script instead of the result of its execution, try using the generic extension .cgi.

If you get a "500 Internal Server Error", you may need to change the permissions of the file:

[server]$ chmod 755 script.cgi

Running a CGI script without a .cgi extension


<Files *>
  SetHandler cgi-script

Once you add this directive, all files within the directory will run as CGI scripts.

Examples of CGI Scripts



use strict;
use CGI;

my $q = CGI->new;
print $q->header();
print "Hello, world!";



print "Content-type: text/html"
print "Hello, world!"



require 'cgi'

cgi =
cgi.out{ 'Hello, world!' }

Shell Script


echo "Content-type: text/html"
echo "Hello, world!"



Troubleshooting CGI issues

View the following article for help with troubleshooting CGI issues:

See also

Did this article answer your questions?

Article last updated PST.