Support → Documentation → Stunnix Perl Web Server

# Environment variables exported to CGI and XCGI scripts

Stunnix Perl Web Server exports a set of environment variables for use in CGI and XCGI scripts, and in Server Parsed documents. In particular, majority of environment variables are the same as exported by Apache web server.

You can see what environment variables are exported and their values by running sample site shipped with Stunnix Perl Web Server just by executing `/sample-image/site/stunnixwebsr/startsite.pl` and following link to simple XCGI script.

## Environment variables common to Apache and Stunnix Perl Web Server

The following variables are exported, with their values for the sample run on Linux of XCGI script with parameter 'foo' set to value 'Test' (Stunnix Perl Web Server 'srvrun.pl' script was located in directory `/home/test/stunnix-web-server/stunnixwebsrv/` and was executed using system perl interpreter):

CGI_GATEWAY | CGI/1.1
DOCUMENT_NAME | sample-xcgi.xcgi
DOCUMENT_ROOT | /home/test/stunnix-web-server/www/root/
GATEWAY_INTERFACE | CGI/1.1
HTTP_COOKIE |
HTTP_USER_AGENT | Lynx/2.8.4
PATH_INFO |
QUERY_STRING | foo=Test
REMOTE_ADDR | 127.0.0.1
REMOTE_HOST | 127.0.0.1
REQUEST_METHOD | GET
REQUEST_URI | /sample-xcgi.xcgi?foo=Test
SCRIPT_DIR | /home/test/stunnix-web-server/www/root
SCRIPT_FILENAME | /home/test/stunnix-web-server/www/root/sample-xcgi.xcgi
SCRIPT_NAME | /sample-xcgi.xcgi
SERVER_NAME | 127.0.0.1
SERVER_PORT | 9000
SERVER_PROTOCOL | HTTP/1.1

The only variable that Apache would export but SPWS doesn't is PATH_TRANSLATED, but it's easy to compute it from value of PATH_INFO.

## Environment variables unique to Stunnix Perl Web Server

Here are exported environment variables with their values for the same sample run of XCGI script on Linux, with descriptions of the meaning of each variable.

Name | Value | Description
--- | --- | ---
PERL_INTERP_NAME | /usr/bin/perl | Commandline to execute Perl interpreter. If site is packed into single executable with Perl interpretrer embedded, the value of this variable will be name of .exe file with special additional commandline options. Use the value of this variable instead of $^X for execution of Perl scripts.
RUNNING_VIA_XCGI | 1 | This variable is set to 1 for scripts that being run using XCGI calling convention
SERVER_ROOT | /home/test/stunnix-web-server/stunnixwebsrv/ | Directory where srvrun.pl script is located. Useful for computing path to other files used in (x)CGI scripts
STUNNIXWS_STATEDIR | /home/test | Provided as platform abstraction service by 'startsite.pl' script. This is a directory where to store global user-specific settings and documents (independant of version number of your browser-based appliation).
STUNNIXWS_TMPSTATEDIR | /home/test/.stunnixws//Perl-Obfus-2.0-Standard-0/ | Provided as platform abstraction service by 'startsite.pl' script. This is a directory where most files specific to the current user, site id and current version number of site can be stored.

## Other environment variables

It's possible to request SPWS to temporarily export additional environment variables when documents or scripts are served/executed on a per-location basis too using Set Env directive in configuration file. It's very useful for passing various bits of configuration information like name of database to use or name of default CSS stylesheet.