-
-
Save armohamm/0fc2da35826f083d18be103e0ba6d903 to your computer and use it in GitHub Desktop.
Auto basic LAMP installation for Ubuntu 18.04 (Apache2, MySql, PHP7.3)
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 | |
###################################################### | |
# AUTO LAMP INSTALLATION # | |
# Written by Gil Shwartz # | |
# gilshwartzdjgs@gmail.com # | |
###################################################### | |
clear | |
echo "#######################################################" | |
if (( $EUID != 0 )); then | |
echo "[!] This script requires root privileges in order" | |
echo " to be able to write to /var/www/html/" | |
echo " Please run as root." | |
echo "#######################################################" | |
exit | |
fi | |
echo "This will install Apache2, MySql and PHP7.3" | |
echo "Please make sure that the system is updated." | |
echo "apt-get update && apt-get upgrade" | |
echo "#######################################################" | |
echo -n "Is the system fully updated? [Y/n]? " | |
read -n1 update | |
if [[ "$update" = "Y" || "$update" = "y" ]] | |
then | |
echo | |
echo "Installing apache2..." | |
sleep 3s | |
sudo apt install apache2 -y | |
sudo systemctl start apache2 | |
sudo systemctl enable apache2 | |
sudo systemctl status apache2 --no-pager | |
echo | |
echo "DONE!" | |
sleep 1s | |
echo | |
echo "Installing MySql Database Server..." | |
sleep 1s | |
sudo apt install mysql-server mysql-client -y | |
sudo systemctl status mysql --no-pager | |
sudo systemctl enable mysql | |
sleep 1s | |
clear | |
echo "Installing MySql Security script..." | |
sudo mysql_secure_installation | |
sleep 2s | |
echo "Installing PHP7.3 Repository..." | |
sleep 2s | |
yes '' | sudo add-apt-repository ppa:ondrej/php | |
echo "Updating system..." | |
sleep 1s | |
sudo apt-get update | |
echo "Installing PHP7.3..." | |
sleep 2s | |
sudo apt install php7.3 php7.3-mysql libapache2-mod-php7.3 -y | |
echo "DONE!" | |
sleep 2s | |
echo "Restarting apache2 service..." | |
sudo systemctl restart apache2 | |
sleep 1s | |
#Manipulating the default file: | |
echo "Updating config..." | |
sudo chown www-data:www-data /var/www/html/ | |
sudo sed -i 's/index.html/index.html index.php/' /etc/apache2/mods-enabled/dir.conf | |
echo "<?php" >> /var/www/html/info.php | |
echo " phpinfo();" >> /var/www/html/info.php | |
echo "?>" >> /var/www/html/info.php | |
sudo systemctl restart apache2 | |
sleep 1s | |
echo "DONE!" | |
echo "##############################################################" | |
echo "Installation Complete!" | |
echo "You can log into your <IP address>/info.php" | |
echo "[!]Please note that this is the very basic installation." | |
echo "[!]Don't forget to LOGOUT from root![!]" | |
echo "##############################################################" | |
echo | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment