可移植的 Python - 让 Django 在 Apache 上工作?
我的服务器使用 Windows 7、Apache 2.28 和 Web Developer Server Suite。
所有文件都存储在 C:/www/vhosts 下
我从 http://www.portablepython.com/< 下载了 Portable Python 2.7 /a> 并将其安装到
C:/www/portablepython
我试图找到 mod_wsgi 让它与 2.7 一起工作 - 但我该怎么做呢?
我做这一切的原因是为了运行一个使用 Python 编码的基本站点,以使用 Django,就像 http://www.heart.co.uk/westmids/ 或 http://www.capitalfm.com/birmingham 即可。显然我的网站不会像他们的那么先进,但你明白了它的要点;我使用 Python/Django 作为新闻/文章网站的 CMS。
无论如何,这是我来自 C:/www/vhosts/localhost/testing.py 的代码:
#!/www/portablepython
print "Content-type: text/html"
print
print "<html><head>"
print ""
print "</head><body>"
print "Hello."
print "</body></html>"
这会生成 403 Forbidden 错误,即:
您无权访问此服务器上的 /testing.py。< /strong>
我关注了 http://code.google.com/p/modwsgi/wiki/InstallationOnWindows 但将 modwsgi-version-number-datedownload.so 重命名为 modwsgi.so 那么这是否导致了错误?
我需要做什么来防止这种情况再次发生?
我使用便携式版本进行测试,认为我可以删除该文件夹,并且如果需要的话我可以再次安装而不添加环境变量(我认为便携式版本会这样做,如果我错了请纠正我)?
如果我需要做出任何改变,该怎么办?我是否需要将它们设置为 httpd-vhosts.conf [我的虚拟主机] 或其他地方的虚拟主机?
任何帮助表示赞赏;随着情况的发展,我会发布更多内容。
I am using Windows 7, Apache 2.28 and Web Developer Server Suite for my server.
All files are stored under C:/www/vhosts
I downloaded Portable Python 2.7 from http://www.portablepython.com/ and have installed it to
C:/www/portablepython
I'm trying to find mod_wsgi to get it to work with 2.7 - but how can I do this?
The reason I'm doing all this is to get a basic site running that uses Python coding, with a view to using Django, in the same way that http://www.heart.co.uk/westmids/ or http://www.capitalfm.com/birmingham do. Obviously my site won't be as advanced as theirs, but you get the gist of it; I'm using Python/Django as a sort of CMS for a news/articles website.
In any case, here's my code from C:/www/vhosts/localhost/testing.py:
#!/www/portablepython
print "Content-type: text/html"
print
print "<html><head>"
print ""
print "</head><body>"
print "Hello."
print "</body></html>"
This generates a 403 Forbidden error, i.e.:
You don't have permission to access /testing.py on this server.
I followed http://code.google.com/p/modwsgi/wiki/InstallationOnWindows but renamed modwsgi-version-number-datedownload.so to modwsgi.so so did that cause the error?
What do I need to do to prevent this re-occurring?
I used the Portable version for testing purposes, thinking that I can just delete the folder, and I can install again if necessary without adding to environment variables (I think portable ones do this, correct me if I'm wrong)?
What, if any changes do I need to make? Do I need to make them to the vhosts in httpd-vhosts.conf [my virtual hosts] or elsewhere?
Any help is appreciated; I'll post more as this situation develops.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
C:/www/vhosts/localhost/testing.py 中的脚本是 CGI 脚本,而不是 WSGI 脚本。按照配置 mod_wsgi 的说明以及 hello world 的 WSGI 脚本文件应如下所示:
http ://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide
The script you have at C:/www/vhosts/localhost/testing.py is a CGI script and not a WSGI script. Follow the instructions for configuring mod_wsgi and what a WSGI script file for hello world should look like at:
http://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide
另外,您应该考虑使用来自 python.org 的 python 系统安装和 pip+distribute+virtualenv 来为不同站点保留包含的 python 环境。这将为您提供最大的便携性。
also, you should look into using a system install of python from python.org and pip+distribute+virtualenv to keep contained python environments for your different sites. This will give you maximum portability.
这是一个示例 - PortableWinPy - 如何让 Django 与 Apache 和
mod_wsgi< 一起使用/code>,以门户方式。
Here is a sample - PortableWinPy - how to get Django work with Apache and
mod_wsgi
, in portale way.