September 27, 2007
Setup Web.py and flup on Windows+Apache(WAMP)
- Web.py is installed by “Easy Install” as Python eggs.
- To install “Easy Install”(setuptools), download ez_setup.py, run it, setuptools egg for right Python version is installed automatically.
- Run “ez_setup.py web.py”, web.py is installed automatically.
- web.py implements WSGI. Need to install flup to provide WSGI interfaces for web.py and web server as CGI, FastCGI or SCGI.
- Config Apache to allow CGI on web directory. Most common problem is permission setting, but its fare easy on Windows.
- Problem exists with flup to run under such environment. Blow logs could be found in Apache err log
[Thu Sep 27 09:21:34 2007] [error] [client 127.0.0.1] File “D:\Python25\lib\site-packages\flup-1.0-py2.5.egg\flup\server\fcgi_base.py”, line 976, in _setupSocketr
[Thu Sep 27 09:21:34 2007] [error] [client 127.0.0.1] AttributeError: ‘module’ object has no attribute ‘fromfd’r
[Thu Sep 27 09:21:34 2007] [error] [client 127.0.0.1] Unhandled exception in thread started by r
[Thu Sep 27 09:21:34 2007] [error] [client 127.0.0.1] Error in sys.excepthook:r
Solved referencing to http://groups.google.com/group/webpy/browse_thread/thread/67a8cfa5fdb1882b/722acab404514de4
Modification to flup code and repack is needed.
Down load flup code (but by ez_setup).
Modify fcgi_base.py as:
def _setupSocket(self):
if self._bindAddress is None: # Run as a normal FastCGI?
isFCGI = True
#@ commented by charlie, ref: http://groups.google.com/group/webpy/browse_thread/thread/67a8cfa5fdb1882b/722acab404514de4
## sock = socket.fromfd(FCGI_LISTENSOCK_FILENO, socket.AF_INET,
## socket.SOCK_STREAM)
## try:
## sock.getpeername()
## except socket.error, e:
## if e[0] == errno.ENOTSOCK:
## # Not a socket, assume CGI context.
## isFCGI = False
## elif e[0] != errno.ENOTCONN:
## raise
isFCGI = False
# FastCGI/CGI discrimination is broken on Mac OS X.
Rebuild eggs for flup following the easy instructions, run “setup.py bdist_egg“.
Copy the new egg to site-packages directory.
My things done.
Filed by
charlie
at 5:06 pm under 