php-fpm开机自动启动Shell脚本
网上有各种版本的php-fpm开机自动启动脚本,其实你编译后源目录已经生成自动脚本。不用做任何修改即用。
cp{php-5.3.x-source-dir}/sapi/fpm/init.d.php-fpm/etc/init.d/php-fpm
php-fpm开机自动启动脚本如下:
#!/bin/sh ###BEGININITINFO #Provides:php-fpm #Required-Start:$remote_fs$network #Required-Stop:$remote_fs$network #Default-Start:2345 #Default-Stop:016 #Short-Description:startsphp-fpm #Description:startsthePHPFastCGIProcessManagerdaemon ###ENDINITINFO prefix=/usr/local/php exec_prefix=${prefix} php_fpm_BIN=${exec_prefix}/sbin/php-fpm php_fpm_CONF=${prefix}/etc/php-fpm.conf php_fpm_PID=${prefix}/var/run/php-fpm.pid php_opts="--fpm-config$php_fpm_CONF--pid$php_fpm_PID" wait_for_pid(){ try=0 whiletest$try-lt35;do case"$1"in 'created') if[-f"$2"];then try='' break fi ;; 'removed') if[!-f"$2"];then try='' break fi ;; esac echo-n. try=`expr$try+1` sleep1 done } case"$1"in start) echo-n"Startingphp-fpm" $php_fpm_BIN--daemonize$php_opts if["$?"!=0];then echo"failed" exit1 fi wait_for_pidcreated$php_fpm_PID if[-n"$try"];then echo"failed" exit1 else echo"done" fi ;; stop) echo-n"Gracefullyshuttingdownphp-fpm" if[!-r$php_fpm_PID];then echo"warning,nopidfilefound-php-fpmisnotrunning?" exit1 fi kill-QUIT`cat$php_fpm_PID` wait_for_pidremoved$php_fpm_PID if[-n"$try"];then echo"failed.Useforce-quit" exit1 else echo"done" fi ;; force-quit) echo-n"Terminatingphp-fpm" if[!-r$php_fpm_PID];then echo"warning,nopidfilefound-php-fpmisnotrunning?" exit1 fi kill-TERM`cat$php_fpm_PID` wait_for_pidremoved$php_fpm_PID if[-n"$try"];then echo"failed" exit1 else echo"done" fi ;; restart) $0stop $0start ;; reload) echo-n"Reloadservicephp-fpm" if[!-r$php_fpm_PID];then echo"warning,nopidfilefound-php-fpmisnotrunning?" exit1 fi kill-USR2`cat$php_fpm_PID` echo"done" ;; *) echo"Usage:$0{start|stop|force-quit|restart|reload}" exit1 ;; esac