是的,没错,mod_python无法在Python 2.7中使用。因此,mod_wsgi是您的最佳选择。@H_419_1@
我建议使用AMPPS,因为默认情况下使用mod_python和python 2.5启用了python环境。AMPPS网站@H_419_1@
如果您仍然想继续,@H_419_1@
LoadModule wsgi_module modules/mod_wsgi.so
取消注释httpd.conf中的行@H_419_1@
Include conf/extra/httpd-vhosts.conf
打开虚拟主机文件httpd-vhosts.conf并添加@H_419_1@
NameVirtualHost 127.0.0.1:80
<VirtualHost 127.0.0.1:80>
<Directory "path/to/directory/in/which/wsgi_test.wsgi/is/present">
Options FollowSymLinks Indexes
AllowOverride All
Order deny,allow
allow from All
</Directory>
ServerName 127.0.0.1
ServerAlias 127.0.0.1
WSGIScriptAlias /wsgi "path/to/wsgi_test.wsgi"
DocumentRoot "path/to/htdocs"
ErrorLog "path/to/log.err"
CustomLog "path/to/log.log" combined
</VirtualHost>
在wsgi_test.wsgi中添加以下行@H_419_1@
def application(environ, start_response):
status = '200 OK'
output = 'Hello World!'
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]
注意:不要在htdocs中创建测试目录。因为我还没有尝试过。这些步骤在AMPPS中对我有用。:)@H_419_1@
然后在您喜欢的浏览器中访问127.0.0.1/wsgi。您将看到Hello World!。@H_419_1@
如果看不到,请遵循QuickConfigurationGuide@H_419_1@
要么@H_419_1@
<IfModule wsgi_module>
<Directory path/to/directory>
Options FollowSymLinks Indexes
AllowOverride All
Order deny,allow
allow from All
</Directory>
WSGIScriptAlias /wsgi path/to/wsgi_test.wsgi
</IfModule>