如何使用 WPHP 和 Python Paste

如何使用 WPHP 和 Python Paste

有人向我建议回答对我的问题如何使用 Python 的 CGIHTTPRequestHandler 作为 PHP 的开发服务器我尝试一下WPHP。

我试过了:

import wphp

my_php_app = wphp.PHPApp('/path/to/php-files/')

from paste import httpserver

httpserver.serve(my_php_app)

但无论我在浏览器中请求什么,我都会得到:

Exception happened during processing of request from ('127.0.0.1', 49397)
Traceback (most recent call last):
  File "/Library/Python/2.6/site-packages/Paste-1.7.4-py2.6.egg/paste/httpserver.py", line 1068, in process_request_in_thread
    self.finish_request(request, client_address)
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/SocketServer.py", line 320, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/SocketServer.py", line 615, in __init__
    self.handle()
  File "/Library/Python/2.6/site-packages/Paste-1.7.4-py2.6.egg/paste/httpserver.py", line 442, in handle
    BaseHTTPRequestHandler.handle(self)
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/BaseHTTPServer.py", line 329, in handle
    self.handle_one_request()
  File "/Library/Python/2.6/site-packages/Paste-1.7.4-py2.6.egg/paste/httpserver.py", line 437, in handle_one_request
    self.wsgi_execute()
  File "/Library/Python/2.6/site-packages/Paste-1.7.4-py2.6.egg/paste/httpserver.py", line 287, in wsgi_execute
    self.wsgi_start_response)
  File "/Library/Python/2.6/site-packages/wphp-0.1dev_r0-py2.6.egg/wphp/__init__.py", line 101, in __call__
    self.create_child()
  File "/Library/Python/2.6/site-packages/wphp-0.1dev_r0-py2.6.egg/wphp/__init__.py", line 184, in create_child
    self.spawn_php(self.fcgi_port)
  File "/Library/Python/2.6/site-packages/wphp-0.1dev_r0-py2.6.egg/wphp/__init__.py", line 207, in spawn_php
    proc = subprocess.Popen(cmd, env=env)
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py", line 595, in __init__
    errread, errwrite)
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py", line 1106, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

我应该如何使用WPHP?

相关内容