WSL2 LAMP setup notes

My desktop computers run Microsoft Windows, but in my job I manage Ubuntu Linux servers. Setting up a local dev environment under Windows is a bit of a pain, so I decided to give the Windows Subsystem for Linux (WSL2) a go, using the Ubuntu 20.04 LTS distribution.

To install the LAMP components:

sudo apt install lamp-server^

Start Apache2:

sudo service apache2 start

Setup MySQL:

sudo usermod -d /var/lib/mysql/ mysql 
sudo mysql_secure_installation
sudo service mysql start

Note that you need to access MySQL using sudo:

sudo mysql -u root -p

I then tried to install PHPMyAdmin:

sudo apt install phpmyadmin php-mbstring php-zip php-gd php-json php-curl

This is where I ran into difficulties, with the error trying to configure the PHPMyAdmin user:

ERROR 1819 (HY000) at line 1: Your password does not satisfy the current policy requirements

Apparently MySQL 8 has changed the authentication system and the Secure Installation script also causes issues. In the end I temporarily disabled the password validation:

mysql> UNINSTALL COMPONENT "file://component_validate_password";
Query OK, 0 rows affected (0.02 sec)

I was then able to complete the PHPMyAdmin configuration and re-enable validation:

mysql> INSTALL COMPONENT "file://component_validate_password";
Query OK, 0 rows affected (0.01 sec)

I also created a new PHPMyAdmin user who could create databases following the linked instructions.

Note that the web directory seems to have defaulted to /var/www/ instead of our standard /srv/www/, but this can be configured in Apache later.

Update: 02/11/2020

I found that I couldn’t connect to my localhost and needed to restart WSL2 (possibly after restarting the PC). These instructions were useful.

# PowerShell (admin)
Restart-Service LxssManager

# CMD (admin)
net stop LxssManager
net start LxssManager

allrite

Irreverently irrelevant. Sysadmin, developer, web dude in a science research agency. WordPress, Japan, planes, trains, Arduino, Raspberry Pi/Pico, puns, dad jokes, etc

Submit a comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s