Common Gateway Interface Setup
In order to have a site enabled with CGI support, a few things are required. You must have a valid account with commercial grade web hosting. Personal web sites do not qualify. Apache must be notified via .htaccess about your intentions. .htaccess must have world readable permissions for the web server to detect any server side web site settings. The CGI must be executable. Your user account must have ownership of any CGI executables in the cgi-bin directory.
Your directory for cgi-bin depends upon the name of your web site. For example, if your web site is www.surfthe.us, your cgi-bin is located in /var/www/hosts/www.surfthe.us/cgi-bin/. Files in this directory must be owned by you, and executable to run. They need not provide permissions for others (e.g., chmod o=) symlinks are ignored. You are encouraged to copy the CGI into your cgi-bin if processing your content requires an Action directive in .htaccess.
Before we start, a few conventions used in this section will be discussed. emphasis such as www.example.com require you to put your site name there. This setup assumes a very generic setup. Most people will want to edit and customize the configuration files after the essentials are up and running.
Some copy and paste operations in an ssh window will require you to hit CTRL+D to end the input after reaching EOF. If so, your clipboard and/or terminal emulator is to blame. You will need to edit the files after creating them. (eg, with vi, vim, zile, ed, emacs etc)
Eventually this will all be automated via a hosting controller. For the mean time, you'll need to login via ssh and perform these commands. (we suggest PuTTY)
This file allows apache to dynamically adjust to your configuration. Directives control what changes occur. Improperly configured .htaccess files can cause "500 - Internal Server Error" on your sites.
A more exhaustive reference for apache directives can be located on the apache foundation web site at http://www.apache.org/.
DirectoryIndex index.php index.php3 index.html index.txt
AddType application/x-httpd-php .php .php3
AddType application/x-httpd-php-source .phps
Action application/x-httpd-php /cgi-bin/php
ErrorDocument 404 /missing.html
This error will occur in at least these situations:
This error can be caused by an improperly configured .htaccess file, or a misbehaved CGI executable. Check the log files for additional information.
Log files for your web site are stored in a location unique to your site name. If for example, your web site was www.somesite.com, your log files are stored in /var/log/apache-ssl/somesite.com/ where www-error.log keeps any error messages.
user@server1:/var/log/apache-ssl/example.com$ ls -oA
total 76
-rw-r--r-- 1 root 51517 Nov 8 16:24 www-combined.log
-rw-r--r-- 1 root 3471 Nov 8 00:47 www-error.log
-rw-r--r-- 1 root 14344 Nov 8 16:24 www-referer.log
Perl is located at /usr/bin/perl
Check the include_path, log_errors, and error_log values to start. Proper use of the log_errors and error_log will allow you to log errors to a log file, instead of in the browser where possibly sensitive information may be revealed.