【问题标题】:Failed to start nginx.service: Unit not found启动 nginx.service 失败:未找到单元
【发布时间】:2019-10-24 23:12:43
【问题描述】:

我安装了最新版的nginx并配置了一些目录:

./configure --sbin-path=/usr/bin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --with-pcre --pid-path=/var/run/nginx.pid --with-http_ssl_module

一切正常。之后我创建了一个自定义文件:

nano /lib/systemd/system/nginx.service

文件内容:

[Unit]
Description=The NGINX HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
PIDFile=/var/run/nginx.pid
ExecStartPre=/usr/bin/nginx -t
ExecStart=/usr/bin/nginx
ExecReload=/usr/sbin/nginx -s reload
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target

但是当运行“systemctl start nginx”时,我得到错误“unit not found”:

我无法理解问题的原因或问题所在。运行“nginx -V”显示目录已设置。

有人知道吗? 提前致谢

【问题讨论】:

标签: nginx systemctl


【解决方案1】:

试试下面的,看看会发生什么。

 sudo yum install epel-release
 sudo yum install nginx
 sudo systemctl -l enable nginx
 sudo systemctl -l start nginx

它最初对我不起作用,因为没有安装 epel-release。但这是假设你使用 Fedora/CentOs

【讨论】:

    猜你喜欢
    • 2021-06-24
    • 2018-03-25
    • 2023-04-10
    • 2019-08-20
    • 2022-10-14
    • 2017-04-04
    • 2018-06-14
    • 2020-01-06
    相关资源
    最近更新 更多