Last active
August 5, 2021 08:57
-
-
Save Senpai-Codes/9f32740319f0c5b906acff7cdf4a19e8 to your computer and use it in GitHub Desktop.
Install LAMP on Ubuntu 20.04 under WSL2
This file contains hidden or 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/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; |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
cd ~
wget https://gist.githubusercontent.com/Senpai-Codes/9f32740319f0c5b906acff7cdf4a19e8/raw/6bea09d34a72b79a3b9f4c459bdbaea7105413e9/wsl2-lamp.sh
chmod -x ./wsl2-lamp.sh
bash ./wsl2-lamp.sh