Nginx CentOS Service startup Setup instance detailed _nginx

Source: Internet
Author: User
Tags centos

Nginx CentOS Service boot Setup

Create a service file

Taking Nginx as an example

Vim/lib/systemd/system/nginx.service

Insert content in Nginx.service

[Unit] 
Description=nginx 
after=network.target 

[service] 
type=forking 
execstart= Services startup command
execreload= Service restart command
execstop= Service stop command
privatetmp=true 

[Install] 
Wantedby=multi-user.target 

[Unit]: Description of the service
Description: Describing services
After: Description of service categories
Settings for running parameters for service services
Type=forking is the form of background running
Execstart the specific Run command for the service
Execreload reboot Command
Execstop to stop command
Privatetmp=true represents a temporary space for a service to be allocated independently
Note: The start, restart, and stop commands for service are all required to use absolute paths

Saved in directory with 754 permissions:/lib/systemd/system

To set the power-on self boot:

Systemctl Enable Nginx.service

Related commands

function Cnetos7 before CNETOS7
Show all started services Chkconfig--list systemctl list-units--type=service

Start a service nginx start Systemctl start Nginx.service or Systemctl start Nginx

Stop a service nginx stop Systemctl stop Nginx.service or systemctl stop Nginx

Restart a service nginx restart Systemctl Restart Nginx.service or systemctl restart Nginx

Enable a service to start automatically chkconfig--level 3 nginx on Systemctl enable Nginx.service or Systemctl enable Nginx

Make a service not start automatically chkconfig--level 3 nginx off systemctl disable Nginx.service or systemctl disable Nginx

Check Service status Nginx status Systemctl is-active nginx.service (show only if) Activesystemctl status nginx.se Rvice (Service details)

Thank you for reading, I hope to help you, thank you for your support for this site!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.