当我尝试安装时nginx
,apt
出现以下错误:
Selecting previously unselected package nginx-common.
(Reading database ... 137404 files and directories currently installed.)
Preparing to unpack .../00-nginx-common_1.10.3-1+deb9u1_all.deb ...
Unpacking nginx-common (1.10.3-1+deb9u1) ...
Selecting previously unselected package libnginx-mod-http-auth-pam.
Preparing to unpack .../01-libnginx-mod-http-auth-pam_1.10.3-1+deb9u1_amd64.deb ...
Unpacking libnginx-mod-http-auth-pam (1.10.3-1+deb9u1) ...
Selecting previously unselected package libnginx-mod-http-dav-ext.
Preparing to unpack .../02-libnginx-mod-http-dav-ext_1.10.3-1+deb9u1_amd64.deb ...
Unpacking libnginx-mod-http-dav-ext (1.10.3-1+deb9u1) ...
Selecting previously unselected package libnginx-mod-http-echo.
Preparing to unpack .../03-libnginx-mod-http-echo_1.10.3-1+deb9u1_amd64.deb ...
Unpacking libnginx-mod-http-echo (1.10.3-1+deb9u1) ...
Selecting previously unselected package libnginx-mod-http-geoip.
Preparing to unpack .../04-libnginx-mod-http-geoip_1.10.3-1+deb9u1_amd64.deb ...
Unpacking libnginx-mod-http-geoip (1.10.3-1+deb9u1) ...
Selecting previously unselected package libnginx-mod-http-image-filter.
Preparing to unpack .../05-libnginx-mod-http-image-filter_1.10.3-1+deb9u1_amd64.deb ...
Unpacking libnginx-mod-http-image-filter (1.10.3-1+deb9u1) ...
Selecting previously unselected package libnginx-mod-http-subs-filter.
Preparing to unpack .../06-libnginx-mod-http-subs-filter_1.10.3-1+deb9u1_amd64.deb ...
Unpacking libnginx-mod-http-subs-filter (1.10.3-1+deb9u1) ...
Selecting previously unselected package libnginx-mod-http-upstream-fair.
Preparing to unpack .../07-libnginx-mod-http-upstream-fair_1.10.3-1+deb9u1_amd64.deb ...
Unpacking libnginx-mod-http-upstream-fair (1.10.3-1+deb9u1) ...
Selecting previously unselected package libnginx-mod-http-xslt-filter.
Preparing to unpack .../08-libnginx-mod-http-xslt-filter_1.10.3-1+deb9u1_amd64.deb ...
Unpacking libnginx-mod-http-xslt-filter (1.10.3-1+deb9u1) ...
Selecting previously unselected package libnginx-mod-mail.
Preparing to unpack .../09-libnginx-mod-mail_1.10.3-1+deb9u1_amd64.deb ...
Unpacking libnginx-mod-mail (1.10.3-1+deb9u1) ...
Selecting previously unselected package libnginx-mod-stream.
Preparing to unpack .../10-libnginx-mod-stream_1.10.3-1+deb9u1_amd64.deb ...
Unpacking libnginx-mod-stream (1.10.3-1+deb9u1) ...
Selecting previously unselected package nginx-full.
Preparing to unpack .../11-nginx-full_1.10.3-1+deb9u1_amd64.deb ...
Unpacking nginx-full (1.10.3-1+deb9u1) ...
Selecting previously unselected package nginx.
Preparing to unpack .../12-nginx_1.10.3-1+deb9u1_all.deb ...
Unpacking nginx (1.10.3-1+deb9u1) ...
Processing triggers for ufw (0.35-4) ...
Setting up nginx-common (1.10.3-1+deb9u1) ...
Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service → /lib/systemd/system/nginx.service.
Setting up libnginx-mod-http-image-filter (1.10.3-1+deb9u1) ...
Setting up libnginx-mod-http-subs-filter (1.10.3-1+deb9u1) ...
Processing triggers for systemd (232-25+deb9u1) ...
Setting up libnginx-mod-http-auth-pam (1.10.3-1+deb9u1) ...
Setting up libnginx-mod-http-dav-ext (1.10.3-1+deb9u1) ...
Setting up libnginx-mod-mail (1.10.3-1+deb9u1) ...
Processing triggers for man-db (2.7.6.1-2) ...
Setting up libnginx-mod-http-xslt-filter (1.10.3-1+deb9u1) ...
Setting up libnginx-mod-http-upstream-fair (1.10.3-1+deb9u1) ...
Setting up libnginx-mod-http-geoip (1.10.3-1+deb9u1) ...
Setting up libnginx-mod-stream (1.10.3-1+deb9u1) ...
Setting up libnginx-mod-http-echo (1.10.3-1+deb9u1) ...
Setting up nginx-full (1.10.3-1+deb9u1) ...
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 Wed 2018-01-03 08:12:19 GMT; 35ms ago
Docs: man:nginx(8)
Process: 1563 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=1/FAILURE)
Process: 1561 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Jan 03 08:12:17 testingBed nginx[1563]: nginx: [emerg] listen() to [::]:80, …se)
Jan 03 08:12:18 testingBed nginx[1563]: nginx: [emerg] listen() to 0.0.0.0:8…se)
Jan 03 08:12:18 testingBed nginx[1563]: nginx: [emerg] listen() to [::]:80, …se)
Jan 03 08:12:18 testingBed nginx[1563]: nginx: [emerg] listen() to 0.0.0.0:8…se)
Jan 03 08:12:18 testingBed nginx[1563]: nginx: [emerg] listen() to [::]:80, …se)
Jan 03 08:12:19 testingBed nginx[1563]: nginx: [emerg] still could not bind()
Jan 03 08:12:19 testingBed systemd[1]: nginx.service: Control process exite…us=1
Jan 03 08:12:19 testingBed systemd[1]: Failed to start A high performance w…ver.
Jan 03 08:12:19 testingBed systemd[1]: nginx.service: Unit entered failed state.
Jan 03 08:12:19 testingBed systemd[1]: nginx.service: Failed with result 'e…de'.
Hint: Some lines were ellipsized, use -l to show in full.
dpkg: error processing package nginx-full (--configure):
subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of nginx:
nginx depends on nginx-full (<< 1.10.3-1+deb9u1.1~) | nginx-light (<< 1.10.3-1+deb9u1.1~) | nginx-extras (<< 1.10.3-1+deb9u1.1~); however:
Package nginx-full is not configured yet.
Package nginx-light is not installed.
Package nginx-extras is not installed.
nginx depends on nginx-full (>= 1.10.3-1+deb9u1) | nginx-light (>= 1.10.3-1+deb9u1) | nginx-extras (>= 1.10.3-1+deb9u1); however:
Package nginx-full is not configured yet.
Package nginx-light is not installed.
Package nginx-extras is not installed.
dpkg: error processing package nginx (--configure):
dependency problems - leaving unconfigured
Processing triggers for ufw (0.35-4) ...
Errors were encountered while processing:
nginx-full
nginx
E: Sub-process /usr/bin/dpkg returned an error code (1)
答案1
错误消息表明nginx
无法绑定(到端口 80)。
最可能的原因是您有另一个 Web 服务器已经在侦听端口 80 - 也许apache
是旧版本的nginx
.
如果是这种情况,请停止旧的 Web 服务器并继续安装:
dpkg --configure --pending
另一种选择是配置nginx
(或 apache)以侦听不同的端口。 8080 是“辅助”Web 服务器的常见且流行的选择。或者如果主机有多个可用的 IP 地址,则使用不同的 IP 地址。