CentOS system sets Nginx service to start and run automatically

After completing the basic configuration of nginx, you can configure it as a service for easy management. At the same time, the service can be automatically started when the system starts. 1. First configure the service script and create the file /etc/rc.d/init.d/nginx2, the content of which is as follows: #!/bin/sh #chkconfig: 2345 10 90 #name: nginx #description: Nginx Service Script # case $1 in start) Echo “Starting Nginx…” /usr/local/nginx2/sbin/nginx -c /usr/local/nginx2/conf/nginx.conf ;; stop) echo “Stopping Nginx…” /usr/bin/killall -s QUIT nginx ;; restart) echo “Reloading Nginx…” $0 stop $0 start ;; *) Echo “Usage: $0 {start|stop|restart}” esac exit 0 2. Configure autostart chkconfig –add nginx2 //Add to self-starting service chkconfig –level 2345 nginx2 off //Adjust the start of different system levels chkconfig –level 2345 nginx2 on //Adjust the start of different system levels chkconfig | grep nginx2 //View status

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索