Last active
November 21, 2018 09:44
-
-
Save rcguy/69739b19e93759e80307 to your computer and use it in GitHub Desktop.
Installs LAMP and phpMyAdmin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# 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 | |
MYSQL_ROOT_PASS="root" | |
# 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', '127.0.0.1', '::1');" | |
Q2="DELETE FROM mysql.user WHERE User='';" | |
Q3="DELETE FROM mysql.db WHERE Db='test' OR Db='test\_%';" | |
SQL="${Q1}${Q2}${Q3}" | |
$MYSQL -uroot -p$MYSQL_ROOT_PASSWORD -e "$SQL" | |
# create php info page | |
cat >> /var/www/html/info.php <<EOF | |
<?php | |
phpinfo(); | |
?> | |
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