Problem:
After installing nginx from the source code, the following error is reported when starting "
Failed to start nginx.service: Unit not found.
Solution:
(Recommended tutorial: centos usage tutorial)
At this time we need to create the nginx file in the system service directory.
vi /lib/systemd/system/nginx.service
Then copy the following content
[Unit] Description=nginx After=network.target [Service] Type=forking ExecStart=/usr/local/nginx/sbin/nginx ExecReload=/usr/local/nginx/sbin/nginx -s reload ExecStop=/usr/local/nginx/sbin/nginx -s quit PrivateTmp=true [Install] WantedBy=multi-user.target
After completion, execute the following command to start the service successfully.
systemctl start nginx.service
Recommended related video tutorials: linux video tutorial
The above is the detailed content of What to do if nginx cannot be started under centos system. For more information, please follow other related articles on the PHP Chinese website!