Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Installs LAMP and phpMyAdmin
# Installs LAMP and phpmyadmin on Ubuntu 14.10
# Tested on: Ubuntu Server 14.10 - x64 + x86 / 2 Cores / 2GB RAM / 20 GB SSD / VPS
# ==> MAIN PROGRAM <==
set -e
# mysql variables
# pre-seed mysql root password
echo "mysql-server-5.5 mysql-server/root_password password $MYSQL_ROOT_PASS" | sudo debconf-set-selections
echo "mysql-server-5.5 mysql-server/root_password_again password $MYSQL_ROOT_PASS" | sudo debconf-set-selections
# upgrades
apt-get update
apt-get upgrade -y
apt-get autoremove -y
apt-get autoclean -y
# install the LAMP stack with phpmyadmin
apt-get install apache2 mysql-server mysql-client libapache2-mod-auth-mysql php5 php5-mysql php5-mcrypt php5-gd libapache2-mod-php5 phpmyadmin -y
# secure mysql
MYSQL=`which mysql`
Q1="DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '', '::1');"
Q2="DELETE FROM mysql.user WHERE User='';"
Q3="DELETE FROM mysql.db WHERE Db='test' OR Db='test\_%';"
# create php info page
cat >> /var/www/html/info.php <<EOF
# enable phpmyadmin
cp /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf
a2enconf phpmyadmin
service apache2 restart
# how to test
LOCAL_IP=$(ifconfig eth0 | grep "inet addr:" | cut -d':' -f 2 | awk '{print $1}')
echo -e "\nTest Apache2 at http://$LOCAL_IP and php5 at http://$LOCAL_IP/info.php\n"
# end
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment