通过fastCGI为nginx运行python

问题描述 投票:0回答:2

我希望通过 fcgi 运行独立的 python 脚本以与 nginx 一起使用,但我不知道从哪里开始生成进程。目前,我使用 nginx+fcgi 成功使用了 PHP,但我不确定是否/如何使用 python 执行同样的操作。关于从哪里开始有什么建议吗?

python nginx fastcgi
2个回答
30
投票

请参阅 FCGI 上的 python 文档部分。基本上,使用 Python,您可以在 fcgi 服务器之上使用 WSGI 接口,该接口与 Web 服务器(fcgi 客户端)通信。

请参阅 Python + FastCGI 了解一些 Python fcgi 服务器。

编辑:

这个 nginx wiki 页面准确解释了如何使用 fcgi 设置 Python 和 nginx。

此 wiki 页面描述了 nginx 的 uWSGI 模块,如果您并不真正需要使用 fcgi,那么这是将 Python 与 Web 服务器结合使用的自然方式。 这个博客条目看起来也像是关于 uWSGI 的好信息。

在生产中,Apache + mod_wsgi 或 Nginx + mod_wsgi? 也有一些关于 nginx mod_wsgi 的有用信息。


0
投票

使用fastcgiwrap。

在大多数发行版中可用。

apt install fastcgiwrap

有关配置,请参阅教程https://techexpert.tips/nginx/python-cgi-nginx/

© www.soinside.com 2019 - 2024. All rights reserved.