nginx 无法在 Ubuntu 15.10 服务器上安装

E.Z*_*.Z. 2 server apt nginx

我正在尝试在我新安装的带有 Mate 桌面的 Ubuntu Server 15.10 上安装 nginx。

我做了一个快速更新:

sudo apt-get update
Run Code Online (Sandbox Code Playgroud)

现在尝试安装nginx:

sudo apt-get install nginx
Run Code Online (Sandbox Code Playgroud)

这是我得到的:

server@Node1:~/nod$ sudo apt-get install nginx
Reading package lists... Done
Building dependency tree       
Reading state information... Done
nginx is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 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.3-1ubuntu1.1) ...
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.3-1ubuntu1.1) | nginx-full (>= 1.9.3-1ubuntu1.1) | nginx-light (>= 1.9.3-1ubuntu1.1) | nginx-extras (>= 1.9.3-1ubuntu1.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.
 nginx depends on nginx-core (<< 1.9.3-1ubuntu1.1.1~) | nginx-full (<< 1.9.3-1ubuntu1.1.1~) | nginx-light (<< 1.9.3-1ubuntu1.1.1~) | nginx-extras (<< 1.9.3-1ubuntu1.1.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)
Run Code Online (Sandbox Code Playgroud)

这是输出 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: enabled)
   Active: failed (Result: exit-code) since Sat 2016-02-27 20:32:18 EST; 32min ago
  Process: 6023 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=1/FAILURE)
  Process: 6020 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)

Feb 27 20:32:16 Node1 nginx[6023]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
Feb 27 20:32:17 Node1 nginx[6023]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Feb 27 20:32:17 Node1 nginx[6023]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
Feb 27 20:32:17 Node1 nginx[6023]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Feb 27 20:32:17 Node1 nginx[6023]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
Feb 27 20:32:18 Node1 nginx[6023]: nginx: [emerg] still could not bind()
Feb 27 20:32:18 Node1 systemd[1]: nginx.service: Control process exited, code=exited status=1
Feb 27 20:32:18 Node1 systemd[1]: Failed to start A high performance web server and a reverse proxy server.
Feb 27 20:32:18 Node1 systemd[1]: nginx.service: Unit entered failed state.
Feb 27 20:32:18 Node1 systemd[1]: nginx.service: Failed with result 'exit-code'.
Run Code Online (Sandbox Code Playgroud)

这是我第一次使用 15.10,希望能更轻松。我几乎没有时间花在服务器安装和考虑回滚到 14.xx 上。如果您有任何解决方案,请告知。

谢谢你。

Ash*_*shu 5

在您的情况下,端口 80 或端口 98 已被其他进程使用。您需要找出哪个进程正在使用这些端口并终止该进程或服务。

sudo netstat -nlp
Run Code Online (Sandbox Code Playgroud)

然后你可以尝试启动nginx。顺便说一句,您的案例中已经安装了 nginx。

你可以参考这个link1link2