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

Detailed explanation of an example of adding nginx system Services to CentOS6.3

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Detailed explanation of an example of adding nginx system Services to CentOS6.3

Foreword:

Today, the virtual machine is equipped with a server to organize this nginx service.

Pay attention to the short bar symbol to see if there is any garbled code after it is copied. I encountered this problem before, and it took me a long time to find out.

Tip: don't remove the comments at the top or you can't register as a system service.

About: chkconfig: 2345 65 37

The online search summed up the following meaning:

2345 for the system environment 65 that starts the service, the priority level 37 for loading is the priority level for shutdown.

The values of these two locations cannot be the same, nor can they conflict with the values of other services. I have never encountered such a problem. If you find any problems, please modify your own configuration.

Create a new file:

# vi / etc/init.d/nginx

Enter the content:

#! / bin/sh # Comments to support chkconfig on RedHat Linux # chkconfig: 2345 65 37 # description: A nginx daemon. Set-e PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin DESC= "nginx daemon" NAME=nginx DAEMON=/usr/local/nginx/sbin/$NAME SCRIPTNAME=/etc/init.d/$NAME # If the daemon file is not found, terminate the script. Test-x $DAEMON | | exit 0 d_test () {$DAEMON-t} d_start () {$DAEMON | | echo-n "already running"} d_stop () {$DAEMON-s quit | | echo-n "not running"} d_reload () {$DAEMON-s reload | echo-n "could not reload"} case "$1" in test) d_test echo. " Start) echo-n "Starting $DESC: $NAME" d_start echo ".;; stop) echo-n" Stopping $DESC: $NAME "d_stop echo".;; reload) echo-n "Reloading $DESC configuration..." D_reload echo "reloaded."; restart) echo-n "Restarting $DESC: $NAME" d_stop # Sleep for two seconds before starting again, this should give the # Nginx daemon some time to perform a graceful stop. Sleep 2 d_start echo "."; *) echo "Usage: $SCRIPTNAME {test | start | stop | restart | reload}" > & 2 exit 3;; esac exit $?

Register for the nginx service:

Chmod + x / etc/init.d/nginx chkconfig-add nginx chkconfig-level 2345 nginx on chkconfig-list nginx

Related nginx commands:

Detect nginx configuration

# service nginx test

Start

# service nginx start

Close

# service nginx stop

Restart

# service nginx restart

Overload configuration

# service nginx reload

If you have any questions, please leave a message or go to the community to exchange and discuss, thank you for reading, hope to help you, thank you for your support!

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