Home > Operation and Maintenance > CentOS > What to do if nginx cannot be started under centos system

What to do if nginx cannot be started under centos system

王林
Release: 2020-03-20 14:55:25
Original
3940 people have browsed it

What to do if nginx cannot be started under centos system

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
Copy after login

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
Copy after login

After completion, execute the following command to start the service successfully.

systemctl start nginx.service
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template