蟒蛇Windows 上的 XAMPP:如何? [英] Python & XAMPP on Windows: how to?
问题描述
我已经在我的 Win7x64 Xampp 和 Python 2.7 上安装了.
I have installed on my Win7x64 Xampp and Python 2.7.
现在我正在尝试获得 Python 语言的力量"……我该怎么做?
Now I'm trying to get the "power" of Python language... how can I do it?
我尝试过使用 mod_python 和 mod_wsgi,但我的 Python 版本不存在第一个,当我在安装 wsgi 后尝试启动 Apache 时出现错误
I've tried with mod_python and mod_wsgi but the first one does not exist for my version of Python, and when I try to start Apache after installing wsgi it gives me an error
< Directory "x93C:/wsgi_appx94"> path is invalid
我在 < 之间添加了一个空格.和 'directory' 使字符串在此处可见.
I added a space between < and 'directory' to make the string visible here.
所以...有人知道是否有安装这些功能的小教程吗?
So... Anyone knows if there is a little tutorial to install these features?
或者有没有好心人一步步解释我该怎么办?
Or is anyone is kind enough to explain me step by step what shall I do?
如果我不能向我解释,谢谢和抱歉.
Thanks and sorry if i'm not so able to explain me.
如果你需要什么,请告诉我.
If you need something, please ask me.
推荐答案
是的,你是对的,mod_python 不适用于 Python 2.7.所以 mod_wsgi 是你的最佳选择.
Yes you are right, mod_python won't work with Python 2.7. So mod_wsgi is the best option for you.
我会推荐 AMPPS,因为 python 环境默认启用 mod_python 和 python 2.5.AMPPS 网站
I would recommend AMPPS as python environment is by default enabled with mod_python and python 2.5. AMPPS Website
如果你还想继续,
在httpd.conf中加入这一行
Add this line in httpd.conf
LoadModule wsgi_module modules/mod_wsgi.so
在 httpd.conf 中取消注释
Uncomment the line in httpd.conf
Include conf/extra/httpd-vhosts.conf
打开vhost文件httpd-vhosts.conf并添加
Open vhost file httpd-vhosts.conf and add
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 中添加以下行
Add the following lines in 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 中对我有用.:)
Note : Don't make the test directory in htdocs. Because I haven't tried that yet. These steps worked for me in AMPPS. :)
然后在您喜欢的浏览器中访问 127.0.0.1/wsgi.您将看到 Hello World!.
Then access 127.0.0.1/wsgi in your favorite browser. You will see Hello World!.
如果您没有看到,请按照 QuickConfigurationGuide
If you don't see, follow QuickConfigurationGuide
或
您可以在 httpd.conf 中添加这些行
You can add these lines in 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>
这篇关于蟒蛇Windows 上的 XAMPP:如何?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!