Is there some good guide on how to use Linux subsystem provided with windows 10 to set up and run Magento 2?
The Windows Subsystem for Linux (WSL) is a new Windows 10 feature that enables you to run native Linux command-line tools directly on Windows, alongside your traditional Windows desktop and modern store apps.
The Windows Subsystem for Linux lets developers run GNU/Linux environment -- including most command-line tools, utilities, and applications -- directly on Windows, unmodified, without the overhead of a virtual machine.
- Choose your favorite GNU/Linux distributions from the Windows Store.
- Run common command-line free software such as grep, sed, awk, or other ELF-64 binaries. Run Bash shell scripts and GNU/Linux command-line applications including:
- Tools: vim, emacs, tmux
- Services: sshd, MySQL, Apache, lighttpd Install additional software using own GNU/Linux distribution package manager.
- Invoke Windows applications using a Unix-like command-line shell.
- Invoke GNU/Linux applications on Windows.
- Enable developer mode from settings.
- Open powershell/cmd as admin and enable WSL using following command
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
You can also enable it from window features in GUI.
- Restart your system.
- Install distro of your choice from the windows store. (Just search for eg. Ubuntu and install).
- Access WSL using
bashcommand on cmd.
- It will ask you to set username and password for your linux user.
- Check your distro using the following command ;
- Install apache using the following command;
sudo apt-get install apache2
- Start apache using the following command;
sudo service apache2 start
Access localhost to see if apache has been started successfully. Just open up the browser of your choice and type 'localhost'.
Install mysql using following command ;
sudo apt-get install mysql-server
- Start mysql using the following command ;
sudo service mysql start
- Access mysql to make sure it is running properly
mysql -uroot -p
Use exit/quit command to exit mysql.
- Install PHP using the following command
sudo apt-get install php7.2
You can install php version of your choice by just mentioning the version.
- Check if PHP has been installed using the following command;
- Check if you have all the modules needed by placing
- Install composer using following command;
curl -sS https://getcomposer.org/installer -o composer-setup.php
If you do not have curl, install it using
sudo apt-get install curl
- Make symlink of your Windows Magento project folder/ from where you want to access Magento files in /var/www/html using ;
sudo ln -s /mnt/c/projects/magento23 /var/www/html/magento23
Note that all the windows filesystem can be found mounted in /mnt folder.
- cd into your symlinked folder and install Magento using composer.
In my opinion, the WSL way of using Magento in windows is much faster than native windows and much more hassle-free than installing a virtual machine and dealing with its problems. You also have direct access to all project files so you can use your preferred editor for coding.
Note : Currently I have to start apache and mysql server after every restart but I will update if I can get it added to systemctl boot time.