Skip to content

Instantly share code, notes, and snippets.

@Senpai-Codes
Last active August 5, 2021 08:57
Show Gist options
  • Select an option

  • Save Senpai-Codes/9f32740319f0c5b906acff7cdf4a19e8 to your computer and use it in GitHub Desktop.

Select an option

Save Senpai-Codes/9f32740319f0c5b906acff7cdf4a19e8 to your computer and use it in GitHub Desktop.
Install LAMP on Ubuntu 20.04 under WSL2
#!/bin/sh
#######################################
# Bash script to install an LAMP stack and PHPMyAdmin plus tweaks. For UBUNTU 20.04 under WSL2.
#######################################
#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
# Update packages and Upgrade system
echo -e "$Cyan \n Updating System.. $Color_Off"
sudo apt update -y && sudo apt upgrade -y
## Install LAMP
echo -e "$Cyan \n Installing Apache2 $Color_Off"
sudo apt install apache2 apache2-doc apache2-utils -y
sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt update -y
echo -e "$Cyan \n Installing PHP & Requirements $Color_Off"
sudo apt install libapache2-mod-php8.0 php8.0 php8.0-common php8.0-curl php8.0-dev php8.0-gd php8.0-imagick php8.0-mcrypt php8.0-mysql php8.0-pspell php8.0-xml php-json php-tokenizer php-ssh2 php-soap php-zip php-mbstring -y
echo -e "$Cyan \n Installing MySQL $Color_Off"
sudo apt install mysql-server mysql-client -y
echo -e "$Cyan \n Installing phpMyAdmin $Color_Off"
sudo apt install phpmyadmin -y
#sudo dpkg-reconfigure phpmyadmin
echo -e "$Cyan \n Verifying installs$Color_Off"
sudo apt install apache2 libapache2-mod-php php mysql-server php-pear php-mysql mysql-client mysql-server php-mysql php-gd -y
## TWEAKS and Settings
# Permissions
echo -e "$Cyan \n Permissions for /var/www $Color_Off"
sudo chown -R www-data:www-data /var/www
echo -e "$Green \n Permissions have been set $Color_Off"
# Enabling Mod Rewrite, required for WordPress permalinks and .htaccess files
echo -e "$Cyan \n Enabling Modules $Color_Off"
sudo a2enmod rewrite
sudo phpenmod mcrypt
# Restart Apache
echo -e "$Cyan \n Restarting Apache & Mysql $Color_Off"
sudo service apache2 restart
sudo service mysql restart
echo -e "$Cyan \n Create global DB user for phpmyadmin $Color_Off"
CREATE USER 'senpai'@'localhost' IDENTIFIED BY 'password_here';
GRANT ALL PRIVILEGES ON * . * TO 'senpai'@'localhost';
FLUSH PRIVILEGES;
quit;
@Senpai-Codes
Copy link
Author

Senpai-Codes commented Aug 5, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment