Nginx和Tomcat的管理脚本-linux安全运维_跨零代码

跨零代码为大家提供高品质的运维解决方案,请大家多多来访,跨零不胜感激,在此谢过。

一、传统模式下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名称

从零到一,创造未来!跨零代码综合IT问题解决服务站,欢迎你的到来。运维教程 只为你绽放。

本文固定链接: http://kua0.com/2019/02/02/nginx和tomcat的管理脚本-linux安全运维_跨零代码/

为您推荐

发表评论

电子邮件地址不会被公开。 必填项已用*标注