Install LAMP on Windows 10

With a new server running Ubuntu as described in install Linux on Windows 10, you can set up a LAMP stack by installing Apache, MySql and PHP. This LAMP install will be set up for a trouble free later install of Moodle.

First update your software to the latest – run these commands
  • sudo apt update
  • sudo apt upgrade
Answer “Y” when given disk space details and asked to continue and”Yes” for “Restart services during package upgrades without asking?” (Use the tab button to select)
Now install Apache and MySql
sudo apt install apache2 mysql-client mysql-server php libapache2-mod-php
sudo service mysql start
sudo mysql_secure_installation This secures the MySql service. MySql must be running and this command must be run by the sudo user.
  • When asked “Would you like to setup VALIDATE PASSWORD plugin?“Choose “N”
  • Now set the Mysql root user (IMPORTANT do not forget that password! Write it down)
  • Answer Y to “Remove anonymous users?”, “Disallow root login remotely?”, “Remove test database and access to it?”, “Reload privilege tables now?
Check your PHP version with:
php -v
Mine returns PHP 7.2.19-0ubuntu0.18.04.1. If the command returns a version of 7.3 or higher, change the version number in the following command:
sudo apt install graphviz aspell ghostscript clamav php7.2-pspell php7.2-curl php7.2-gd php7.2-intl php7.2-mysql php7.2-xml php7.2-xmlrpc php7.2-ldap php7.2-zip php7.2-soap php7.2-mbstring
Restart Apache webserver.
sudo service apache2 restart
You may see Failed to enable APR_TCP_DEFER_ACCEPT so run
sudo service apache2 status
You should see Apache2 is running

Check your install by going to a browser and typing localhost in the browser bar and you should see the Ubuntu Apache page. Now you have a Lamp stack and are ready to install Moodle as described in install Moodle on Windows 10 Subsystem for Linux.