码迷,mamicode.com
首页 > 数据库 > 详细

cenOS系统,chkconfig设置程序开机自启--mysql、tomcat、redis、fastdfs--nginx/fdfs_trackerd/fdfs_storaged

时间:2014-07-16 18:41:09      阅读:1427      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   http   java   color   

设置程序开机启动就是将程序的启动脚本添加到/etc/init.d目录下,或者将启动路径写入/etc/rc.d/rc.local文件里面.

设置mysql开机启动

cp /usr/local/mysql/support-files/mysql.server  /etc/init.d/mysql   
chkconfig --add mysql  
chkconfig  mysql  on

设置fdfs_tracker开机启动

cp /usr/local/src/FastDFS/init.d/fdfs_trackerd /etc/init.d/
chkconfig --add fdfs_trackerd
chkconfig fdfs_trackerd on

设置fdfs_storafed开机启动

cp /usr/local/src/FastDFS/init.d/fdfs_storaged /etc/init.d/
chkconfig --add fdfs_storaged
chkconfig fdfs_storaged on

 设置redis开机启动

cp  /usr/local/src/redis-stable/utils
./install_server.sh 

具体配置可以详见http://www.open-open.com/lib/view/open1355055890117.html

设置tomcat开机启动

在startup.sh文件中添加如下内容

vim  /usr/local/tomcat/bin/startup.sh
i            //代表进入文档输入模式
#!/bin/sh                 //#不能少
# chkconfig: 2345 97 00  
# description:tomcat auto start
# processname: tomcat

 在catalina.sh文件中增加如下内容

vim  /usr/local/tomcat/bin/catalina.sh
i                                                //进入输入模式
export CATALINA_BASE=/usr/local/tomcat          //根据实际情况填写路径
export CATALINA_HOME=/usr/local/tomcat         //根据实际情况填写路径
export CATALINA_TMPDIR=/usr/local/tomcat/temp  //根据实际情况填写路径
export JRE_HOME=/usr/java/jdk1.7.0_55
                                              //按esc键
:wq                                          //保存并退出

创建软连接

ln -s /usr/local/tomcat/bin/startup.sh /etc/init.d

 设置启动

chkconfig --add tomcat
chkconfig tomcat on

设置nginx开机启动

在/etc/init.d目录下新建nginx文档

vim /etc/init.c/ngin 

写入一下命令并保存

#!/bin/bash
# nginx Startup script for the Nginx HTTP Server
# it is v.0.0.2 version.
# chkconfig: - 85 15
# description: Nginx is a high-performance web and proxy server.
#              It has a lot of features, but its not for everyone.
# processname: nginx
# pidfile: /usr/local/nginx/logs/nginx.pid    //根据实际情况修改
# config: /usr/local/nginx/conf/nginx.conf     //根据实际情况修改
nginxd=/usr/local/nginx/sbin/nginx    //根据实际情况修改
nginx_config=/usr/local/nginx/conf/nginx.conf    //根据实际情况修改
nginx_pid=/usr/local/nginx/logs/nginx.pid    //根据实际情况修改
RETVAL=0
prog="nginx"
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0
[ -x $nginxd ] || exit 0
# Start nginx daemons functions.
start() {
if [ -e $nginx_pid ];then
   echo "nginx already running...."
   exit 1
fi
   echo -n $"Starting $prog: "
   daemon $nginxd -c ${nginx_config}
   RETVAL=$?
   echo
   [ $RETVAL = 0 ] && touch /var/lock/subsys/nginx
   return $RETVAL
}
# Stop nginx daemons functions.
stop() {
        echo -n $"Stopping $prog: "
        killproc $nginxd
        RETVAL=$?
        echo
        [ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx  /usr/local/nginx/logs/nginx.pid    //根据实际情况修改
}
# reload nginx service functions.
reload() {
    echo -n $"Reloading $prog: "
    #kill -HUP `cat ${nginx_pid}`
    killproc $nginxd -HUP
    RETVAL=$?
    echo
}
# See how we were called.
case "$1" in
start)
        start
        ;;
stop)
        stop
        ;;
reload)
        reload
        ;;
restart)
        stop
        start
        ;;
status)
        status $prog
        RETVAL=$?
        ;;
*)
        echo $"Usage: $prog {start|stop|restart|reload|status|help}"
       exit 1
esac
exit $RETVAL

 设置开启启动

chkconfig --add  nginx
chkconfig nginx on

 

 

cenOS系统,chkconfig设置程序开机自启--mysql、tomcat、redis、fastdfs--nginx/fdfs_trackerd/fdfs_storaged,布布扣,bubuko.com

cenOS系统,chkconfig设置程序开机自启--mysql、tomcat、redis、fastdfs--nginx/fdfs_trackerd/fdfs_storaged

标签:des   style   blog   http   java   color   

原文地址:http://www.cnblogs.com/lanyufei/p/3844913.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!