nginxServer.sh 656 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #!/bin/bash
  2. NGINX_HOME="/usr/local/nginx"
  3. start(){
  4. nohup $NGINX_HOME/sbin/nginx >$NGINX_HOME/logs/nohup.out 2>&1 &
  5. }
  6. stop(){
  7. nohup $NGINX_HOME/sbin/nginx -s stop >$NGINX_HOME/logs/nohup.out 2>&1 &
  8. }
  9. reload(){
  10. nohup $NGINX_HOME/sbin/nginx -s reload >$NGINX_HOME/logs/nohup.out 2>&1 &
  11. }
  12. restart(){
  13. stop
  14. start
  15. }
  16. main(){
  17. case $1 in
  18. start)
  19. start
  20. echo "nginx start!"
  21. ;;
  22. stop)
  23. stop
  24. echo "nginx stop!"
  25. ;;
  26. restart)
  27. restart
  28. echo "nginx restart!"
  29. ;;
  30. reload)
  31. reload
  32. echo "nginx reload!"
  33. ;;
  34. *)
  35. echo "unknow command $1, usage ./nginxServer.sh [start|stop|restart|reload]"
  36. esac
  37. exit 0
  38. }
  39. main $1