如何在 Wampserver 上设置和运行 Python?
谁能帮我设置 Python 在 Wampserver 上运行。根据我到目前为止所读到的内容,您需要结合使用 Wampser、Python、mod_pyhton 以及对 Apache http.conf 文件的调整。我已经尝试过,但我相信在版本方面我遇到了冲突。有谁知道可以工作的版本组合,以便我可以使用我的 wampserver 进行一些本地 python 开发?下载链接将不胜感激。
我当前的配置: Wampserver 2.0c => Apache版本:2.2.8,PHP版本:5.2.6,MySQL版本:5.0.51b
Can anyone help me to set up Python to run on Wampserver. From what I've read so far you would need to use a combination of Wampser, Python, mod_pyhton, and adjustment to the Apache http.conf file. I've tried it but i belive i am having conflict when it comes to versions. Does anyone know of a cobination of versions that can work so that i can do some local python development using my wampserver? Links to the download would be greatly appreciated.
My current config:
Wampserver 2.0c =>
Apache Version : 2.2.8 , PHP Version : 5.2.6 , MySQL Version : 5.0.51b
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
不要使用mod_python;它并没有像大多数人认为的那样做。请改用
mod_wsgi
。Do not use
mod_python
; it does not do what most people think it does. Usemod_wsgi
instead.如何使用 web.py (下载)还是django?
他们有自己的Web服务器,您还可以使用MySQLdb扩展连接MySQL服务器。
How about using web.py (download) or django?
They have their own web server, and you can also connect MySQL server with MySQLdb extension.
认识到该帖子询问了 mod_python,我发布以下内容,以防使用 CGI 可以接受。
我已经有一段时间没有让它工作了,但我得到了用 Python 编写的 CGI 脚本,可以在 Wampserver 下运行,只需做一些简单的事情(尽管当时看起来并不简单):
#!python
(或 python 可执行文件的完整路径)。虽然 Windows 下的 Python 程序通常不需要第一行,但 Apache 似乎需要这一行,以便它知道该程序是 Python。应该可以做到这一点。我仔细检查了 httpd.conf 文件,没有看到任何使 Python 工作的更改。 (这假设您已经让 CGI 正常工作。)
下面的简单脚本应该告诉您是否可以正常工作:
Recognising that the post asks about mod_python, I'm posting the following, in case using CGI is acceptable.
It has been a while since I got this to work, but I got CGI scripts written with Python to run under Wampserver with a couple simple things (although it didn't seem simple at the time):
#!python
(or the full path to the python executable). While the first line isn't usually necessary for Python programs under Windows, Apache seems to need this so it knows the program is Python.That should do it. I double checked my httpd.conf file and don't see any changes to get Python working. (This assumes you already have CGI working otherwise.)
The following simple script should tell you if you have things working:
以下是一些说明:http://www.imladris.com/Scripts/PythonForWindows.html
Here are some instructions here: http://www.imladris.com/Scripts/PythonForWindows.html
我的 WSGI 设置是在 WAMP 服务器 2.5、32 位上进行的(Apache 2.4.9 32位)
Win32 上的 PythonWin 2.7.8(默认,2014 年 7 月 2 日,19:50:44)[MSC v.1500 32 位(Intel)] 继续下一步。
配置 Apache
从 http://www.apachelounge.com/viewtopic.php 下载 32 位 mod_wsgi.so ?t=5143 并将其放置为
c:\wamp\bin\apache\apache2.4.9\modules\mod_wsgi.so
在主C:\wamp\bin\apache\apache2.4.9\conf\httpd.conf中加载wsgi模块到apache:
获取webpy
测试一下:
将应用程序创建为 c:\wamp\www\API\code.py
结果
重新启动 apache Web 服务器并检查 http://localhost/API
My WSGI setup made on WAMP server 2.5, 32bits (Apache 2.4.9 32bits) with
PythonWin 2.7.8 (default, Jul 2 2014, 19:50:44) [MSC v.1500 32 bit (Intel)] on win32 went on the next way.
Config Apache
Download 32bits mod_wsgi.so from http://www.apachelounge.com/viewtopic.php?t=5143 and place it as
c:\wamp\bin\apache\apache2.4.9\modules\mod_wsgi.so
Load the wsgi module to apache in the main C:\wamp\bin\apache\apache2.4.9\conf\httpd.conf:
Get webpy
Test it:
Create your application as c:\wamp\www\API\code.py
Result
Restart your apache webserver and check http://localhost/API
第 1 步:下载 Python 安装程序
https://www.python.org/downloads/release/python-350/< /a>
第 2 步:安装 Python
第 3 步:下载 wampserver
https://sourceforge.net/projects/wampserver/files/WampServer %202/Wampserver%202.4/
步骤 4:在记事本中打开 httpd.conf 文件,从该位置 C:\wamp64\bin\apache\apache2.4.23\conf\httpd.conf
步骤 5:找到 CTRL+F httpd.conf 中的“目录”,并在安装 wamp 服务器的文档和目录中设置 wamp 安装位置,请使用正斜杠 < strong>"/" 不是反词 "\"
A.(DocumentRoot "C:/wamp64/www")
B.(目录 "C :/wamp64/www"> )
并替换 Directory "C:/wamp64/www"> 中的这两行;
删除:-
选项索引 FollowSymLinks
添加:-
AddHandler cgi-script .cgi .py
选项索引 FollowSymLinks ExecCGI
C. 设置 cgi-bin 位置
(目录“C:” /wamp64/cgi-bin”
允许覆盖无
选项无...)
第六步:重新启动wamp的所有服务。
步骤7:制作python程序,但首先添加这些行
#!D:/paythoninstalled/python.exe//设置python的安装路径
步骤8:保存程序.py扩展。
第9步:在浏览器上运行
Step 1: Download the Python Setup
https://www.python.org/downloads/release/python-350/
Step 2: Install Python
Step 3: Download the wampserver
https://sourceforge.net/projects/wampserver/files/WampServer%202/Wampserver%202.4/
Step 4: Open httpd.conf file in notepad,from that location C:\wamp64\bin\apache\apache2.4.23\conf\httpd.conf
Step 5: find CTRL+F "Directory" in httpd.conf and set wamp install location in Document and Directory , where your wamp server is installed , kindly use forward slash "/" not backword "\"
A.(DocumentRoot "C:/wamp64/www")
B.(Directory "C:/wamp64/www"> )
and Replace these two line inside Directory "C:/wamp64/www">
Remove:-
Options Indexes FollowSymLinks
Add:-
AddHandler cgi-script .cgi .py
Options Indexes FollowSymLinks ExecCGI
C. Set cgi-bin location
(Directory "C:/wamp64/cgi-bin"
AllowOverride None
Options None...)
Step 6: Restart All Service of wamp.
Step 7: make python program but add these line at first
#!D:/paython installed/python.exe // set path where python is installed
Step 8: save program .py extension.
Step 9: run on browser using
Wampserver 没有 python/django 的插件,但 XAMPP 有。
这里有一个很好的教程:
http://jyotirmaya.blogspot.com/2008 /11/xampp-python-django.html
Wampserver doesn't have addon for python/django, but XAMPP does.
A good tutorial here:
http://jyotirmaya.blogspot.com/2008/11/xampp-python-django.html