[Zope] Zope in Virtual Host on ISP
Chris Larson
clarson@changeling.com
Sun, 7 Feb 1999 01:33:49 -0600
I thought I'd just kinda restate my problem from the ground up.
Problem: Executing scripts through a Python other than the primary
install on my ISPs machine.
Conditions:
1. ISP has Python 1.4 installed at /usr/bin.
2. ISP has PyApache 2.25 compiled into Apache server for my domain
(Virtual Host).
3. I have installed Python 1.5.2b2 into my home directory.
(/home/c/change/local, with bin, lib, etc as it should be.
4. At command line, scripts execute correctly through my Python (I've set
path to /home/c/change/local/bin:/usr/bin, etcetera (My notation, not
literally "/etcetera" <grin>), so it finds the correct Python, executes
environment script and returns everything correctly.
5. When executed through browser (through the Apache server, that is), no
matter what I do, Python is either executed from /usr/bin or returns
Internal Server Error. (I've tried explicitly stating absolute path to
/home/c/change/local/bin/python, /usr/bin/env python, and for
confirmation that tthe script is working, /usr/bin/python.)
6. I've also tried installing python in a local/ hierarchy in my cgi-bin
and in my htdocs directories. (On a side note, if I could get one of
these to work, should I worry about any security issues? They're both
deleted now.)
7. I've tried directing python to execute through shell scripts as both
.sh and .cgi, setting such paths and other environment variables as I
thought prudent. The best I could accomplish was to get python to print
(generate to the browser) the text within the '---' below, bypassing the
Server Error by including an echo or two before calling python:
---
Content-type: text/html
</pre>
Importing sys
Done Importing sys
Importing os
---
I broke 'import sys,os' into two lines with print flags before and after
because with just that line, all I got was:
---
Content-type: text/html
</pre>
---
What I suspect this means is that the wrong python launched with the
right sys.path. (Translation: Right: 1.5.2b2 in /home/... Wrong: 1.4 in
/usr/...) If I add a 'print "Python %s" % sys.version' following sys
import, I get:
---
Importing sys
Done Importing sys
Python 1.4 (Feb 4 1997) [GCC 2.7.2.1]
Importing os
---
Summary: So, in a nutshell, I'm running in a 'virtual host' environment
Apache with the PyApache 2.25 module compiled in.
Apache does execute as my username.
Apache does not seem to allow me to bypass PyApache (?) _or_ it won't
consider (executable) paths not explicitly set somehow, even if executed
as username through a shell. No matter where I try to direct execution, I
end up with Python 1.4.
(Now, This'll sound wonderfully naive, I'm sure, but my scripts to date
have executed as #!sh, and the user shell variable used/set by Apache is
csh. From all I understand, this should be irrelevant, but I wanna be
sure. At this point, I'm rethinking everything I know about unix (linux)
(which ain't all _that_ much, but I _had_ thought it was more than I'm
realizing). Forgive if I seem to be rambling or missing the obvious. It's
difficult to convey the level of my frustration in ascii.
I've gone as far as setting 3 scripts calling each other before asking
for python. At the moment, I have the two mentioned in Jeff's email (And
thanks _again_ for all the help, Jeff!) running, with the added ...PYTHON
variables to save typing between experiments. The current versions are
listed below. Note that testcgi.cgi declares no #!
I'm probably leaving out all sortsa relevant stuff, and/or missing
something glaringly obvious, but hey, I'm tired, frustrated and kinda
loopy at this point <grin>.
Thanks
Chris Larson
------------------------
Text of launchpad.cgi
----
#!/bin/sh
PYTHONPATH=/home/c/change/local/lib/python1.5/test:/home/c/change/local/lib
/python1.5/plat-linux2:/home/c/change/local/lib/python1.5/lib-tk:/home/c/ch
ange/local/lib/python1.5/lib-dynload:/home/c/change/local/lib/python1.5/sit
e-packages
export PYTHONPATH
PATH=/home/c/change/local/bin:/usr/local/bin:/bin:/usr/bin
export PATH
ENVPYTHON=/usr/bin/env python
SYSPYTHON=/usr/bin/python
MYPYTHON=/home/c/change/local/bin/python
MYCGIBIN=/virtual/customer/changeling.com/cgi-bin
$MYPYTHON < $MYCGIBIN/testcgi.cgi
----
Text of testcgi.cgi
----
#!$MYPYTHON
print "Content-type: text/html"
print
print "<pre>"
print "Importing sys"
import sys
print "Done Importing sys"
print "Importing os"
import os
print "Done Importing os"
print "<strong>Python %s</strong>" % sys.version
for (x,y) in os.environ.items():
print "%s\t%s" % (x, y)
print "</pre>"
----