![无法在 ubuntu 16.04 上安装 nginx](https://linux22.com/image/893547/%E6%97%A0%E6%B3%95%E5%9C%A8%20ubuntu%2016.04%20%E4%B8%8A%E5%AE%89%E8%A3%85%20nginx.png)
我见过类似的问题,但大多没有得到解决。我在停止 apache 服务器后安装 nginx
dpkg:错误处理软件包 nginx-core(--configure):子进程安装的安装后脚本返回错误退出状态 1
$ sudo apt 安装 nginx
Reading package lists... Done
Building dependency tree
Reading state information... Done
nginx is already the newest version (1.9.15-0ubuntu1).
0 upgraded, 0 newly installed, 0 to remove and 25 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] Y
Setting up nginx-core (1.9.15-0ubuntu1) ...
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.
dpkg: error processing package nginx-core (--configure):
subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of nginx:
nginx depends on nginx-core (>= 1.9.15-0ubuntu1) | nginx-full (>= 1.9.15-0ubuntu1) | nginx-light (>= 1.9.15-0ubuntu1) | nginx-extras (>= 1.9.15-0ubuntu1); however:
Package nginx-core is not configured yet.
Package nginx-full is not installed.
Package nginx-light is not installed.
Package nginx-extras is not installed.
nginx depends on nginx-core (<< 1.9.15-0ubuntu1.1~) | nginx-full (<< 1.9.15-0ubuntu1.1~) | nginx-light (<< 1.9.15-0ubuntu1.1~) | nginx-extras (<< 1.9.15-0ubuntu1.1~); however:
Package nginx-core is not configured yet.
Package nginx-full is not installed.
Package nginx-light is not installed.
Package nginx-extras is not installed.
dpkg: error processing package nginx (--configure):
dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
Errors were encountered while processing:
nginx-core
nginx
E: Sub-process /usr/bin/dpkg returned an error code (1)
运行“systemctl status nginx.service”后的输出
nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: en
Active: failed (Result: exit-code) since Fri 2017-05-26 12:50:30 IST; 3min 27
Process: 21570 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (cod
Process: 21566 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process
May 26 12:50:28 infinity nginx[21570]: nginx: [emerg] bind() to 0.0.0.0:80 faile
May 26 12:50:28 infinity nginx[21570]: nginx: [emerg] bind() to 0.0.0.0:80 faile
May 26 12:50:29 infinity nginx[21570]: nginx: [emerg] bind() to 0.0.0.0:80 faile
May 26 12:50:29 infinity nginx[21570]: nginx: [emerg] bind() to 0.0.0.0:80 faile
May 26 12:50:30 infinity nginx[21570]: nginx: [emerg] bind() to 0.0.0.0:80 faile
May 26 12:50:30 infinity nginx[21570]: nginx: [emerg] still could not bind()
May 26 12:50:30 infinity systemd[1]: nginx.service: Control process exited, code
May 26 12:50:30 infinity systemd[1]: Failed to start A high performance web serv
May 26 12:50:30 infinity systemd[1]: nginx.service: Unit entered failed state.
May 26 12:50:30 infinity systemd[1]: nginx.service: Failed with result 'exit-cod
lines 1-16/16 (END)
运行“journalctl -xe”后的输出
--
-- Unit nginx.service has begun starting up.
May 26 12:50:28 infinity nginx[21570]: nginx: [emerg] bind() to 0.0.0.0:80 faile
May 26 12:50:28 infinity nginx[21570]: nginx: [emerg] bind() to 0.0.0.0:80 faile
May 26 12:50:29 infinity nginx[21570]: nginx: [emerg] bind() to 0.0.0.0:80 faile
May 26 12:50:29 infinity nginx[21570]: nginx: [emerg] bind() to 0.0.0.0:80 faile
May 26 12:50:30 infinity nginx[21570]: nginx: [emerg] bind() to 0.0.0.0:80 faile
May 26 12:50:30 infinity nginx[21570]: nginx: [emerg] still could not bind()
May 26 12:50:30 infinity systemd[1]: nginx.service: Control process exited, code
May 26 12:50:30 infinity systemd[1]: Failed to start A high performance web serv
-- Subject: Unit nginx.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit nginx.service has failed.
--
-- The result is failed.
May 26 12:50:30 infinity systemd[1]: nginx.service: Unit entered failed state.
May 26 12:50:30 infinity systemd[1]: nginx.service: Failed with result 'exit-cod
May 26 12:50:32 infinity sudo[21514]: pam_unix(sudo:session): session closed for
May 26 12:50:48 infinity pkexec[21608]: pam_unix(polkit-1:session): session open
May 26 12:50:48 infinity pkexec[21608]: pam_systemd(polkit-1:session): Cannot cr
May 26 12:50:48 infinity pkexec[21608]: mayuresh: Executing command [USER=root]
lines 2095-2117/2117 (END)
答案1
我终于能够安装 nginx 了:我卸载了 apache2 并重新安装了 dpkg这个答案