一. Nginx 开机启动php
NGINX SHELL脚本 放到/etc/init.d/下取名nginxmysql
下面代码里根据你原始安装路径去更改nginx
nginx="/usr/localinx/sbininx"
NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf" web
更改脚本权限 chmod 775 /etc/init.d/nginxsql
二. MySQL开机启动
将mysql安装目录下 support-files目录下的mysql.server文件拷贝到/etc/init.d/目录下并更名为mysqld,并更改权限
chmod 775 /etc/init.d/mysqldbash
三. PHP开机启动php-fpm
PHP-FPM SHELL脚本 放到/etc/init.d/下 取名php-fpm,this
- php_command=/usr/local/php/sbin/php-fom
- php_config=/usr/local/php/etc/php-fpm.conf
根据你的安装路径去改spa
- #!/bin/bash
- # php-fpm startup script for the php-fpm
- # php-fpm version:5.5.0-alpha6
- # chkconfig: - 85 15
- # description: php-fpm is very good
- # processname: php-fpm
- # pidfile: /var/run/php-fpm.pid
- # config: /usr/local/php/etc/php-fpm.conf
-
- php_command=/usr/local/php/sbin/php-fom
- php_config=/usr/local/php/etc/php-fpm.conf
- php_pid=/usr/local/php/var/run/php-fpm.pid
- RETVAL=0
- prog="php-fpm"
-
- #start function
- php_fpm_start() {
- /usr/local/php/sbin/php-fpm
- }
-
- start(){
- if [ -e $php_pid ]
- then
- echo "php-fpm already start..."
- exit 1
- fi
- php_fpm_start
- }
-
- stop(){
- if [ -e $php_pid ]
- then
- parent_pid=`cat $php_pid`
- all_pid=`ps -ef | grep php-fpm | awk '{if('$parent_pid' == $3){print $2}}'`
- for pid in $all_pid
- do
- kill $pid
- done
- kill $parent_pid
- fi
- exit 1
- }
-
- restart(){
- stop
- start
- }
-
- # See how we were called.
- case "$1" in
- start)
- start
- ;;
- stop)
- stop
- ;;
- restart)
- stop
- start
- ;;
- status)
- status $prog
- RETVAL=$?
- ;;
- *)
- echo $"Usage: $prog {start|stop|restart|status}"
- exit 1
- esac
- exit $RETVAL
使用chkconfig进行管理.net
- chkconfig --add /etc/init.d/nginx
- chkconfig --add /etc/init.d/mysqld
- chkconfig --add /etc/init.d/php -fpm
设置终端模式开机启动:
- chkconfig php-fpm on
- chkconfig nginx on
- chkconfig mysqld on