Skip to content

Instantly share code, notes, and snippets.

@ArielBarkan
Forked from aamnah/lamp.sh
Last active December 11, 2019 20:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ArielBarkan/8ae0862252364129e569ec241bc02572 to your computer and use it in GitHub Desktop.
Save ArielBarkan/8ae0862252364129e569ec241bc02572 to your computer and use it in GitHub Desktop.
Bash script to install Apache2,php5.6,php5.6-curl,php5.6-gd,php5.6-mbstring,php5.6-mcrypt,php5.6-mysql,mysql-server,phpmyadmin,Enable mod_rewrite on apache,Executing \"apt-get -f \install\" to unmet dependencies,Apply permissions on \/var\/www\/ directory \&subdirectories,Adding EXISTING user to www-data group (optional),Turn EXISTING user to ww…
#!/bin/bash
#######################################
# Based on script written by @AamnahAkram from http://aamnah.com
# Original Script at: https://gist.github.com/aamnah/f03c266d715ed479eb46#file-lamp-sh-L2
#######################################
# Written by @ArielBarkan from https://peekapost.com
#
# Bash script to install:
#- Apache2
#- php5.6
# > Adding PHP5.6 repository
# > Executing apt-get update
# > Installing PHP 5.6
#- php5.6-curl
#- php5.6-gd
#- php5.6-mbstring
#- php5.6-mcrypt
#- php5.6-mysql
#- mysql-server
#- phpmyadmin
#- Enable mod_rewrite on apache
#- Executing \"apt-get -f \install\" to unmet dependencies
#- Apply permissions on \/var\/www\/ directory \& sub directories
#- Adding EXISTING user to www-data group (optional)
#- Turn EXISTING user to www-data group owner(optional)
#- Restart apache
#
# This bash script was writen according to my project needs, Feel free to modify, improve and seen me feedback
#
########################################
#COLORS
# Reset
Color_Off='\033[0m' # Text Reset
# Regular Colors
Red='\033[0;31m' # Red
Green='\033[0;32m' # Green
Yellow='\033[0;33m' # Yellow
Purple='\033[0;35m' # Purple
Cyan='\033[0;36m' # Cyan
echo -e "$Cyan \n "+++++++++++++++++++++++++++++++
echo -e "$Cyan \n "This script will perform the following:
echo -e "$Cyan \n "- Apache2
echo -e "$Cyan \n "- php5.6
echo -e "$Cyan \n " \> Adding PHP5.6 repository
echo -e "$Cyan \n " \> Executing apt-get update
echo -e "$Cyan \n " \> Installing PHP 5.6
echo -e "$Cyan \n "- php5.6-curl
echo -e "$Cyan \n "- php5.6-gd
echo -e "$Cyan \n "- php5.6-mbstring
echo -e "$Cyan \n "- php5.6-mcrypt
echo -e "$Cyan \n "- php5.6-mysql
echo -e "$Cyan \n "- mysql-server
echo -e "$Cyan \n "- phpmyadmin
echo -e "$Cyan \n "- Enable mod_rewrite on apache
echo -e "$Cyan \n "- Executing \"apt-get -f \install\" to unmet dependencies
echo -e "$Cyan \n "- Apply permissions on \/var\/www\/ directory \& sub directories
echo -e "$Cyan \n "- Adding EXISTING user to www-data group (optional)
echo -e "$Cyan \n "- Turn EXISTING user to www-data group owner(optional)
echo -e "$Cyan \n "- Restart apache
echo -e "$Cyan \n "+++++++++++++++++++++++++++++++" $Color_Off"
echo -e "$Red \n "Pay attention to error messages or actions required from your side" $Color_Off"
echo -e "$Yellow \n "Press any key to proceed or CTRL+C to stop this script" $Color_Off"
read -p ""
echo -e "$Cyan \n "Update packages and Upgrade system" $Color_Off"
sudo apt-get update -y && sudo apt-get upgrade -y
echo -e "$Cyan \n "Installing apache2" $Color_Off"
sudo apt install apache2 -y
echo -e "$Cyan \n "Installing php5.6" $Color_Off"
echo -e "$Cyan \n " \> Adding PHP5.6 repository" $Color_Off"
sudo add-apt-repository ppa:ondrej/php
echo -e "$Cyan \n " \> Executing apt-get update" $Color_Off"
sudo apt-get update
echo -e "$Cyan \n " \> Installing PHP 5.6" $Color_Off"
sudo apt-get install php5.6 -y
echo -e "$Cyan \n "Installing php5.6-curl" $Color_Off"
sudo apt install php5.6-curl -y
echo -e "$Cyan \n "Installing php5.6-gd" $Color_Off"
sudo apt install php5.6-gd -y
echo -e "$Cyan \n "Installing php5.6-mbstring" $Color_Off"
sudo apt install php5.6-mbstring -y
echo -e "$Cyan \n "Installing php5.6-mcrypt" $Color_Off"
sudo apt install php5.6-mcrypt -y
echo -e "$Cyan \n "Installing php5.6-mysql" $Color_Off"
sudo apt install php5.6-mysql -y
echo -e "$Cyan \n "Installing mysql-server" $Color_Off"
sudo apt install mysql-server -y
echo -e "$Cyan \n "Installing phpmyadmin" $Color_Off"
sudo apt install phpmyadmin -y
echo -e "$Cyan \n "Enable mod_rewrite on apache" $Color_Off"
sudo a2enmod rewrite
echo -e "$Cyan \n "Performing \'apt-get -f install\' to unmet dependencies" $Color_Off"
sudo apt-get -f install
echo -e "$Cyan \n "Applying permissions on \/var\/www\/ directory \& sub directories" $Color_Off"
sudo chmod -R 775 /var/www/
while true; do
read -p "Do you want to add an EXISTING user to www-data group (y or n) : " yn
case $yn in
[Yy]* ) #yes
while true; do
read -p "Type the EXISTING user name : " unametoad
if [ -z "$unametoad" ]
then
echo "No argument supplied"
else
if (grep -q "$unametoad" /etc/passwd) ; then
echo -e "$Cyan \n "Adding "$unametoad" to www-data group" $Color_Off"
sudo adduser "$unametoad" www-data
while true; do
read -p "Do you wish to make "$unametoad" owner of www-data group?" yn
case $yn in
[Yy]* )
echo -e "$Cyan \n "Making "$unametoad" owner of www-data group" $Color_Off"
sudo chown -R "$unametoad":www-data /var/www/
break 2;;
[Nn]* )
break 2;;
* ) echo "Please answer yes or no.";;
esac
done
else
echo "User "$unametoad" don't exists in your system"
fi
fi
done
break;;
[Nn]* ) #no
break;;
* ) echo "Please answer yes or no.";;
esac
done
echo -e "$Cyan \n "Restarting apache" $Color_Off"
sudo service apache2 restart
echo -e "$Green \n "-----------------------------
echo -e "$Green \n " End of script
echo -e "$Green \n "-----------------------------" $Color_Off"
#!/bin/bash
#######################################
# Based on script written by @AamnahAkram from http://aamnah.com
# Original Script at: https://gist.github.com/aamnah/f03c266d715ed479eb46#file-lamp-sh-L2
#######################################
# Written by @ArielBarkan from https://peekapost.com
#
# Bash script to install:
#- Apache2
#- php7.2
# > Adding PHP7.2 repository
# > Executing apt-get update
# > Installing PHP 7.2
#- php7.2-curl
#- php7.2-gd
#- php7.2-mbstring
#- php7.2-mcrypt
#- php7.2-mysql
#- mysql-server
#- phpmyadmin
#- Enable mod_rewrite on apache
#- Executing \"apt-get -f \install\" to unmet dependencies
#- Apply permissions on \/var\/www\/ directory \& sub directories
#- Adding EXISTING user to www-data group (optional)
#- Turn EXISTING user to www-data group owner(optional)
#- Restart apache
#
# This bash script was writen according to my project needs, Feel free to modify, improve and seen me feedback
#
########################################
#COLORS
# Reset
Color_Off='\033[0m' # Text Reset
# Regular Colors
Red='\033[0;31m' # Red
Green='\033[0;32m' # Green
Yellow='\033[0;33m' # Yellow
Purple='\033[0;35m' # Purple
Cyan='\033[0;36m' # Cyan
echo -e "$Cyan \n "+++++++++++++++++++++++++++++++
echo -e "$Cyan \n "This script will perform the following:
echo -e "$Cyan \n "- Apache2
echo -e "$Cyan \n "- php7.2
echo -e "$Cyan \n " \> Adding PHP7.2 repository
echo -e "$Cyan \n " \> Executing apt-get update
echo -e "$Cyan \n " \> Installing PHP 7.2
echo -e "$Cyan \n "- php7.2-curl
echo -e "$Cyan \n "- php7.2-gd
echo -e "$Cyan \n "- php7.2-mbstring
echo -e "$Cyan \n "- php7.2-mcrypt
echo -e "$Cyan \n "- php7.2-mysql
echo -e "$Cyan \n "- mysql-server
echo -e "$Cyan \n "- phpmyadmin
echo -e "$Cyan \n "- Enable mod_rewrite on apache
echo -e "$Cyan \n "- Executing \"apt-get -f \install\" to unmet dependencies
echo -e "$Cyan \n "- Apply permissions on \/var\/www\/ directory \& sub directories
echo -e "$Cyan \n "- Adding EXISTING user to www-data group (optional)
echo -e "$Cyan \n "- Turn EXISTING user to www-data group owner(optional)
echo -e "$Cyan \n "- Restart apache
echo -e "$Cyan \n "+++++++++++++++++++++++++++++++" $Color_Off"
echo -e "$Red \n "Pay attention to error messages or actions required from your side" $Color_Off"
echo -e "$Yellow \n "Press any key to proceed or CTRL+C to stop this script" $Color_Off"
read -p ""
echo -e "$Cyan \n "Update packages and Upgrade system" $Color_Off"
sudo apt-get update -y && sudo apt-get upgrade -y
echo -e "$Cyan \n "Installing apache2" $Color_Off"
sudo apt install apache2 -y
echo -e "$Cyan \n "Installing php7.2" $Color_Off"
echo -e "$Cyan \n " \> Adding PHP7.2 repository" $Color_Off"
sudo add-apt-repository ppa:ondrej/php
echo -e "$Cyan \n " \> Executing apt-get update" $Color_Off"
sudo apt-get update
echo -e "$Cyan \n " \> Installing PHP 7.2" $Color_Off"
sudo apt-get install php7.2 -y
echo -e "$Cyan \n "Installing php7.2-curl" $Color_Off"
sudo apt install php7.2-curl -y
echo -e "$Cyan \n "Installing php7.2-gd" $Color_Off"
sudo apt install php7.2-gd -y
echo -e "$Cyan \n "Installing php7.2-mbstring" $Color_Off"
sudo apt install php7.2-mbstring -y
echo -e "$Cyan \n "Installing php7.2-mcrypt" $Color_Off"
sudo apt install php7.2-mcrypt -y
echo -e "$Cyan \n "Installing php7.2-mysql" $Color_Off"
sudo apt install php7.2-mysql -y
echo -e "$Cyan \n "Installing mysql-server" $Color_Off"
sudo apt install mysql-server -y
echo -e "$Cyan \n "Installing phpmyadmin" $Color_Off"
sudo apt install phpmyadmin -y
echo -e "$Cyan \n "Enable mod_rewrite on apache" $Color_Off"
sudo a2enmod rewrite
echo -e "$Cyan \n "Performing \'apt-get -f install\' to unmet dependencies" $Color_Off"
sudo apt-get -f install
echo -e "$Cyan \n "Applying permissions on \/var\/www\/ directory \& sub directories" $Color_Off"
sudo chmod -R 775 /var/www/
while true; do
read -p "Do you want to add an EXISTING user to www-data group (y or n) : " yn
case $yn in
[Yy]* ) #yes
while true; do
read -p "Type the EXISTING user name : " unametoad
if [ -z "$unametoad" ]
then
echo "No argument supplied"
else
if (grep -q "$unametoad" /etc/passwd) ; then
echo -e "$Cyan \n "Adding "$unametoad" to www-data group" $Color_Off"
sudo adduser "$unametoad" www-data
while true; do
read -p "Do you wish to make "$unametoad" owner of www-data group?" yn
case $yn in
[Yy]* )
echo -e "$Cyan \n "Making "$unametoad" owner of www-data group" $Color_Off"
sudo chown -R "$unametoad":www-data /var/www/
break 2;;
[Nn]* )
break 2;;
* ) echo "Please answer yes or no.";;
esac
done
else
echo "User "$unametoad" don't exists in your system"
fi
fi
done
break;;
[Nn]* ) #no
break;;
* ) echo "Please answer yes or no.";;
esac
done
echo -e "$Cyan \n "Restarting apache" $Color_Off"
sudo service apache2 restart
echo -e "$Green \n "-----------------------------
echo -e "$Green \n " End of script
echo -e "$Green \n "-----------------------------" $Color_Off"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment