First, Nginx boot setting
1. Create a script in the/etc/init.d/directory
VI /etc/init.d/nginx
2. Change Script Permissions
chmod 775/etc/init.d/nginx
3. Writing script content
#! /bin/sh
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
pidfile=/var/run/$NAME. PID
# If The daemon file is not found, terminate the script.
Test-x $DAEMON | | Exit 0
D_start () {
$DAEMON | | Echo-n "Already Running"
}
D_stop () {
Kill-quit ' Cat $PIDFILE ' | | Echo-n "Not Running"
}
D_reload () {
Kill-hup ' Cat $PIDFILE ' | | Echo-n "Could not reload"
}
Case "$" in
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 both 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 {start|stop|restart|reload}" >&2
Exit 3
;;
Esac
Exit 0
4. Set Boot start
This shows that the system in Ubuntu does not have the Chkconfig command in the RH system!
Some gadgets are available to manage Ubuntu startup options, rcconf:
#sudo Apt-get rcconf
#sudo Apt-get Install rcconf
Run under root: #sudo rcconf
More-functional tools: sysv-rc-conf
#sudo apt-get Update
#sudo Apt-get Install sysv-rc-conf
Run: #sudo sysv-rc-conf
You can also join the startup program directly, such as adding/etc/init.d/red5 to the system Autostart list:
#sudo sysv-rc-conf red5 on
Other ways to use see: google::ubuntu::sysv-rc-conf command usage
Second, PHP boot startup settings
1. Create a script in the/etc/init.d/directory
VI /ETC/INIT.D/PHP-FPM
2. Change Script Permissions
chmod 775/etc/init.d/php-fpm
3. Writing script content
#!/bin/SH# # PHP-fpm-this script starts and stops the php-fpm daemin## chkconfig:- - the# processname:php-fpm# config:/usr/local/php/etc/php-Fpm.confset-Epath=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/Bindesc="php-fpm Daemon"NAME=php-Fpmdaemon=/usr/local/php5.6/sbin/$NAMECONFIGFILE=/usr/local/php5.6/etc/$NAME. Confpidfile=/var/run/php-Fpm5.pidscriptname=/etc/init.d/php-fpm5# If The daemonfileis not found, terminate the Script.test-X $DAEMON | | Exit0D_start () {$DAEMON-Y $CONFIGFILE | |Echo-N"already running"}d_stop () {Kill-quit 'Cat$PIDFILE ' | |Echo-N"no running"}d_reload () {Kill-hup 'Cat$PIDFILE ' | |Echo-N"could not reload"} Case " $" inchstart)Echo-N"starting $DESC: $NAME"D_startEcho ".";; Stop)Echo-N"stopping $DESC: $NAME"D_stopEcho ".";; Reload)Echo-N"Reloading $DESC Configuration ..."D_reloadEcho "Reloaded.";; Restart)Echo-N"restarting $DESC: $NAME"d_stop# Sleep forSeconds before starting again, this should give the Nginx daemon some TimeTo perform a graceful stopSleep 2D_startEcho ".";;*)Echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload)">&2Exit3;;EsacExit0
4, through the above self-starting method to set.
Third, MySQL boot settings
1. Copying related documents
Cp-a./support-files/my-default.cnf/etc/my.cnf
Cp-a./support-files/mysql.server/etc/init.d/mysqld
2. Set above
Four, Redis boot startup settings
1. Create a script in the/etc/init.d/directory
VI /etc/init.d/redis
2. Change Script Permissions
chmod 775/etc/init.d/redis
3. Writing script content
#!/bin/sh
# chkconfig:2345 10 90
# simple Redis INIT.D script conceived to work on Linux systems
# as it does use of the/proc filesystem.
redisport=6379
Exec=/usr/local/bin/redis-server
Cliexec=/usr/local/bin/redis-cli
Pidfile=/var/run/redis.pid
conf= "/etc/redis.conf"
Case "$" in
Start
If [-F $PIDFILE]
Then
echo "$PIDFILE exists, process is already running or crashed"
Else
echo "Starting Redis server ..."
$EXEC $CONF &
Fi
;;
Stop
if [!-F $PIDFILE]
Then
echo "$PIDFILE does not exist, process was not running"
Else
pid=$ (Cat $PIDFILE)
echo "Stopping ..."
$CLIEXEC-P $REDISPORT shutdown
While [-x/proc/${pid}]
Do
echo "Waiting for Redis to shutdown ..."
Sleep 1
Done
echo "Redis stopped"
Fi
;;
*)
echo "Please use Start or stop as first argument"
;;
Esac
4, through the above self-starting method to set.
Linux under Nginx, PHP, MySQL, Redis boot from boot settings