home *** CD-ROM | disk | FTP | other *** search
- <TITLE>Installing your CGI script on a Unix system -- Python library reference</TITLE>
- Next: <A HREF="../t/testing_your_cgi_script" TYPE="Next">Testing your CGI script</A>
- Prev: <A HREF="../c/caring_about_security" TYPE="Prev">Caring about security</A>
- Up: <A HREF="../c/cgi" TYPE="Up">cgi</A>
- Top: <A HREF="../t/top" TYPE="Top">Top</A>
- <H2>10.1.6. Installing your CGI script on a Unix system</H2>
- Read the documentation for your HTTP server and check with your local
- system administrator to find the directory where CGI scripts should be
- installed; usually this is in a directory <CODE>cgi-bin</CODE> in the server tree.
- <P>
- Make sure that your script is readable and executable by ``others''; the
- Unix file mode should be 755 (use <CODE>chmod 755 filename</CODE>). Make sure
- that the first line of the script contains <CODE>#!</CODE> starting in column 1
- followed by the pathname of the Python interpreter, for instance:
- <P>
- <UL COMPACT><CODE> #!/usr/local/bin/python<P>
- </CODE></UL>
- Make sure the Python interpreter exists and is executable by ``others''.
- <P>
- Make sure that any files your script needs to read or write are
- readable or writable, respectively, by ``others'' -- their mode should
- be 644 for readable and 666 for writable. This is because, for
- security reasons, the HTTP server executes your script as user
- ``nobody'', without any special privileges. It can only read (write,
- execute) files that everybody can read (write, execute). The current
- directory at execution time is also different (it is usually the
- server's cgi-bin directory) and the set of environment variables is
- also different from what you get at login. in particular, don't count
- on the shell's search path for executables (<CODE>$PATH</CODE>) or the Python
- module search path (<CODE>$PYTHONPATH</CODE>) to be set to anything interesting.
- <P>
- If you need to load modules from a directory which is not on Python's
- default module search path, you can change the path in your script,
- before importing other modules, e.g.:
- <P>
- <UL COMPACT><CODE> import sys<P>
- sys.path.insert(0, "/usr/home/joe/lib/python")<P>
- sys.path.insert(0, "/usr/local/lib/python")<P>
- </CODE></UL>
- (This way, the directory inserted last will be searched first!)
- <P>
- Instructions for non-Unix systems will vary; check your HTTP server's
- documentation (it will usually have a section on CGI scripts).
- <P>
-