CGI Program Information

Web server CGI information

Reviewed by John Sopko 4/27/2012

The wwwx server runs on host wwwx.cs.unc.edu, a RedHat Linux machine that runs the Apache web server software.  The intent of the wwwx server is to allow graduate students, staff, and faculty to run cgi programs.  Undergraduate students taking classes SHOULD NOT use the wwwx server for their class work!  The students will be assigned a system to use by the instructor.  They will be given instructions on where they can run cgi programs.

CGI programs are programs that are executed by the web server to produce html output.  See Common Gateway Interface for information on CGI programs and their use.  You can run CGI programs out of your personal web space located in your …/public_html directory on the web server “wwwx.cs.unc.edu.”  Your CGI scripts will NOT run on the department www.cs.unc.edu web server.  See the departments web server faq for more info on the department web server.

Running your CGI progams

Your cgi programs must end with the “.cgi” extension.  Your program file must also have the Linux execute bits set; you can use the unix command “chmod 755 file_name” to make your program executable.  The program should reside in your …/public_html/cgi-bin directory.  This way you know where all your cgi programs reside.  CGI programs will run in any directory under your public_html directory or in /afs/cs.unc.edu/project space.
CGI programs are run on your behalf by the web server software.  The web server software runs with the unix user id “httpusr.”  As a result, once your program is running, if it has problems you cannot use the unix “kill” command to terminate your CGI process.

Debugging your CGI script

You should simulate data input to your CGI programs and run them standalone until you are confident the programs run without hanging.  A program that hangs can use up a large amount of CPU and memory on the wwwx server; this will affect all users logged into the wwwx server as well as the functioning of the server.

A good place to see if your CGI program is generating errors is the error_log file on the wwwx server.  You can access the error log file by logging into one of the public unix machines and examining the log file located at: /net/wwwx/var/log/httpd/error_log.  Use the following Linux command to view the log file as entries are appended:

tail -f /net/wwwx/var/log/httpd/error_log

The file that logs web access is located in the same place and is called access_log.  The error_log and access_log logs for the SSL https://wwwx.cs.unc.edu server are kept at a similar location:

/net/wwwx/var/log/httpd-ssl