首次尝试安装 LEMP,没有任何使用本教程的经验:如何在 Ubuntu 16.04 上安装 Nginx
在新实例(scaleway VPS)上运行 Ubuntu 16.04.1 LTS
由于出现错误,我尝试删除并重新安装 nginx
apt purge nginx
apt autoremove
apt install nginx
但我仍然遇到问题
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-full (--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.0-0ubuntu0.16.04.4) | nginx-full (>= 1.10.0-0ubuntu0.16.04.4) | nginx-light (>= 1.10.0-0ubuntu0.16.04.4) | nginx-extras (>= 1.10.0-0ubuntu0.16.04.4); however:
Package nginx-core is not installed.
Package nginx-full is not configured yet.
Package nginx-light is not installed.
Package nginx-extras is not installed.
nginx depends on nginx-core (<< 1.10.0-0ubuntu0.16.04.4.1~) | nginx-full (<< 1.10.0-0ubuntu0.16.04.4.1~) | nginx-light (<< 1.10.0-0ubuntu0.16.04.4.1~) | nginx-extras (<< 1.10.0-0ubuntu0.16.04.4.1~); however:
Package nginx-core is not installed.
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
Errors were encountered while processing:
nginx-full
nginx
E: Sub-process /usr/bin/dpkg returned an error code (1)
运行systemctl status nginx.service:
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Mon 2017-01-09 22:20:18 UTC; 5min ago
Process: 15561 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)
我还尝试了 sudo apt-get install nginx-full,它具有以下输出:
dpkg: error processing package nginx (--configure):
dependency problems - leaving unconfigured
Errors were encountered while processing:
nginx-full
nginx
答案1
检查 /var/log/nginx/error.log 那里可能有一些线索。我有这个:
2017/02/04 14:55:09 [emerg] 25011#25011:mkdir()“/var/cache/nginx/microcache”失败(2:没有此文件或目录)
因此我手动创建了 /var/cache/nginx 子目录并重新运行安装,并且成功了。