Home  >  Article  >  Operation and Maintenance  >  How to add system services to Nginx in CentOS7

How to add system services to Nginx in CentOS7

WBOY
WBOYforward
2023-05-12 15:25:151165browse

View service

First check the service status of nginx, enter systemctl status nginx, the result is as follows

How to add system services to Nginx in CentOS7

No related services were found, the next step is to add system services.

Add system service

Add nginx.service in the /usr/lib/systemd/system directory, according to Modifications are made based on the actual situation. For detailed analysis, please refer to the article in the reference materials below. The content is as follows

[unit]
description=nginx - high performance web server
documentation=http://nginx.org/en/docs/
after=network.target remote-fs.target nss-lookup.target
 
[service]
type=forking
pidfile=/usr/local/nginx/logs/nginx.pid
execstartpre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
execstart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
execreload=/bin/kill -s hup $mainpid
execstop=/bin/kill -s quit $mainpid
privatetmp=true
 
[install]
wantedby=multi-user.target

Let’s take a look after adding it

How to add system services to Nginx in CentOS7

Set up to start automatically at boot

Test it first. Restart and check that the nginx service

How to add system services to Nginx in CentOS7

is indeed not started. Enter systemctl start nginx to start

How to add system services to Nginx in CentOS7

You can use systemctl to start, indicating the previously added nginx.service no problem. Then enter systemctl enable nginx to set up startup

How to add system services to Nginx in CentOS7

Finally restart and check whether the setting is successful

How to add system services to Nginx in CentOS7

No problem, now the compilation and installation of nginx is completed, next is the installation of php.

The above is the detailed content of How to add system services to Nginx in CentOS7. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete