Django 我的nginx无法在Ubuntu 16.04上加载uwsgi
试图通过uwsgi和nginx在Ubuntu 16.04上运行django应用程序“mysite”,但当我启动uwsgi并检查浏览器时,它就挂起了 我在端口8002上将django上游套接字设置为,在8003上将nginx设置为侦听。在运行uwsgi之前,我在浏览器中访问192.168.0.17:8003,它抛出预期的502,因此我使用Django 我的nginx无法在Ubuntu 16.04上加载uwsgi,django,nginx,ubuntu-16.04,uwsgi,Django,Nginx,Ubuntu 16.04,Uwsgi,试图通过uwsgi和nginx在Ubuntu 16.04上运行django应用程序“mysite”,但当我启动uwsgi并检查浏览器时,它就挂起了 我在端口8002上将django上游套接字设置为,在8003上将nginx设置为侦听。在运行uwsgi之前,我在浏览器中访问192.168.0.17:8003,它抛出预期的502,因此我使用 uwsgi--http:8002--module mysite.wsgi--logto/tmp/uwsgi.log--master 当我在浏览器中重新加载时,8
uwsgi--http:8002--module mysite.wsgi--logto/tmp/uwsgi.log--master
当我在浏览器中重新加载时,8003现在挂起。我查看了/var/log/nginx/error.log
,但它是空的(access.log)
这是nginx配置,它被符号链接到/etc/nginx/sites enabled
:
sudo nano/etc/nginx/sites available/mysite\u nginx.conf
# mysite_nginx.conf
# the upstream component nginx needs to connect to
upstream django {
# server unix:///path/to/your/mysite/mysite.sock; # for a file socket
server 127.0.0.1:8002; # for a web port socket (we'll use this first)
}
# configuration of the server
server {
# the port your site will be served on
listen 8003;
# the domain name it will serve for
server_name 192.168.0.17; # substitute your machine's IP address or FQDN
charset utf-8;
# max upload size
client_max_body_size 75M; # adjust to taste
# Django media
location /media {
alias /home/myusername/uwsgi-tutorial/mysite/media; # your Django project's media files - amend as required
}
location /static {
alias /home/myusername/uwsgi-tutorial/mysite/static; # your Django project's static files - amend as required
}
# Finally, send all non-media requests to the Django server.
location / {
uwsgi_pass django;
include /home/myusername/uwsgi-tutorial/mysite/uwsgi_params; # the uwsgi_params file you installed
}
}
我知道Django正在运行,因为在我的应用程序的settings.py
中,我有ALLOWED_HOSTS=['192.168.0.17'、'localhost'、'127.0.0.1']
,当我在浏览器中访问端口8002时,我会看到Django的“恭喜!”页面。当我从允许的_主机中删除192.168.0.17时,django仍然从localhost或127.0.0.1在该机器上运行,因此这似乎与ngnix和uwsgi之间的通信方式有关
有什么想法吗???原来systemd不喜欢配置文件中的行太长。我删除了
/etc/systemd/system/uwsgi.service
中的几个长注释,重新启动了uwgsi服务,一切正常
我通过运行sudo journalctl-u uwsgi
并发现以下错误发现了这一点:
[/etc/systemd/system/uwsgi.service:5] Unbalanced quoting, ignoring: "/bin/bash -c 'mkdir -p /run/uwsgi; chown myusername:myusern
在研究不平衡引用时,发现了关于最大文件行长度的问题。nginx错误日志怎么说?