Centos 6.3设置php、mysql、nginx开机自启动

vim /etc/init.d/nginx

输入如下nginx脚本:

#!/bin/bash
#
# chkconfig: - 85 15
# description: Nginx is a World Wide Web server.
# processname: nginx

nginx=/app/nginx/sbin/nginx   #这里/app/是nginx安装路径
conf=/app/nginx/conf/nginx.conf
case $1 in
start)
echo -n "Starting Nginx"
$nginx -c $conf
echo " done"
;;
stop)
echo -n "Stopping Nginx"
killall -9 nginx
echo " done"
;;
test)
$nginx -t -c $conf
;;
reload)
echo -n "Reloading Nginx"
ps auxww | grep nginx | grep master | awk '{print $2}' | xargs kill -HUP
echo " done"
;;
restart)
$0 stop
$0 start
;;
show)
ps -aux|grep nginx
;;
*)
echo -n "Usage: $0 {start|restart|reload|stop|test|show}"
;;
esac

保存,再用命令

chmod +x /etc/init.d/nginx
chkconfig nginx on

开启nginx自动启动。

cp -f sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
#从php压缩包里复制init.d.php-fpm 到/etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
chkconfig php-fpm on

cp -f support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
chkconfig mysqld on
posted @ 2012-11-19 13:54  黄丁丁  阅读(499)  评论(0)    收藏  举报