Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. # Install this PHP Version
  4. INSTALL_VERSION='7.3'
  5.  
  6. # Script must be run as root
  7. if [[ $EUID -ne 0 ]]; then
  8. echo "Must be run as root"
  9. exit -1
  10. fi
  11.  
  12. # Install needed linux packages
  13. echo "Installing required linux packages..."
  14. apt-get install -y \
  15. network-manager \
  16. libnss3-tools \
  17. jq \
  18. xsel \
  19. curl \
  20. zip \
  21. unzip \
  22. git
  23.  
  24. if which php >/dev/null; then
  25. # Get the current PHP version
  26. PHP_VERSION=$(php -v | head -n 1 | cut -d " " -f 2 | cut -f1-2 -d".")
  27. echo "PHP $PHP_VERSION found"
  28. else
  29. echo "No PHP found"
  30. PHP_VERSION=0
  31. fi
  32.  
  33. # Install PHP Version if different
  34. if [[ $PHP_VERSION != $INSTALL_VERSION ]]
  35. then
  36. # Check if there is a repo with it
  37. if [[ ! $(apt-cache search php$INSTALL_VERSION-cli) ]]
  38. then
  39. echo "Adding PHP $INSTALL_VERSION repository..."
  40. add-apt-repository ppa:ondrej/php -y
  41. apt-get update
  42. fi
  43.  
  44. echo "Removing old PHP $PHP_VERSION..."
  45. apt-get purge 'php*' -y
  46. fi
  47.  
  48. # Install PHP core
  49. echo "Installing core PHP..."
  50. apt-get install -y \
  51. php$INSTALL_VERSION-common \
  52. php$INSTALL_VERSION-cli \
  53. php$INSTALL_VERSION-fpm
  54.  
  55. # Install PHP extensions
  56. echo "Installing PHP extensions..."
  57. apt-get install -y \
  58. php$INSTALL_VERSION-bcmath \
  59. php$INSTALL_VERSION-curl \
  60. php$INSTALL_VERSION-intl \
  61. php$INSTALL_VERSION-json \
  62. php$INSTALL_VERSION-mbstring \
  63. php$INSTALL_VERSION-mysql \
  64. php$INSTALL_VERSION-opcache \
  65. php$INSTALL_VERSION-readline \
  66. php$INSTALL_VERSION-xml \
  67. php$INSTALL_VERSION-zip
  68.  
  69. # PHP mcrypt is not separate in some versions
  70. apt-get install -y php$INSTALL_VERSION-mcrypt > /dev/null 2>&1
  71.  
  72. # Install nginx
  73. if [[ ! $(which -a nginx) ]]
  74. then
  75. echo "Installing nginx..."
  76. sudo apt-get install -y nginx
  77. fi
  78.  
  79. # Install Dnsmasq
  80. if [[ ! $(which -a dnsmasq) ]]
  81. then
  82. echo "Installing Dnsmasq..."
  83. sudo apt-get install -y dnsmasq
  84. fi
  85.  
  86. # Install inotify-tools
  87. echo "Installing inotify-tools..."
  88. sudo apt-get install -y inotify-tools > /dev/null 2>&1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement