是的,没错,mod_python无法在Python 2.7中使用。因此,mod_wsgi是您的最佳选择。
我建议使用AMPPS,因为默认情况下使用mod_python和python
2.5启用了python环境。AMPPS网站
如果您仍然想继续,
在httpd.conf中添加此行
LoadModule wsgi_module modules/mod_wsgi.so
取消注释httpd.conf中的行
Include conf/extra/httpd-vhosts.conf
打开虚拟主机文件httpd-vhosts.conf并添加
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中添加以下行
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中对我有用。:)
然后在您喜欢的浏览器中访问127.0.0.1/wsgi。您将看到Hello World!。
如果看不到,请遵循QuickConfigurationGuide
要么
您可以在httpd.conf中添加这些行
<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>



