我在服务器上运行python应用程序。我尝试在我的应用程序中配置uwsgi服务器。
uwsgi.conf文件位置:/etv/init/uwsgi.conf
# file: /etc/init/uwsgi.conf
description "uWSGI starter"
start on (local-filesystems and runlevel [2345])
stop on runlevel [016]
respawn
# home - is the path to our virtualenv directory
# pythonpath - the path to our django application
# module - the wsgi handler python script
exec /home/testuser/virtual_environments/django-new/bin/uwsgi \
--uid root \
--home /home/testuser/virtual_environments/django-new \
--pythonpath /home/testuser/django \
--socket /tmp/uwsgi.sock \
--chmod-socket \
--module wsgi \
--logdate \
--optimize 2 \
--processes 2 \
--master \
--logto /var/log/uwsgi.log
我创建了.ini文件。
/etc/uwsgi/app-available/uwsgi.ini
[uwsgi]
home = /home/testuser/virtual_environments/django-new
pythonpath = /home/testuser/django
socket = /tmp/uwsgi1.sock
module = wsgi
optimize = 2
processes = 2
nginx配置:
的/ etc / nginx的/位点/有默认
upstream uwsgicluster {
#server unix:/tmp/uwsgi.sock;
server unix:///tmp/uwsgi1.sock;
}
server {
location / {
uwsgi_pass uwsgicluster;
#uwsgi_pass unix:/run/uwsgi/app/scisphere/socket;
#proxy_pass http://uwsgicluster;
include /etc/nginx/uwsgi_params;
}
location /static {
root /home/testuser/django/main;
}
location /media {
root /home/testuser/django;
}
}
我尝试启动服务器:
sudo service uwsgi start
我收到了502 Bad Gateway错误。以及如何在uwsgi.conf中配置uwsgi.ini文件
请任何人帮助我。
谢谢& advancd
答案 0 :(得分:0)
在include uwsgi_params;
下方添加uwsgi_pass uwsgicluster;
。