Linux shell reads every day--install Nginx

Source: Internet
Author: User

Of course this blog original code is reproduced great God's ...

Automatically install Nginx script, use case mode, choose the way, you can change to the actual needs of the script you want mynginx.sh

  1. #!/bin/sh
  2. # # #nginx Install Shell
  3. # # #wugk 2012-07-14
  4. # # #PATH DEFINE
  5. soft_path=/data/soft/
  6. Nginx_file=nginx-1.2.0.tar.gz
  7. Down_path=http://nginx.org/download/
  8. if[$UID-ne 0];then
  9. echo this script must with administrator or root user, please exit!
  10. Sleep 2
  11. Exit 0
  12. Fi
  13. if[!-D $SOFT _path];then
  14. Mkdir-p $SOFT _path
  15. Fi
  16. Download ()
  17. {
  18. CD $SOFT _path, wget $DOWN _path/$NGINX _file
  19. }
  20. Install ()
  21. {
  22. Yum Install Pcre-devel-y
  23. CD $SOFT _path; tar xzf $NGINX _file; CD nginx-1.2.0/&&./configure–prefix=/usr/local/nginx/–with-http_stub_ Status_module–with-http_ssl_module
  24. [$?-eq 0]&&make &&make Install #[] conditions can be used to determine
  25. }
  26. Start ()
  27. {
  28. Lsof-i: 80[$?-ne 0]&&/usr/local/nginx/sbin/nginx #lsof-i: 80//Show all processes that open 80 ports
  29. }
  30. Stop ()
  31. {
  32. Ps-ef |grep nginx |grep-v grep |awk ' {print $} ' |xargs kill-9 #本文最nice的一个就是用了xargs这个命令, the output from the previous command as a parameter to the next command
  33. }
  34. Exit ()
  35. {
  36. echo $?; exit
  37. }
  38. # # #case Menu #####
  39. Case $ in
  40. Download)
  41. Download
  42. ;;
  43. Install)
  44. Install
  45. ;;
  46. Start)
  47. Start
  48. ;;
  49. Stop)
  50. Stop
  51. ;;
  52. * )
  53. echo "usage:$0 {Download or install or start or stop}"
  54. Exit
  55. Esac

Script execution:

./mynginx.sh Download

./mynginx.sh Install

./mynginx.sh start

./mynginx.sh Stop

Linux shell reads every day--install Nginx

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.