Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python nginx.service:无法从文件/run/nginx.PID读取PID:参数无效_Python_Django_Ubuntu_Nginx_Uwsgi - Fatal编程技术网

Python nginx.service:无法从文件/run/nginx.PID读取PID:参数无效

Python nginx.service:无法从文件/run/nginx.PID读取PID:参数无效,python,django,ubuntu,nginx,uwsgi,Python,Django,Ubuntu,Nginx,Uwsgi,我正在努力。我已经完成了图坦卡蒙,但我得到了一个502错误 My nginx服务器块配置文件: server { listen 80; server_name 198..xxx.xxx.xxx mysite.org; location = /favicon.ico { access_log off; log_not_found off; } location /static/ { root /home/deploy/mysite3; } location / { includ

我正在努力。我已经完成了图坦卡蒙,但我得到了一个502错误

My nginx服务器块配置文件:

server {
listen 80;
server_name 198..xxx.xxx.xxx mysite.org;

location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
    root /home/deploy/mysite3;
}

location / {
    include         uwsgi_params;
    uwsgi_pass      unix:/run/uwsgi/mysite3.sock;
}
}

deploy@server:/etc/nginx/sites-enabled$ sudo systemctl status nginx
● nginx.service - A high performance web server and a reverse proxy server
   Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2017-02-06 17:30:53 EST; 4s ago
  Process: 7374 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid (code=exited, status=0/SUCCESS)
  Process: 7383 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
  Process: 7380 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
 Main PID: 7384 (nginx)
   CGroup: /system.slice/nginx.service
           ├─7384 nginx: master process /usr/sbin/nginx -g daemon on; master_process on
           └─7385 nginx: worker process

Feb 06 17:30:53 server systemd[1]: Starting A high performance web server and a reverse proxy server...
Feb 06 17:30:53 server systemd[1]: nginx.service: Failed to read PID from file /run/nginx.pid: Invalid argument
Feb 06 17:30:53 server systemd[1]: Started A high performance web server and a reverse proxy server.
nginx错误日志显示:

2017/02/06 21:10:32 [error] 7385#7385: *15 upstream prematurely closed connection while reading response header from upstream, client: 64.xxx.xxx.xxx, server: 198.xxx.xxx.xxx, request: "GET / HTTP/1.1", upstream: "uwsgi://unix:/run/uwsgi/mysite3.sock:", host: "mysite.org"
在我看来,uwsgi运行正常:

Feb 06 17:43:42 server uwsgi[7434]: WSGI app 0 (mountpoint='') ready in 1 seconds on interpreter 0xc7ac10 pid: 7435 (default app)
Feb 06 17:43:42 server uwsgi[7434]: *** uWSGI is running in multiple interpreter mode ***
Feb 06 17:43:42 server uwsgi[7434]: spawned uWSGI master process (pid: 7435)
Feb 06 17:43:42 server uwsgi[7434]: Mon Feb  6 17:43:42 2017 - [emperor] vassal mysite3.ini has been spawned
Feb 06 17:43:42 server uwsgi[7434]: spawned uWSGI worker 1 (pid: 7439, cores: 1)
Feb 06 17:43:42 server uwsgi[7434]: spawned uWSGI worker 2 (pid: 7440, cores: 1)
Feb 06 17:43:42 server uwsgi[7434]: spawned uWSGI worker 3 (pid: 7441, cores: 1)
Feb 06 17:43:42 server uwsgi[7434]: spawned uWSGI worker 4 (pid: 7442, cores: 1)
Feb 06 17:43:42 server uwsgi[7434]: spawned uWSGI worker 5 (pid: 7443, cores: 1)
Feb 06 17:43:42 server uwsgi[7434]: Mon Feb  6 17:43:42 2017 - [emperor] vassal mysite3.ini is ready to accept requests
我怎样才能解决这个问题

编辑:


nginx.pid文件中的警告是一个已知的bug(如果不适用于其他发行版,则至少适用于Ubutnu)。详情如下:

解决方法(在ssh控制台上,作为root用户,使用下面的命令):

然后检查是否仍然看到nginx.pid错误,以及nginx是否正在实际运行,以及是否可以连接到服务器上的端口80

我还要检查它是否确实存在以及对它的权限:

/run/uwsgi/mysite3.sock
如果nginx正在运行,而uWSGI也在运行,那么我猜这是一个配置问题

我知道您希望使用Django,因此我建议您查看实际配置,并将其与下面的配置进行比较:


我希望有帮助

我首先要做的是:mkdir/etc/systemd/system/nginx.service.dI使用
apt安装nginx
和新鲜的UBUNTU 16 LTS。。。需要纠正这个错误。如何在没有这个bug的情况下安装NGINX?关于uWSGI的段落需要更多的解释。我很确定这不是必需的,我也不使用它。这很有效。我尝试printf语句时收到一条权限被拒绝的消息,之前只有一个“sudo”。所以,我必须先进入根(“sudo su”)。然后就被处决了。剩下的是纯“sudo”,以防有人来这里使用openresty时遇到同样的问题。通过将文件添加为
/lib/systemd/system/openresty.service.d/override.conf
mkdir /etc/systemd/system/nginx.service.d
printf "[Service]\nExecStartPost=/bin/sleep 0.1\n" > /etc/systemd/system/nginx.service.d/override.conf
systemctl daemon-reload
systemctl restart nginx 
/run/uwsgi/mysite3.sock