Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Method steps for CentOS7 to add Nginx to system service

2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Introduction

After compiling, installing and resolving the problem, Nginx is running normally, but Nginx is not added to the system service at this time. Next, Nginx is added to the system service and boot is set up.

View Servic

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

If the relevant services are not found, the next step is to add system services.

Add system services

Add nginx.service to the / usr/lib/systemd/system directory and modify it according to the actual situation. For detailed analysis, see the article in Resources below. The contents are as follows

[Unit] Description=nginx-high performance web serverDocumentation= http://nginx.org/en/docs/After=network.target remote-fs.target nss-lookup.target [Service] Type=forkingPIDFile=/usr/local/nginx/logs/nginx.pidExecStartPre=/usr/local/nginx/sbin/nginx-t-c / usr/local/nginx/conf/nginx.confExecStart=/usr/local/nginx/sbin/nginx-c / usr/local/nginx/conf/nginx.confExecReload=/bin/kill-s HUP $MAINPIDExecStop=/bin/kill-s QUIT $MAINPIDPrivateTmp=true [Install] WantedBy=multi-user.target

Let's take a look at it after it has been added.

Set the boot to start automatically

Test it first, restart it, and then check the Nginx service

It didn't start. Enter systemctl start nginx to start

You can start with systemctl, indicating that there is no problem with the previously added nginx.service. Then enter systemctl enable nginx to set boot up

Finally, restart to check whether the setting is successful.

No problem, so the compilation and installation of Nginx is complete, followed by the installation of PHP.

Reference: CentOS 7 systemd add Custom system Services,

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report