我最近将我的 Ubuntu 服务器升级到 16.04 版本。从此我无法启动nginx服务。
结果service nginx restart:
Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.
Run Code Online (Sandbox Code Playgroud)
我的系统日志显示的是 ( cat /var/log/syslog) :
May 20 17:03:53: Stopped A high performance web server and a reverse proxy server.
May 20 17:03:53: Starting A high performance web server and a reverse proxy server...
May 20 17:03:53: nginx.service: Failed at step EXEC spawning /usr/sbin/nginx: No such file or directory
May 20 17:03:53: nginx.service: Control process exited, code=exited status=203
May 20 17:03:53: Failed to start A high performance web server and a reverse proxy server.
May 20 17:03:53: nginx.service: Unit entered failed state.
May 20 17:03:53: nginx.service: Failed with result 'exit-code'.
Run Code Online (Sandbox Code Playgroud)
结果cat /lib/systemd/system/nginx.service:
# Stop dance for nginx
# =======================
#
# ExecStop sends SIGSTOP (graceful stop) to the nginx process.
# If, after 5s (--retry QUIT/5) nginx is still running, systemd takes control
# and sends SIGTERM (fast shutdown) to the main process.
# After another 5s (TimeoutStopSec=5), and if nginx is alive, systemd sends
# SIGKILL to all the remaining processes in the process group (KillMode=mixed).
#
# nginx signals reference doc:
# http://nginx.org/en/docs/control.html
#
[Unit]
Description=A high performance web server and a reverse proxy server
After=network.target
[Service]
Type=forking
PIDFile=/run/nginx.pid
ExecStartPre=/usr/sbin/nginx -t -q -g 'daemon on; master_process on;'
ExecStart=/usr/sbin/nginx -g 'daemon on; master_process on;'
ExecReload=/usr/sbin/nginx -g 'daemon on; master_process on;' -s reload
# Use TERM instead of QUIT to prevent Nginx from leaving stale Unix socket and failing the next start (https://trac.nginx.org/nginx/ticket/753)
ExecStop=-/sbin/start-stop-daemon --quiet --stop --retry TERM/5 --pidfile /run/nginx.pid
# Give Passenger a chance to clean up before being killed by systemd.
ExecStop=/bin/sleep 1
TimeoutStopSec=5
KillMode=mixed
[Install]
WantedBy=multi-user.target
Run Code Online (Sandbox Code Playgroud)
确实没有文件/usr/sbin/nginx,所以我尝试了apt install nginx,但结果如下:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
nginx : Depends: nginx-core (>= 1.10.0-0ubuntu0.16.04.4) but it is not going to be installed or
nginx-full (>= 1.10.0-0ubuntu0.16.04.4) but it is not going to be installed or
nginx-light (>= 1.10.0-0ubuntu0.16.04.4) but it is not going to be installed or
nginx-extras (>= 1.10.0-0ubuntu0.16.04.4) but it is not going to be installed
Depends: nginx-core (< 1.10.0-0ubuntu0.16.04.4.1~) but it is not going to be installed or
nginx-full (< 1.10.0-0ubuntu0.16.04.4.1~) but it is not going to be installed or
nginx-light (< 1.10.0-0ubuntu0.16.04.4.1~) but it is not going to be installed or
nginx-extras (< 1.10.0-0ubuntu0.16.04.4.1~) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
Run Code Online (Sandbox Code Playgroud)
作为一个新手,我很迷茫,我真的需要一些帮助。
非常感谢您的宝贵时间。
更新 1:
结果apt-cache policy nginx:
nginx:
Installed: 1.12.0-1+xenial1
Candidate: 1.12.0-1+xenial1
Version table:
*** 1.12.0-1+xenial1 500
500 http://ppa.launchpad.net/nginx/stable/ubuntu xenial/main amd64 Packages
500 http://ppa.launchpad.net/nginx/stable/ubuntu xenial/main i386 Packages
100 /home/var/lib/dpkg/status
1.10.0-0ubuntu0.16.04.4 500
500 http://ubuntu.mirrors.ovh.net/ftp.ubuntu.com/ubuntu xenial-updates/main amd64 Packages
500 http://ubuntu.mirrors.ovh.net/ftp.ubuntu.com/ubuntu xenial-updates/main i386 Packages
500 http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages
500 http://security.ubuntu.com/ubuntu xenial-security/main i386 Packages
1.9.15-0ubuntu1 500
500 http://ubuntu.mirrors.ovh.net/ftp.ubuntu.com/ubuntu xenial/main amd64 Packages
500 http://ubuntu.mirrors.ovh.net/ftp.ubuntu.com/ubuntu xenial/main i386 Packages
Run Code Online (Sandbox Code Playgroud)
因此,您有两件事存在冲突,并且似乎导致 nginx 二进制文件以某种方式消失:Xenial 存储库版本和 NGINX PPA。作为两者的维护者,请允许我解释一下冲突。
在 Xenial 中,我们在作为更新发布后发布了 1.10.0。此更新将我们推向“稳定”分支,但没有构建和提供可动态加载的模块。这是由于时间原因,但也造成了测试期间出现的冲突。我们最终在 Zesty 中获得了动态模块支持。
在 PPA 中,我们总是直接从 Debian 克隆。这意味着,我们总是有 Debian 的“动态模块”支持,它与 Xenial 软件包冲突并导致一些安装和升级冲突。
这里有一个小冲突——你不能混合搭配nginx-core(这是为nginx在 Ubuntu 中软件包)和 PPA,因为它有时会使事情消失。那么,这里的问题是我们需要删除现有的 Ubuntu 包,然后仅从 PPA 安装。
要解决此问题,您首先需要备份要为站点保留的 nginx 配置。也就是说,在其他地方复制您的 /etc/nginx/sites-available/ 目录(即使在您用户的主目录中也可以,我们只需要一份站点配置的副本)。同样,我们需要备份您的网站数据,因此也将其复制到其他地方(不在标准 docroot 中,因此不会弄乱)。
制作副本后,您必须删除现有的 nginx 包。这可以通过以下命令完成:
sudo apt-get remove nginx nginx-common nginx-doc nginx-core nginx-full nginx-extras nginx-light
Run Code Online (Sandbox Code Playgroud)
完成后,sudo apt-get update再次运行以确保我们拥有最新的版本编号。
然后,nginx从 PPA安装-sudo apt-get install nginx nginx-full nginx-common应该这样做。
您应该不会再遇到无法启动错误的情况了。确保您的站点配置仍然存在,并且没有被覆盖。如果他们这样做了,请从我们之前对站点配置和站点数据进行的备份中恢复。否则,你都准备好了。
| 归档时间: |
|
| 查看次数: |
9596 次 |
| 最近记录: |