为什么LAMP托管避免CGI的Python? [英] Why avoid CGI for Python with LAMP hosting?
问题描述
我一直在使用PHP多年。最近我已经遇到无数的论坛帖子,指出 PHP已经过时,现代编程语言更容易,更安全,等等等等。
I have been using PHP for years. Lately I've come across numerous forum posts stating that PHP is outdated, that modern programming languages are easier, more secure, etc. etc.
所以,我决定为开始学习Python的。因为我已经习惯了使用PHP,我刚开始建立网页通过上传一个.htaccess文件:
So, I decided to start learning Python. Since I'm used to using PHP, I just started building pages by uploading an .htaccess file with:
addtype text/html py
addhandler cgi-script .py
然后,我的示例页面看起来像:
Then, my sample pages look like:
#!/usr/bin/python
print "content-type: text/html\n\n"
print "html tags, more stuff, etc."
这工作得很好。但是,我在一个帖子,说的 CGI不使用Python 最好的办法碰到一个注释。当然,它并没有提到什么的是的最好的方式。
This works fine. But, I came across a comment in a post that said that CGI isn't the best way to use Python. Of course, it didn't mention what is the best way.
为什么是它使用CGI不使用Python的最佳方法是什么?什么是另类?
有一些的完全别的办法设置一个简单的Python的网站?有一些完全不同的范例我应该看的的.htaccess和.py文件外?
Is there some totally other way to set up a simple Python site? Is there some completely different paradigm I should be looking at outside of .htaccess and .py files?
- <一个href="http://stackoverflow.com/questions/43709/pros-and-cons-of-different-approaches-to-web-programming-in-python">Pros不同的方法来网络编程在Python 和缺点
- <一个href="http://stackoverflow.com/questions/68986/whats-a-good-lightweight-python-mvc-framework">What’s一个良好的轻量级Python的MVC框架?(尤其是,<一个href="http://stackoverflow.com/questions/68986/whats-a-good-lightweight-python-mvc-framework/83263#83263">@Kevin Dangoor的回答)
- <一个href="http://stackoverflow.com/questions/596729/how-do-i-use-python-for-web-development-without-relying-on-a-framework">How我使用Python的Web开发不依赖于一个框架?
- <一个href="http://stackoverflow.com/questions/490210/python-web-framework-not-app-framework-or-cms-framework">Python Web框架 - 不应用程序框架或CMS框架
- Python的Web编程
- Pros and Cons of different approaches to web programming in Python
- What’s a good lightweight Python MVC framework? (esp., @Kevin Dangoor's answer)
- How do I use python for web development without relying on a framework?
- Python Web Framework - Not App Framework or CMS Framework
- Python web programming
推荐答案
经典CGI是不使用任何东西的最佳方式。凭借经典的CGI服务器为生成一个新的进程为每个请求
Classic CGI isn't the best way to use anything at all. With classic CGI server has to spawn a new process for every request.
至于Python中,你有几个选择:
As for Python, you have few alternatives:
-
的mod_wsgi
-
的mod_python
- FastCGI的
- 在独立Python的Web服务器(内置,的 CherryPy的, Tracd )
- 在非标准端口的独立Python的Web服务器和
的mod_proxy
在阿帕奇
mod_wsgi
mod_python
- fastcgi
- standalone Python web server (built-in, CherryPy, Tracd )
- standalone Python web server on non-standard port and
mod_proxy
in Apache
这篇关于为什么LAMP托管避免CGI的Python?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!