eas*_*de5 5 python nginx uwsgi
我在Nginx上使用uwsgi来运行一些Python代码.
我想将uwsgi绑定到一个目录并使其呈现我从浏览器中的服务器调用的任何.py文件.我在想PHP,这里(/index.php执行该文件,/ login.php执行该文件).
这有可能吗?或者我只能在uwsgi中明确指定单个模块/ app /文件?
这是我的init语法:
/opt/uwsgi/uwsgi -s 127.0.0.1:9001 -M 4 -t 30 -A 4 -p 4 -d /var/log/uwsgi.log --pidfile /var/run/uwsgi.pid --pythonpath /srv/www
Run Code Online (Sandbox Code Playgroud)
我认为这将允许/srv/www
充当执行任何.py文件的文件夹.
这是我的nginx配置:
server {
listen 80;
server_name DONT_NEED_THIS;
access_log /srv/www/logs/access.log;
error_log /srv/www/logs/error.log;
location / {
root /srv/www;
# added lines
include uwsgi_params;
uwsgi_pass 127.0.0.1:9001;
}
Run Code Online (Sandbox Code Playgroud)
就目前而言,当我尝试调用web root(即www.site.com/)时,我得到一个:
wsgi application not found
Run Code Online (Sandbox Code Playgroud)
使用以下index.py文件:
import sys
import os
sys.path.append(os.path.abspath(os.path.dirname(__file__)))
def application(environ, start_response):
status = '200 OK'
output = 'Hello World!'
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
谢谢!