【发布时间】: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”显示目录已设置。
有人知道吗? 提前致谢
【问题讨论】:
-
非常感谢 Chetan,看来“systemctl daemon-reload”解决了这个问题。一开始我以为对方的问题太不一样了。谢谢!