Wrote a little snippet at work today for anyone who might need to get a LAMP environment set up fast for a dev environment. Works perfect for me for one off virtual machines I am doing testing in.

#!/bin/bash
# EZ-LAMP
# by Alex Rydzak <[email protected]>

# Defining functions here...
# ==================================================================================================
art() {

cat <<"EOT"

	       .    |    ,
	        \ _---_ /
	     -_ .'     `. _-
	    __ :  .---.  : __
	       :  \   /  :
	     -" `. | | .' "-
	        / |`-'| \
	          ]"-_[  
	           "*"
  ___ ____   _      _   __  __ ___ 
 | __|_  /__| |    /_\ |  \/  | _ \
 | _| / /___| |__ / _ \| |\/| |  _/
 |___/___|  |____/_/ \_\_|  |_|_| 
	
EOT
}
# End of functions here...
# ==================================================================================================
clear
art
echo -e "================================================================================"
echo -e "                        Let's get our test and dev on!"
echo -e "================================================================================"
echo ""
echo -e "[*] Starting user level check..."
    if [ $UID -ne 0 ]; 
    then
        echo -e "[!] Non-root user. Please restart the script as root."
        exit 
    else
        echo -e "[*] Ok, I am running as the root user. Movin' on."
    fi
echo -e "[*] Starting internet connectivity test..."
    if ping -c 5 google.com | grep timeout;
    then 
        echo -e "[!] Hmm, can't seem to connect to Internet. Try me again later perhaps."
        exit
    else
        echo -e "[*] Ok, I can get out to the internet."
        echo -e "[*] Updating system packages."
        apt-get -qy update > /dev/null
		apt-get -qy upgrade > /dev/null
		apt-get -qy dist-upgrade > /dev/null
		echo -e "[*] Ok, packages updated successfully."
    fi
echo -e "[*] Installing package 'wget'"
sudo apt-get -qy install wget > /dev/null
echo -e "[*] Installing package 'git'"
sudo apt-get -qy install git > /dev/null
echo -e "[*] Installing package 'openssh-server'"
sudo apt-get -qy install openssh-server > /dev/null
echo -e "[*] Installing package 'apache2'"
sudo apt-get -qy install apache2 > /dev/null
echo -e "[*] Apache web server IP address is:"
ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'
echo -e "[*] Installing package 'mysql-server'"
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password XXXXXXXXX'
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password XXXXXXXXX'
sudo apt-get -qy install mysql-server > /dev/null
echo -e "[*] Installing package 'libapache2-mod-auth'"
sudo apt-get -qy install libapache2-mod-auth-mysql > /dev/null
echo -e "[*] Installing package 'php5-mysql'"
sudo apt-get -qy install php5-mysql > /dev/null
echo -e "[*] Running 'mysql_install_db'"
sudo mysql_install_db > /dev/null
echo -e "[*] Installing package 'php5'"
sudo apt-get -qy install php5 > /dev/null
echo -e "[*] Installing package 'libapache2-mod-php5'"
sudo apt-get -qy install libapache2-mod-php5 > /dev/null 
echo -e "[*] Installing package 'php5-mcrypt'"
sudo apt-get -qy install php5-mcrypt > /dev/null
echo -e "[*] restarting Apache to apply settings."
sudo service apache2 restart > /dev/null
echo -e "[!] NOTE: mysql_secure_installation has NOT BEEN RUN, do not use this for a production machine."
echo -e "================================================================================"
echo -e "                        		END OF SCRIPT REACHED"
echo -e "================================================================================"
Scroll to Top