Skip to content

Instantly share code, notes, and snippets.

@ZAYEC77
Last active August 16, 2018 23:23
Show Gist options
  • Save ZAYEC77/f1e1cdefd50e81f18f1d6a86839661fa to your computer and use it in GitHub Desktop.
Save ZAYEC77/f1e1cdefd50e81f18f1d6a86839661fa to your computer and use it in GitHub Desktop.
debian-server
#!/bin/bash
# debian 9+
# Install common stuff
apt-get install bc apt-transport-https lsb-release ca-certificates console-cyrillic git-core rsync python-setuptools python-dev build-essential -y
# Check if the PHP version is valid and install it
installPhp() {
# The current PHP Version of the machine
currentVersion=$(php --version | head -n 1 | cut -d " " -f 2 | cut -c 1,3);
# The version to validate against
minimumRequiredVersion=72;
# If the version match
if [ $(echo " $currentVersion >= $minimumRequiredVersion" | bc) -eq 1 ]; then
# Notify that the versions are matching
echo "PHP Version is valid ...";
else
# Else notify that the version are not matching
echo "PHP Version NOT valid for ${currentVersion} ...";
apt-get install apt-transport-https lsb-release ca-certificates
# Install php 7.2
wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/php.list
apt-get update
apt-get install php7.2 php7.2-cli php7.2-common php7.2-curl php7.2-gd php7.2-json php7.2-mbstring php7.2-mysql php7.2-opcache php7.2-readline php7.2-xml php7.2-zip php7.2-soap php7.2-intl php7.2-fpm
fi
}
installComposer() {
EXPECTED_SIGNATURE=$(wget -q -O - https://composer.github.io/installer.sig)
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
ACTUAL_SIGNATURE=$(php -r "echo hash_file('SHA384', 'composer-setup.php');")
if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ]
then
>&2 echo 'ERROR: Invalid installer signature'
rm composer-setup.php
exit 1
fi
php composer-setup.php --filename=composer --install-dir=/usr/bin
rm composer-setup.php
composer global require "hirak/prestissimo"
}
installPercona() {
wget https://repo.percona.com/apt/percona-release_0.1-6.$(lsb_release -sc)_all.deb
dpkg -i percona-release_0.1-6.$(lsb_release -sc)_all.deb
apt-get update
apt-get install percona-server-server-5.7
rm percona-release_0.1-6.$(lsb_release -sc)_all.deb
}
createWwwDir() {
DIR=/var/www
mkdir -p $DIR
chmod -R 755 $DIR
chown -R www-data:www-data $DIR
}
installPhp
installComposer
installPercona
createWwwDir
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment