这是我的.ini文件来运行uwsgi“pyApp.py”
[uwsgi] plugins = cgi socket = 127.0.0.1:9010 cgi = /=/usr/share/test/ cgi-allowed-ext = .py cgi-helper = .py=python
我在位置/usr/share/test/firstapp.py有一个“firstapp.py”文件它的内容是
#!/usr/bin/python print "Content-type: text/html\n\n" print "<html><body><h1>It works! Cool!!</h1></body></html>"
我正在用命令运行uwsgi的实例
uwsgi --http :9011 --http-modifier1 9 --ini pyApp.ini --master
我已经使用nginxconfiguration了几个虚拟主机。 而其中的一个必须指向/ usr / share / test /目录,当其中有“/ cgi-bin /”的url时。
nginxconfiguration是 – [也是唯一默认的]
server { listen 80 default_server; listen [::]:80 default_server ipv6only=on; root /var/www/pythonsite.com/html; index index.html index.htm; server_name pythonsite.com www.pythonsite.com; location / { try_files $uri $uri/ =404; } location /cgi-bin { include uwsgi_params; uwsgi_modifier1 9; uwsgi_pass 127.0.0.1:9010; } }
但是,当我尝试从浏览器通过URL访问“CGI”脚本
http://pythonsite.com/cgi-bin/firstapp.py
默认的url“pythonsite.com”似乎工作正常,但上面的“cgi-bin”URl似乎缺less一些东西。 我得到“502坏门户”。 我错过了什么。 为了使用Python脚本这种方式?
编辑:
另外,每当我在浏览器中请求URL http://pythonsite.com/cgi-bin/firstapp.py “时,uwsgi服务器实例上就会有一个日志
-- unavailable modifier requested: 9 --
编辑2:
在uwsgi日志我得到“无效的请求块大小:21573(最大4096)…跳过”为127.0..0.1:9010和连接重置浏览器页面
和“127.0.0.1:9011/”; 浏览器中出现“内部服务器错误”消息。 和uwsgi日志为"--- no python application found, check your startup logs for errors ---"
什么可能会出错? :|
CGI插件是否安装?
在uWSGI上运行CGI脚本
使用相同的configuration我可以重现错误,但是在安装CGI插件并使用/ tmp / uwsgi中的新二进制文件运行后,它将起作用:
curl http://uwsgi.it/install | bash -s cgi /tmp/uwsgi