L
Lad
How can I set up Apache web server to use Python for CGI processing( for file *.py).
Thanks for help
Lad
Thanks for help
Lad
Lad said:How can I set up Apache web server to use Python for CGI processing( for
file *.py). Thanks for help
How can I set up Apache web server to use Python for CGI processing( for file *.py).
Thanks for help
Lad
Jeffrey Froman said:A simple method would be to include the line:
AddHandler cgi-script .py
in your httpd.conf. This should work fine so long as your .py files start
with a proper invocation of the python interpreter (i.e.,
#!/usr/bin/python). You might also want to look at mod_python
(http://www.modpython.org/).
Jeffrey
[Tue Aug 10 08:51:32 2004] [error] [client 127.0.0.1] (2)No such file
or directory: script not found or unable to stat: c:/program
files/apache group/apache/cgi-bintest.py
The name of script is test.py and is in cgi-bin (Apache subdirectory).
BTW, how can I set up a different directory for cgi scripts? For
example I would like to have all my scripts in
C:\Scripts\MyScripts
Peter van Kampen said:[Tue Aug 10 08:51:32 2004] [error] [client 127.0.0.1] (2)No such file
or directory: script not found or unable to stat: c:/program
files/apache group/apache/cgi-bintest.py
The name of script is test.py and is in cgi-bin (Apache subdirectory).
In my experience cgi-bin is rarely just a subdir of apache's www-root. The
name cgi-bin is in itself not some magical name that 'turns CGI on'. You
have to configure it on your httpd.conf. Here's a relevant bit of mine:
#
# ScriptAlias: This controls which directories contain server scripts.
# ScriptAliases are essentially the same as Aliases, except that
# documents in the realname directory are treated as applications and
# run by the server when requested rather than as documents sent to the client.
# The same rules about trailing "/" apply to ScriptAlias directives as to
# Alias.
#
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
#
# "/usr/lib/cgi-bin" could be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#
<Directory /usr/lib/cgi-bin/>
AllowOverride None
Options ExecCGI
Order allow,deny
Allow from all
</Directory>
Also just to be sure the first line of test.py should be sth like this on
windows:
#! c:\path\to\python.exe
BTW, how can I set up a different directory for cgi scripts? For
example I would like to have all my scripts in
C:\Scripts\MyScripts
This is probably clear by now...
Hth,
PterK
Thanks Peter for help. Now I can run cgi scripts in default
c:/program files/apache group/apache/cgi-bin/
directory.
The problem was that there was not last "/"
But how can I forced the Apache to allowed to run scripts in a
different directory for example C:\Test\MyScripts\
Peter van Kampen said:I would guess you have something like the above in your httpd.conf
ScriptAlias /cgi-bin/ c:/program files/apache group/apache/cgi-bin/
<Directory c:/program files/apache group/apache/cgi-bin/>
AllowOverride None
Options ExecCGI
Order allow,deny
Allow from all
</Directory>
Simply replace c:/program files/apache group/apache/cgi-bin/ with
C:\Test\MyScripts
Hth,
PterK
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.