8个月前 (05-03)  Linux安全运维    抢沙发
文章评分 0 次,平均分 0.0

一、传统模式下Nginx的启动、关闭

1、启动:/usr/local/nginx/sbin/nginx
2、关闭:killall nginx
3、重启:/usr/local/nginx/sbin/nginx -s reload

二、通过配置/etc/init.d/nginx来管理Nginx

#!/bin/bash  
# nginx Startup script for the Nginx HTTP Server  
nginxd=/usr/local/nginx/sbin/nginx  
nginx_config=/usr/local/nginx/conf/nginx.conf  
nginx_pid=/var/run/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 /var/run/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  

保存并添加执行权限

service nginx start    //启动Nginx
service nginx stop    //关闭Nginx
service nginx restart  //重启Nginx
service nginx status  //查看Nginx的状态

添加至开机启动
chkconfig --add nginx
chkconfig nginx on

三、传统Tomcat的开启、关闭

1、启动:/usr/local/apache-tomcat-9.0.7/bin/startup.sh
2、关闭:/usr/local/apache-tomcat-9.0.7/bin/shutdown.sh

四、配置/etc/init.d/tomcat管理Tomcat

# tomcat startup script for the Tomcat server  
. /etc/rc.d/init.d/functions

prog=tomcat
JAVA_HOME=/usr/local/java/
export JAVA_HOME  
CATALANA_HOME=/usr/local/apache-tomcat-9.0.7/
export CATALINA_HOME  

case "$1" in
start)
    echo "Starting Tomcat..."  
    $CATALANA_HOME/bin/startup.sh
    ;;

stop)
    echo "Stopping Tomcat..."  
    $CATALANA_HOME/bin/shutdown.sh
    ;;

restart)
    echo "Stopping Tomcat..."  
    $CATALANA_HOME/bin/shutdown.sh
    sleep 2
    echo  
    echo "Starting Tomcat..."  
    $CATALANA_HOME/bin/startup.sh
    ;;

*)
    echo "Usage: $prog {start|stop|restart}"  
    ;;
esac
exit 0

service tomcat start
service tomcat stop
service tomcat restart

chkconfig --add tomcat
chkconfig tomcat on

 


//下面这个css和插件后台设置的主题有关系,如果需要换样式,则需要修改以下CSS名称

  原文:http://blog.51cto.com/gdutcxh/2109877

发表评论

暂无评论

切换注册

登录

忘记密码 ?

您也可以使用第三方帐号快捷登录

切换登录

注册

扫一扫二维码分享