![Nginx 无法在 Ubuntu 16.04 上清除](https://linux22.com/image/896094/Nginx%20%E6%97%A0%E6%B3%95%E5%9C%A8%20Ubuntu%2016.04%20%E4%B8%8A%E6%B8%85%E9%99%A4.png)
我想重新安装 nginx,但在清除或安装时出现此错误。
sudo service nginx start
Job for nginx.service failed because the control process exited with
error code. See "systemctl status nginx.service" and "journalctl -xe" for details.
alson@Alson:~$ sudo apt purge nginx
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
nginx*
0 upgraded, 0 newly installed, 1 to remove and 1 not upgraded.
2 not fully installed or removed.
After this operation, 37,9 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 197124 files and directories currently installed.)
Removing nginx (1.10.3-0ubuntu0.16.04.2) ...
Setting up nginx-core (1.10.3-0ubuntu0.16.04.2) ...
Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.
invoke-rc.d: initscript nginx, action "start" failed.
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Jum 2017-09-22 10:32:36 WIB; 12ms ago
Process: 13157 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)
Main PID: 2996 (code=exited, status=0/SUCCESS)
Sep 22 10:32:36 Alson systemd[1]: Starting A high performance web server and a reverse proxy server...
Sep 22 10:32:36 Alson nginx[13157]: nginx: [emerg] open() "/etc/nginx/nginx.conf" failed (2: No such file or directory)
Sep 22 10:32:36 Alson nginx[13157]: nginx: configuration file /etc/nginx/nginx.conf test failed
Sep 22 10:32:36 Alson systemd[1]: nginx.service: Control process exited, code=exited status=1
Sep 22 10:32:36 Alson systemd[1]: Failed to start A high performance web server and a reverse proxy server.
Sep 22 10:32:36 Alson systemd[1]: nginx.service: Unit entered failed state.
Sep 22 10:32:36 Alson systemd[1]: nginx.service: Failed with result 'exit-code'.
dpkg: error processing package nginx-core (--configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
nginx-core
E: Sub-process /usr/bin/dpkg returned an error code (1)
答案1
您似乎有未配置的包(2 not fully installed or removed.
)。
因此,您应该先通过执行 来处理这些问题sudo apt install -f
。之后,您可以重试清除(sudo apt purge nginx
)。根据您的情况,我建议使用 删除 nginx 子组件,以sudo apt autoremove --purge
清除剩余的 nginx 依赖项,以便重新安装。
如果所有步骤成功,你可以重新安装 nginx(sudo apt install nginx
)。
编辑:
由于问题无法通过这种方式解决,并且问题是由nginx-core
您可以尝试通过以下步骤手动修复问题引起的:
sudo apt -f remove nginx-core
这告诉 aptF使用您提供的说明解决问题,即只需删除nginx-core
。
编辑2:
由于最后一个失败的包是nginx-full
(参见第 29 行你的日志)您也必须将其删除。
要做到这一点:sudo apt -f remove nginx-full
然后,按照上述步骤进行操作,从 开始sudo apt autoremove --purge
。