Nginx 无法启动

Nginx 无法启动

我目前正在尝试设置 nginx 来帮助我在家运行网站。我已按照以下说明设置 nginx:

sudo apt update
sudo apt install nginx
sudo ufw app list
sudo ufw allow 'Nginx HTTP'
sudo ufw status

一旦我尝试运行sudo systemctl start nginx,我就会得到

Job for nginx.service failed because the control process exited with error code.
See "systemctl status nginx.service" and "journalctl -xe" for details.

运行systemctl status nginx我得到以下信息:

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 2020-04-08 16:00:43 BST; 9min ago
     Docs: man:nginx(8)
  Process: 8820 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)

Apr 08 16:00:43 AMCosyClub systemd[1]: Starting A high performance web server and a reverse proxy server...
Apr 08 16:00:43 AMCosyClub nginx[8820]: nginx: [emerg] directive "root" is not terminated by ";" in /etc/nginx/conf.d/writefreely.conf:6
Apr 08 16:00:43 AMCosyClub nginx[8820]: nginx: configuration file /etc/nginx/nginx.conf test failed
Apr 08 16:00:43 AMCosyClub systemd[1]: nginx.service: Control process exited, code=exited status=1
Apr 08 16:00:43 AMCosyClub systemd[1]: nginx.service: Failed with result 'exit-code'.
Apr 08 16:00:43 AMCosyClub systemd[1]: Failed to start A high performance web server and a reverse proxy server.

运行journalctl -xe产生

Apr 08 16:00:43 AMCosyClub nginx[8820]: nginx: configuration file /etc/nginx/nginx.conf test failed
Apr 08 16:00:43 AMCosyClub systemd[1]: nginx.service: Control process exited, code=exited status=1
Apr 08 16:00:43 AMCosyClub systemd[1]: nginx.service: Failed with result 'exit-code'.
Apr 08 16:00:43 AMCosyClub systemd[1]: Failed to start A high performance web server and a reverse proxy server.
-- Subject: Unit nginx.service has failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- Unit nginx.service has failed.
-- 
-- The result is RESULT.
Apr 08 16:00:43 AMCosyClub sudo[8817]: pam_unix(sudo:session): session closed for user root
Apr 08 16:00:49 AMCosyClub systemd[1]: Started Run anacron jobs.
-- Subject: Unit anacron.service has finished start-up
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- Unit anacron.service has finished starting up.
-- 
-- The start-up result is RESULT.
Apr 08 16:00:49 AMCosyClub anacron[8821]: Anacron 2.3 started on 2020-04-08
Apr 08 16:00:49 AMCosyClub anacron[8821]: Normal exit (0 jobs run)
Apr 08 16:02:26 AMCosyClub kernel: [UFW BLOCK] IN=wlp8s0 OUT= MAC=redacted SRC=redacted DST=redacted LEN=36 TOS=0x

[1]+  Stopped                 journalctl -xe

我检查了 nginx 错误日志,它重复了以下内容:

[emerg] 8820#8820: directive "root" is not terminated by ";" in /etc/nginx/conf.d/writefreely.conf:6

我对这些东西完全是新手,所以任何帮助我都会非常感激。请让我知道我是否可以提供任何进一步的详细信息/运行特定命令来帮助进一步弄清发生了什么。谢谢!

答案1

错误信息非常明确:

/etc/nginx/conf.d/writefreely.conf:6 中的指令“root”没有以“;”结尾

编辑文件:/etc/nginx/conf.d/writefreely.conf

转到第 6 行

在行末添加“;”

重启 nginx

相关内容