大网数据广告活动
服务器运维问答

Running a python script on Nginx

· 52CE 我爱测

This question might sound a bit odd to the people hanging out here, but i am just trying to start learning server side programming Is it possible to run a python script directly in a Nginx server just by replacing root /usr/share…

问题原文

原帖链接 · srj0408 · CC BY-SA 3.0

This question might sound a bit odd to the people hanging out here, but i am just trying to start learning server side programming

Is it possible to run a python script directly in a Nginx server just by replacing

root /usr/share/nginx/html;
    index index.py; // instead of index.html index.htm 

I tried running the same, but no result. All i was trying is to get the post data of the request and print it on a web-page.

I have searched a bit on google and found how to run python script using uWSGI and Ngnix - link. I will defiantly go ahead and try this one, but it would be really nice, if some one can clear my doubt.

Thanks in advance.

已采纳解答

原帖链接 · giomanda · CC BY-SA 3.0

Noap, you cant run python scripts by replacing the index.html. Doing so, you are serving a python file to the client/web-browser where he doesnt know how to interpret it.

As you correctly stated, you may use uWSGI in order to execute python scripts on your server.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-05-20)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。