Skip to content

Instantly share code, notes, and snippets.

@scriptburn
Last active February 18, 2020 13:57
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scriptburn/9ba0a1dae87e8900cd4eeb02be0c9544 to your computer and use it in GitHub Desktop.
Save scriptburn/9ba0a1dae87e8900cd4eeb02be0c9544 to your computer and use it in GitHub Desktop.
Install php7.2 apache2 mysql pgsql debian 9
#!/usr/bin/env bash
cecho() {
declare -A colors
colors=(
['black']='\E[0;47m'
['red']='\E[0;31m'
['green']='\E[0;32m'
['yellow']='\E[0;33m'
['blue']='\E[0;34m'
['magenta']='\E[0;35m'
['cyan']='\E[0;36m'
['white']='\E[0;37m'
)
local defaultMSG="No message passed."
local defaultColor="black"
local defaultNewLine=true
while [[ $# -gt 1 ]]; do
key="$1"
case $key in
-c | --color)
color="$2"
shift
;;
-n | --noline)
newLine=false
;;
*)
# unknown option
;;
esac
shift
done
message=${1:-$defaultMSG}
color=${color:-$defaultColor}
newLine=${newLine:-$defaultNewLine}
echo -en "${colors[$color]}"
echo -en "$message"
if [ "$newLine" = true ]; then
echo
fi
tput sgr0
return
}
warning() {
cecho -c 'yellow' "$1"
}
error() {
cecho -c 'red' "$1"
}
information() {
cecho -c 'blue' "$1"
}
success() {
cecho -c 'green' "$1"
}
information "Starting update\n"
sudo apt update -y
sudo apt upgrade -y
sudo apt install -y ca-certificates apt-transport-https
information "\nInstalling git\n"
sudo apt -y install git
information "\nInstalling mariadb\n"
sudo apt-get -y install mariadb-server mariadb-client
sudo systemctl start mysql
information "\Configuring mariadb\n"
sudo mysql -e "UPDATE mysql.user SET Password = PASSWORD('root') WHERE User = 'root'"
# Kill the anonymous users
sudo mysql -e "DROP USER ''@'localhost'"
# Because our hostname varies we'll use some Bash magic here.
sudo mysql -e "DROP USER ''@'$(hostname)'"
# Kill off the demo database
sudo mysql -e "DROP DATABASE IF EXISTS test"
# Make our changes take effect
sudo mysql -e "FLUSH PRIVILEGES"
information "\nInstalling lynx\n"
sudo apt install -y lynx
information "\nInstalling apache\n"
sudo apt-get -y install apache2
sudo a2enmod rewrite
sudo systemctl restart apache2
information "\nInstalling php\n"
sudo apt-get install apt-transport-https lsb-release ca-certificates
sudo 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" | sudo tee /etc/apt/sources.list.d/php.list
sudo apt install -y php7.2
sudo apt install -y php7.2-cli php7.2-common php7.2-curl php7.2-gd php7.2-json php7.2-mbstring php7.2-mysql php7.2-xml php7.2-zip php7.2-curl php-pgsql libapache2-mod-php
information "\nInstalling zip\n"
sudo apt install -y zip unzip
information "\nInstalling composer\n"
sudo apt install -y composer
information "\nInstalling postgresql\n"
sudo apt install -y postgresql libpq5 postgresql-client postgresql-client-common postgresql-contrib
sudo apt install -y pgadmin3
information "\nConfiguring postgresql\n"
sudo -u postgres psql -c "ALTER USER postgres PASSWORD 'postgres';"
sudo service postgresql restart
success "\nDone\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment