Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- # Install this PHP Version
- INSTALL_VERSION='7.3'
- # Script must be run as root
- if [[ $EUID -ne 0 ]]; then
- echo "Must be run as root"
- exit -1
- fi
- # Install needed linux packages
- echo "Installing required linux packages..."
- apt-get install -y \
- network-manager \
- libnss3-tools \
- jq \
- xsel \
- curl \
- zip \
- unzip \
- git
- if which php >/dev/null; then
- # Get the current PHP version
- PHP_VERSION=$(php -v | head -n 1 | cut -d " " -f 2 | cut -f1-2 -d".")
- echo "PHP $PHP_VERSION found"
- else
- echo "No PHP found"
- PHP_VERSION=0
- fi
- # Install PHP Version if different
- if [[ $PHP_VERSION != $INSTALL_VERSION ]]
- then
- # Check if there is a repo with it
- if [[ ! $(apt-cache search php$INSTALL_VERSION-cli) ]]
- then
- echo "Adding PHP $INSTALL_VERSION repository..."
- add-apt-repository ppa:ondrej/php -y
- apt-get update
- fi
- echo "Removing old PHP $PHP_VERSION..."
- apt-get purge 'php*' -y
- fi
- # Install PHP core
- echo "Installing core PHP..."
- apt-get install -y \
- php$INSTALL_VERSION-common \
- php$INSTALL_VERSION-cli \
- php$INSTALL_VERSION-fpm
- # Install PHP extensions
- echo "Installing PHP extensions..."
- apt-get install -y \
- php$INSTALL_VERSION-bcmath \
- php$INSTALL_VERSION-curl \
- php$INSTALL_VERSION-intl \
- php$INSTALL_VERSION-json \
- php$INSTALL_VERSION-mbstring \
- php$INSTALL_VERSION-mysql \
- php$INSTALL_VERSION-opcache \
- php$INSTALL_VERSION-readline \
- php$INSTALL_VERSION-xml \
- php$INSTALL_VERSION-zip
- # PHP mcrypt is not separate in some versions
- apt-get install -y php$INSTALL_VERSION-mcrypt > /dev/null 2>&1
- # Install nginx
- if [[ ! $(which -a nginx) ]]
- then
- echo "Installing nginx..."
- sudo apt-get install -y nginx
- fi
- # Install Dnsmasq
- if [[ ! $(which -a dnsmasq) ]]
- then
- echo "Installing Dnsmasq..."
- sudo apt-get install -y dnsmasq
- fi
- # Install inotify-tools
- echo "Installing inotify-tools..."
- sudo apt-get install -y inotify-tools > /dev/null 2>&1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement