nginxServer.sh 651 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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