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

What to do if nginx cannot be started under centos system

王林
王林Original
2020-03-20 14:55:253908browse

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

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!

Statement:
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