CGI help

From XMission Wiki
Jump to: navigation, search


Common Gateway Interface (CGI) services are typically scripts or programs that can be executed in conjunction with web pages. They are often used to process data entered by a visitor.

While HTML is a static language that mainly controls page layout, CGI (Common Gateway Interface) opens up many possibilities for dynamic web pages. XMission encourages our subscribers to explore what CGI can do for them.

Naming & Placement

CGI on XMission requires no interaction from administration. You can set up your own CGI scripts in your public_html directory simply by naming them with a filename ending in ".cgi". There is no need to put your scripts in a cgi-bin directory. (This is also the same with ".php" and ".php3".)


The file should be set to allow the web server execute permissions. Assuming the group on the file is "www", issuing the command "chmod g+x filename.cgi" (using your XMission shell account) would give the web server permission to execute the file.

SSI (Server Side Includes)

If you wish to include your script as a part of an HTML file, you will want to use Server Side Includes (SSI) with the Apache web server. The syntax is very simple. You simply need to give your file the ".shtml" extension instead of just ".html" and use the following tag within the file where you'd like to include the script: "".

WWW Services

WWW services can be invoked by using a URL such as "", where "servicename" is the name of the service you're invoking.


This is a powerful WWW-to-email gateway that can be configured for your specific needs. By default, you have a simple cgiemail form in your public_html directory. It comes in two parts: mail.html and mail.txt. Refer to our [cgi-email cgiemail help page] for details.


This is a debugging aid for CGI script writers. It shows the data delivered by a form using the POST method.


This is a debugging aid for CGI script writers. It shows the data delivered by an ISINDEX query.


This is a debugging aid for CGI script writers. It shows the entire environment available to the CGI script. This is handy for examining the default command search path, for instance.


This is a debugging aid for CGI script writers. It shows CGI related information (i.e., command line arguments and related environment variables).

Perl Modules

Our webhosting servers have a limited selection of Perl modules installed by default. We are happy to consider installing modules server-wide upon request, but only for versions considered to be stable by the Debian or Ubuntu package repositories. If you have code that needs a later version of code than we have, or if you need code that's not normally packaged, consider using CPAN.


You can maintain your own CPAN repository, start with this link: Once you have your local CPAN repository setup, you can type 'cpan' at a shell on and install whatever modules you need ('install DBIx::Class', for example). To utilize your local repository in your CGI scripts, add the following at the top:

 use lib "$ENV{HOME}/perl/lib"; # or whatever the path to your local repository is

We'd also recommend you add this use line:

 use CGI::Carp qw(fatalsToBrowser); 

This allows for any error messages that may result for module discrepancies to be printed to the browser instead of the servers error.log (which you don't have access to unless you've asked us to redirect it somewhere for you).