我安装了最新版本的 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
Run Code Online (Sandbox Code Playgroud)
一切正常。之后我创建了一个自定义文件:
nano /lib/systemd/system/nginx.service
Run Code Online (Sandbox Code Playgroud)
文件内容:
[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
Run Code Online (Sandbox Code Playgroud)
但是当运行“systemctl start nginx”时,我收到错误“未找到单元”:
我不明白为什么或有什么问题。运行“nginx -V”显示目录已设置。
有人有线索吗?提前致谢
小智 7
尝试以下操作,让我们看看会发生什么。
sudo yum install epel-release
sudo yum install nginx
sudo systemctl -l enable nginx
sudo systemctl -l start nginx
Run Code Online (Sandbox Code Playgroud)
它最初对我不起作用,因为没有安装 epel-release。但这是假设您使用 Fedora/CentOs
| 归档时间: |
|
| 查看次数: |
24005 次 |
| 最近记录: |