Original address: http://guodong810.blog.51cto.com/4046313/1285353
Sometimes, when we install a software ourselves, we want to make this service easier to control, 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 added to the startup list. It would be a lot easier if you would order a shell script.
With Nginx to explain its process, just 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 scripting, there must be chkconfig parameters in the script, such as: #chkconfig:-18 18 The front is preceded by the # (and comments, but not comments, followed by the boot needs to run the level, such as 2345, if you do not want to be on at any level, then use "-", 18 18 indicates the default sort number for S and K
Note:
S is the service to turn on when switching to this run level
K is the service to shut down when switching to another runlevel
3. Permission to perform this file for Nginx
chmod +x/etc/init.d/nginx
4. Join Chkconfig
[Email protected]]# chkconfig--add Nginx
If the following line error occurs, the Chkconfig parameter in the second step is not added
Service Nginx does not support Chkconfig
5. Next, you can configure this service to run at which level
Chkconfig--level
6. Next, you can use the service Nginx start to launch the
Redhat/centos using service control to start and close