将 PHP 替换为 Python 并使用 Apache
基本上我正在寻找一种方法来摆脱对 PHP 的依赖,并且我想切换到 Python。我很难找到一种方法来基本上让 python 成为替代品。我很熟悉 Django,但对于我必须做的大多数小事情来说,它不够快且不够脏。所以我想知道是否有一个 Apache 模块或一种方法来设置 mod_wsgi 来提供 *.py 文件,就像 mod_php 从服务器根目录提供 *.php 一样?
注意:我发现了 php 的各种 python 扩展,用于从 PHP 调用代码,但这并不能真正解决大括号问题。
Basically I'm looking for a way to get rid of my PHP dependence, and I would like to switch to Python. I'm having trouble finding a way to basically make python a drop in replacement. I'm familiar with Django but its just not quick and dirty enough for most small things I have to do. So I'm wondering if there is an Apache module or a way to setup mod_wsgi to serve up *.py files the same way mod_php serves up *.php from the server root?
Note: I have found the various python extensions to php for calling code from PHP but that doesn't really solve the curly brace hell.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
mod_wsgi 调用的文件是 Python 文件。此外,如果您将它们设置为守护进程模式,则更新 python 文件将重新启动守护进程。它非常光滑。
如果 Django 过度杀伤力,您可以查看的另一件事是 Werkzeug,它几乎只是服务器接口。然后,您可以使用 SqlAlchemy 添加数据库访问和/或使用 Jinja2。或不。
当人们想要 Django 作为组件时,这些组件几乎就是他们所使用的,并且我被告知,如果需要更多的维护工作(需要一些组装),它们会更强大。
The files that mod_wsgi calls are Python files. Additionally, if you set them up in daemon mode, updating the python file will restart the daemon. It's pretty slick.
Another thing you could look at if Django is overkill is Werkzeug, which is pretty much just the server interface. Then later you can add database access with SqlAlchemy and/or templating with Jinja2. Or not.
These pieces are pretty much what people use when they want Django as pieces, and I'm told that they're more powerful, if more work to maintain (some assembly required).
是的,您可以使用 mod_wsgi 来做到这一点,但如果您是开发 Python Web 应用程序的新手,那么这可能是一种痛苦的方法。无论哪种方式,请阅读以下文档:
http://code.google.com/p /modwsgi/wiki/ConfigurationGuidelines#The_Apache_Alias_Directive
您可以像使用 CGI 或 PHP 脚本一样使用 AddHander。
Yes you can do that with mod_wsgi, but if you are new to developing Python web applications it is a potentially painful way to go about it. Either way, read the documentation at:
http://code.google.com/p/modwsgi/wiki/ConfigurationGuidelines#The_Apache_Alias_Directive
You use AddHander just like you would with CGI or PHP scripts.
如果您使用过 php,那么您也熟悉 mod_php
,还有 mod_python ( http://www.modpython.org/ )但它的社区不活跃(有很多文章如何使用 mod_python 设置 django ( http://docs.djangoproject.com/en/dev/howto/deployment/modpython/ ) )
但最好使用 wsgi 和 uwsgi
if you worked with php also you are familiar to mod_php
also there is mod_python ( http://www.modpython.org/ ) but its not active community ( there is many article how set django with mod_python ( http://docs.djangoproject.com/en/dev/howto/deployment/modpython/ ) )
but its better use wsgi and uwsgi