Nginx

無法在 Amazon Lightsail NodeJs 機器上安裝 nginx

  • July 10, 2019

嘗試安裝 nginx 時出現以下錯誤。

我在機器上託管了一個 reactjs 應用程序,並打算使用 nginx 設置反向代理

Reading package lists... Done
Building dependency tree
Reading state information... Done
nginx is already the newest version (1.10.3-0ubuntu0.16.04.3).
The following packages were automatically installed and are no longer required:
 libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.1-0
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 22 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.10.3-0ubuntu0.16.04.3) ...
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 Tue 2018-12-18 13:41:07 IST; 4ms ago
 Process: 10014 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)

Dec 18 13:41:07 -systemd[1]: Starting A high performance web s....
Dec 18 13:41:07  nginx[10014]: nginx: [emerg] unknown directiv...8
Dec 18 13:41:07  nginx[10014]: nginx: configuration file /etc/...d
Dec 18 13:41:07  systemd[1]: nginx.service: Control process ex...1
Dec 18 13:41:07  systemd[1]: Failed to start A high performanc....
Dec 18 13:41:07  systemd[1]: nginx.service: Unit entered faile....
Dec 18 13:41:07  systemd[1]: nginx.service: Failed with result....
Hint: Some lines were ellipsized, use -l to show in full.
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.10.3-0ubuntu0.16.04.3) | nginx-full (>= 1.10.3-0ubuntu0.16.04.3) | nginx-light (>= 1.10.3-0ubuntu0.16.04.3) | nginx-extras (>= 1.10.3-0ubuntu0.16.04.3); 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.10.3-0ubuntu0.16.04.3.1~) | nginx-full (<< 1.10.3-0ubuntu0.16.04.3.1~) | nginx-light (<< 1.10.3-0ubuntu0.16.04.3.1~) | nginx-extras (<< 1.10.3-0ubuntu0.16.04.3.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)

幾點建議:確保在安裝之前沒有其他 Web 伺服器正在執行。解除安裝 Nginx 包括配置文件。從官方 Nginx 儲存庫安裝 Nginx,儘管您不必這樣做。

引用自:https://serverfault.com/questions/944329