如何通过nginx运行python脚本?

Sta*_*cer 7 nginx

nginx 能够运行 php 脚本来生成供其服务的内容。

如何让 nginx 执行任意程序(例如 python 脚本)并提供输出?

小智 0

全栈Python

https://www.fullstackpython.com/nginx.html

或者:

Nginx Python 模块

该模块允许在配置阶段和运行时在 nginx 中使用 Python: https:
//github.com/arut/nginx-python-module

使用模块配置 nginx:

# static module
$ ./configure --add-module=/path/to/nginx-python-module

# dynamic module
$ ./configure --add-dynamic-module=/path/to/nginx-python-module

# sync-only version (no blocking operations substitution)
$ ./configure --add-module=/path/to/nginx-python-module
              --with-cc-opt=-DNGX_PYTHON_SYNC=1

# a specific Python installation can be used by exporting
# the path to python-config prior to configuring
$ export PYTHON_CONFIG=/path/to/python-config
Run Code Online (Sandbox Code Playgroud)