栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

Windows上的Python和XAMPP:如何?

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Windows上的Python和XAMPP:如何?

是的,没错,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>


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/648951.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号