PDA

View Full Version : Error message on my home apache server


sheila
01-10-2001, 02:58 AM
I've had an Apache server installed on my Win98 machine for a short time now. I only run it ocassionally. Anyhow, I finally decided I wanted to fix it so that I could run cgi scripts.

I went through the httpd.conf file and thought I set everything properly. Plus, I thought the docs said that the cgi module is installed by default with Apache.

I can't seem to get my cgi scripts to run, though. I've been trying to run a small python script that I put in my cgi-bin, and I've added Python to the path for my machine. (I checked at the DOS prompt, and typed "path" to make sure.)

So, when I enter the URL for this script,
http://127.0.0.1/cgi-bin/pytestscript.py

I get a 500 Internal Server error. And, when I view the error logs, it states:
"(2)No such file or directory: couldn't spawn child process: e:/apache/cgi-bin/pytestscript.py"

Does anyone have any ideas what may be wrong? Help?

<additional info>

Just to test out whether I could get cgi-scripts to run at all, I created a file list.bat with these contents:
dir
and when I enter
http://127.0.0.1/cgi-bin/list.bat

it gives a directory listing of the cgi-bin directory, so cgi scripts are working. I guess I'm just not invoking python properly? How would one do this on a Windows/DOS system?

</additional info>
[This message has been edited by sheila (edited 01-10-01@02:11 am)]

Arthur
01-10-2001, 06:23 AM
Here's what I did to get it running (Windows 2000, Apache, Activestate Python 2.0):
In httpd.conf add the line - AddHandler cgi-script .py
and these lines -
SetEnv pythonpath=d:\Python20;
SetEnv PYTHONUNBUFFERED 1

First line of Python script;
#!d:/python20/python[nbsp][nbsp](or #!/python20/python)

--
Arthur

sheila
01-10-2001, 05:46 PM
Arthur,

Thanks for the reply. I tried adapting your directions to my situation, I tried both this:

Add these lines to httpd.conf:
SetEnv pythonpath=E:\;
SetEnv PYTHONUNBUFFERED 1

and this line to top of the script file:
#!e:/python

which didn't work. I also tried putting this in the httpd.conf file:
SetEnv pythonpath=E:\python;
SetEnv PYTHONUNBUFFERED 1

and leaving the shebang-path at the top of the script file as-is, but I still got 500 internal server error when I tested it out.

HOWEVER, someone in the comp.lang.python newsgroup gave me the following advice, which worked beautifully:

1) Add the following line at the end of {Path of Apache}\conf\httpd.conf

ScriptInterpreterSource Registry

2) give your CGI scripts the extension .py (the Python installer should
have registered .py, .pyc, .pyo to be handled by python.exe), as in this
script:

file test.py in cgi-bin:
########################
#!/usr/bin/env python

print 'Content-type: text/html\n\nhello!'

I always add &quot;#!/usr/bin/env&quot; python as first line to my scripts, even
under Windows, so they can run unchanged under a Unix system (if python
is in the path on the Unix system). This procedure is the portable way,
so you don't have to fiddle with interpreter paths if you want to run
your scripts on another Windows machine or a Unix machine.

So, I'm a happy camper, now. Now I can test out my scripts (before putting them on my FQ site) on my home computer the real way, instead of running them in a DOS console window.

Thanks! Cheers! :D

Tibbits
01-11-2001, 02:19 PM
I installed nusphere from http://www.nusphere.com/ and everything worked first time.. it includes apache, perl, mysql, php etc.

sheila
01-11-2001, 08:08 PM
Looks interesting, but at $79 a pop, that's a bit rich for my blood. (I'm just a hobbyist/teacher. This isn't a business for me, or I'm sure I'd spend such money willingly.)

Tibbits
01-13-2001, 08:48 PM
YOu can dowload nusphere for free.. you only have to pay for the disks, manuals and support etc.