您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

Windows上的Python和XAMPP:如何?

Windows上的Python和XAMPP:如何?

是的,没错,mod_python无法在Python 2.7中使用。因此,mod_wsgi是您的最佳选择。@H_419_1@

我建议使用AMPPS,因为认情况下使用mod_python和python 2.5启用了python环境。AMPPS网站@H_419_1@

如果您仍然想继续,@H_419_1@

在httpd.conf中添加此行@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@

您可以在httpd.conf中添加这些行@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>
python 2022/1/1 18:27:24 有194人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶