Sometimes, when we install a software ourselves, we want to make it easier to control the service, in Redhat/centos we will first think of using service XXX start|stop to implement, but unfortunately, this requires us to write the startup shutdown script, and add it to the startup list. It would be a lot easier if you could point to a shell script.
Nginx to explain its process, but the process, do not paste the shell script
1. Create a startup shutdown script in the/etc/init.d/directory, such as Nginx
2. When writing a script, there must be a chkconfig parameter in the script, such as: #chkconfig: 18 18 is preceded by a # start (same as annotations, but not annotations, followed by the level at which the boot needs to run, such as 2345, if you do not want to at any level, use "-", 18 18 The default sort number for S and K
Note:
S is the service to be opened when switching to this run level
K is the service to be closed when switching to a different run level
3. Give Nginx the right to execute this file
chmod +x/etc/init.d/nginx
4. Join Chkconfig
[root@nginxrc3.d]# chkconfig--add Nginx
If the following line of error occurs, the chkconfig row parameter in the second step is not added
Service Nginx does not support Chkconfig
5. This service can then be configured to run at which level
Chkconfig--level Nginx on
6. You can then use service Nginx start to start the
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/OS/Linux/