I guess there is no nginx.service service startup script in the /usr/lib/systemd/system directory in your system. If you install it using yum, this script will be generated, because if you do not set it during compilation and installation If so, if you use systemctl (start/stop/reload/restart) nginx.service, of course an error will occur. If you insist on using compilation and installation, you can refer to the following script content to modify it. You can almost use the systemctl command.
============ The following content omits the comments starting with #======== [Unit] Description=The nginx HTTP and reverse proxy server After=network.target remote-fs.target nss-lookup.target
Mainly modify the path of the nginx executable file and the PID file path
10yue26 I accidentally saw the reminder today and accepted it. . There is still a small pitfall Whether this file is created or modified, you need to execute the following command after completion to let systemd load it
I guess there is no nginx.service service startup script in the /usr/lib/systemd/system directory in your system. If you install it using yum, this script will be generated, because if you do not set it during compilation and installation If so, if you use systemctl (start/stop/reload/restart) nginx.service, of course an error will occur. If you insist on using compilation and installation, you can refer to the following script content to modify it. You can almost use the systemctl command.
============ The following content omits the comments starting with #========
[Unit]
Description=The nginx HTTP and reverse proxy server
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/run/nginx.pid
ExecStartPre=/usr/bin/rm -f /run/nginx.pid
ExecStartPre=/usr/ sbin/nginx -t
ExecStart=/usr/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
KillMode=process
KillSignal=SIGQUIT
TimeoutStopSec=5
PrivateTmp=true
[Install]
WantedBy=multi-user.target
Mainly modify the path of the nginx executable file and the PID file path
10yue26 I accidentally saw the reminder today and accepted it. . There is still a small pitfall
Whether this file is created or modified, you need to execute the following command after completion to let systemd load it
systemctl daemon-reload
^_^
You give this message as if your car won’t start and then ask others why
Look at error.log
Run the journalctl -xe command, which will display the reason why nginx failed to start. Viewing detailed logs can help you solve the problem faster.