Newbie: How do you enable python scripts in apache server?

Harry George hgg9140 at cola2.ca.boeing.com
Thu Jun 5 12:37:31 EDT 2003


Husam <husalwan at sci.kun.nl> writes:

> Hi,
> I have apache server running on redhat 9 and wants to run python scripts
> with it. I made a test script test.py and chmod to 777. The script sits
> in the root directory of the www-site. The script is this:
> 
> #!/usr/bin/python
> print "Content-Type: text/plain\n\n"
> print "Hello, Python!"
> 
> Although the script executes properly in konsole terminal, the problem
> is when I try to execute this script in netscape like this:
> http://localhost/test.py
> 
> the script is showing as plain text.
> 
> Can anybody points me to the right direction?
> 
> Thanks in advance
> 

You say "in the root directory".  Your symptoms suggest a
misunderstanding.  There are several "root" dirs in an apache
installation.  Typically:

  /usr/local/httpd/      root as in "ServerRoot"
     bin/
     conf/
       httpd.conf        where roots are defined
     htdocs/             root for docs
       mytest1.py        get via example.org/mytest1.py
     cgi-bin/            root for cgis
       mytest2.py        execute, and report out what it generates   

If you put your code at mytest1.py, the server thinks you just mean to
report the raw text (your symptom).  If you put it at mytest2.py, then
the server will know you mena it to be executed.

-- 
harry.g.george at boeing.com
6-6M31 Knowledge Management
Phone: (425) 294-8757




More information about the Python-list mailing list