我有一个 nginx 服务,它运行良好,唯一的问题是我无法启用它。我关注了这个帖子不是本机服务 systemd - 无法在启动时运行并按照接受的答案做了,但我仍然遇到问题。
当我跑步时:
sudo systemctl enable nginx.service
我得到:
Synchronizing state of nginx.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable nginx
update-rc.d: error: nginx Default-Start contains no runlevels, aborting.
当我启动sudo systemctl start nginx.service
并运行时:
sudo systemctl status nginx.service
我正进入(状态:
nginx.service - The NGINX HTTP and reverse proxy server
Loaded: loaded (/etc/systemd/system/nginx.service; disabled; vendor preset: enabled)
Active: active (running) since Wed 2020-10-28 08:26:05 UTC; 57min ago
Tasks: 3 (limit: 2303)
CGroup: /system.slice/nginx.service
├─1281 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
├─2094 nginx: worker process
└─2095 nginx: cache manager process
Oct 28 08:26:04 vps-cef86568 systemd[1]: Starting nginx.service...
Oct 28 08:26:05 vps-cef86568 nginx[1262]: * Starting Nginx Server
Oct 28 08:26:05 vps-cef86568 nginx[1262]: ...done.
Oct 28 08:26:05 vps-cef86568 systemd[1]: Started nginx.service.
我的/etc/systemd/system/nginx.service
文件如下所示:
[Unit]
Description=The NGINX HTTP and reverse proxy server
After=syslog.target network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target
[Service]
Type=forking
PIDFile=/run/nginx.pid
ExecStartPre=/usr/sbin/nginx -t
ExecStart=/usr/sbin/nginx
ExecReload=/usr/sbin/nginx -s reload
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
关于如何启用它有什么建议吗?
答案1
由于某种原因,Ubuntu 的 nginx 构建包含一个 systemd 单元和它原本要替换的过时的 SysV init 脚本。这也存在于 20.04 LTS 中,因此升级不会有帮助。我猜有些打包者只是忘记了它;考虑在 Launchpad 上打开报告,以便维护人员可以删除过时的脚本。
对于眼前的问题,您可能应该使用 Ubuntu 附带的 systemd 单元,而不是您自己的单元。删除您创建的文件,运行systemctl daemon-reload
,然后尝试再次启用该服务。
答案2
sudo /usr/local/smokeping/bin/smokeping --debug
错误:/usr/local/smokeping/bin/../etc/config,第 13 行:表语法错误
输入调试命令后出现该错误
以下是它所引用的文件:
所有者 = cict 联系人 = ***[电子邮件保护] mailhost = mail.****za.zm imgcache = /usr/local/smokeping/cache imgurl = 缓存 datadir = /usr/local/smokeping/data piddir = /usr/local/smokeping/var cgiurl =http://155.0.72.158/smokeping.cgi smokemail = /usr/local/smokeping/etc/smokemail.dist tmail = /usr/local/smokeping/etc/tmail.dist syslogfacility = smokeping *** 警报 *** 至 = ***[电子邮件保护] 来自 = mail@**za.zm +someloss 类型 = 损失模式 = >0%,12,>0%,12,>0% 评论 = 连续 3 次亏损