[Tutor] Python in Apache?
Israel Evans
israel@lith.com
Thu, 24 Jan 2002 21:43:25 -0800
Cool, Thanks...
I've got python located and have set up the Shebang line to point to python.
Right now I've got it set to #! % python which works to launch scripts when
I click on them even though they aren't in the PATH or PYTHONPATH. I've
also used #! c:/proj/Python22 which also works just launching the file by
clicking on it.
I'm not using any flavor of Unix unfortunatly, I'm using Win2000. This
leads me to step 4 and how I don't know how to chmod anything on a windows
machine. I can double click the file and it runs just fine.
The error I seem to be getting in the Apache Error log is that the child
process couldn't be launched.
I'm pretty much stuck though. I've been reading the docs, but I can't seem
to find anything more that I haven't done which is supposed to allow you to
launch cgi's.
Thanks though! The apache list seems less talkative than this one. Man I
love you guys! :)
~Israel~
-----Original Message-----
From: kirk Bailey [mailto:idiot1@netzero.net]
Sent: Thursday, January 24, 2002 8:39 PM
To: Israel Evans
Subject: Re: [Tutor] Python in Apache?
Sure thing.
1. ASSUMING a flavor of unix, locate python.
$ whereis python
python: /usr/local/bin/python /usr/local/man/man1/python.1.gz
/usr/ports/lang/python
$
The first one is the executable file we are intrested in.
2. Add the pouond-bang hack to the first line of your script:
#!/usr/local/python
#
import cgi, smtp, os, string, glob
#
localhost='tinylist.org'
#
pathtostuff='/www/www.tinylist.org/cgi-bin'
#
etc...
3. save the file. Exact details depend on the editor used. Make sure
it has the '.py' name extension in case your ggrandmother has to
maintain the thing 4 years from now and has no idea which file is a
python script.
4. Make sure the thing is executable. AT THE MINIMUM, turn on the X
bit:
$ chmod +x myscript.py
BETTER is to make it 755, so the world cannot write to it, but can run
it.
$ chmod 755 myscript.py
Hope this helps.
Israel Evans wrote:
>
> Has anyone here ever attempted to get Python cgi
> files to run in an apache server? I seem to be having
> trouble though everything looks right and I don't know
> whether it's python or apache that's causing me problems.
>
> The following is a bit long but I think it's thorough
> These are the things I have set up.
>
> This is my script alias in httpd.config which I think is
> set up correctly. The path I've set up is correct, but
> I'm new to the options so I may be off.
> ############################################
>
> ScriptAlias /cgi-bin/ "C:/Weblish/cgi-bin/"
>
> <Directory "C:/Weblish/cgi-bin/">
> AllowOverride None
> Options +ExecCGI
> Order allow,deny
> Allow from all
> </Directory>
>
> ############################################
>
> I don't have Perl on my machine, but I do have Python,
> which I like much better so I'm using that as the language
> for my cgi programs. My super simple introductory cgi is
> as follows. I've got Python in my Path and using this
> Shebang line I'm able to run python scripts just fine by
> clicking on them.
> ######################################
>
> #! % python
>
> header = "Content-type: text/html\n\n"
> content = "Hello, Baby."
>
> print header, content
>
> ######################################
>
> I access this cgi file by entering
> "http://localhost/cgi-bin/test.cgi"
> into my browser after having made sure that the Server
> is running.
>
> I get the following error message:
> ####################################
>
> Internal Server Error
>
> The server encountered an internal error or
> misconfiguration and was unable to complete your request.
>
> Please contact the server administrator, Israel@lith.com
> and inform them of the time the error occurred, and anything
> you might have done that may have caused the error.
>
> More information about this error may be available in the
> server error log.
>
> _____
>
> Apache/1.3.20 Server at ISREAL.lith.com Port 80
>
> ##########################################
>
> And when I look into the Error logs I find these tidbitsof information:
> #############################################
>
> [Thu Jan 24 08:08:42 2002] [error] [client 127.0.0.1]
> attempt to invoke directory as script: c:/weblish/cgi-bin
> [Thu Jan 24 08:11:28 2002] [error] [client 127.0.0.1]
> couldn't spawn child process: c:/weblish/cgi-bin/test.cgi
>
> #############################################
>
> _______________________________________________
> Tutor maillist - Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
--
-Respectfully,
-Kirk D Bailey
Consulting Loose Cannon
end
www.howlermonkey.net highprimate@howlermonkey.net
www.sacredelectron.org idiot1@netzero.net
www.tinylist.org grumpy@tinylist.org
----------------------------------------------------
Sign Up for NetZero Platinum Today
Only $9.95 per month!
http://my.netzero.net/s/signup?r=platinum&refcd=PT97