我在亚马逊linux上按照本教程https://uwsgi.readthedocs.org/en/latest/Upstart.html创建了一个uwsgi文件.虽然它似乎没有运行,因为Nginx只是说坏网关.如果我跑了
/etc/init/uwsgi.conf
description "uwsgi tiny instance"
start on runlevel [2345]
stop on runlevel [06]
exec /home/ec2-user/venv/bin/uwsgi --ini /home/ec2-user/uwsgi-prod_demo.ini
Run Code Online (Sandbox Code Playgroud)
如果我在shell中运行以下命令,则运行python应用程序.
/home/ec2-user/venv/bin/uwsgi --ini /home/ec2-user/uwsgi-prod_demo.ini
Run Code Online (Sandbox Code Playgroud)
uwsgi-prod_demo.ini
[uwsgi]
socket = :8080
chdir = /home/ec2-user/prod_demo
master = True
venv = /home/ec2-user/venv
callable = app
wsgi-file = /home/ec2-user/prod_demo/manage.py
enable-threads = True
https = =0,/home/ec2-user/xxx.com.au.pem,/home/ec2-user/newkey.pem,HIGH
Run Code Online (Sandbox Code Playgroud)
nginx.conf
user ec2-user;
worker_processes 1;
error_log /var/log/nginx/error.log;
#error_log /var/log/nginx/error.log notice;
#error_log /var/log/nginx/error.log info;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - …Run Code Online (Sandbox Code Playgroud) 环境: 在Windows 10主机上的Vagrant / Virtualbox中运行的Ubuntu 16.04(系统Python在2.7.12)
Python安装程序: 通过执行python -V验证了系统python,未激活virtualenv。还安装了Python 3.5,并且已经pipenv --three为该项目创建了virtualenv。在激活的virtualenv中进行python -V(pipenv shell激活)显示Python 3.5.2。
其他背景: 我正在开发Wagtail 2应用程序。Wagtail 2需要Django 2,而它当然需要Python3。我在这台机器上还有其他Django应用程序,这些应用程序是Django 1.11 / Python 2.7开发的,由Apache提供。我们将继续使用Django 2 / Python 3进行开发,并正在使用nginx / uWSGI来提供应用程序。
我经历了许多教程/许多迭代。所有的Vagrant端口映射都可以通过nginx提供媒体/静态文件并在Unix套接字上向Django应用传递请求到Django应用的设置很好地设置,但这会导致502 Gateway not found错误,因为uWSGI无法正确运行。因此,现在我只是在命令行中运行以下命令,以尝试运行uWSGI : uwsgi --ini /etc/uwsgi/sites/my_site.com.ini。该文件包含:
[uwsgi]
uid = www-data
gid = www-data
plugin = python35
# Django-related settings
# the base directory (full path)
chdir=/var/sites/my_site
# Django's wsgi file
wsgi-file = my_site.wsgi
# the virtualenv (full path)
virtualenv=/root/.local/share/virtualenvs/my_site-gmmiTMID
# process-related settings
# master …Run Code Online (Sandbox Code Playgroud)