Windows

My Experiment with Windows Subsystem Linux (WSL)

This article have been updated. You can read the current post here.

As a Windows user who’s feeling more comfortable in there, but when it comes to web development, it barely fit!

That’s why (the veteran) AppServ, WAMP and XAMP exists and fills that gap with a totally unstable distribution that just works and helps a lot of new PHP learners to get started until they fell in problems. Or install the precompiled binaries or even compile them and install in your machine manually and that’s a headache especially for upgrades and reinstallation. Either use sort of Virtualization and Containerization such as Vagrant and/or Docker…

Recently Microsoft announced its corporation with Canonical (The company behind Ubuntu) to bring bash to windows which were weird news to hear but awesome at the same time and now it’s been released in Windows 10 anniversary update build to represent as Windows Subsystem for Linux (beta) shipped with Ubuntu 14.04 Trusty. https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux

After installing bash commands and tools like SSH, ls, cat and vim become available in the native CMD! Which is a great thing without having another OS running in the same place with no (really) suffer for VM. You can find a lot of instructions to install bash in your machine around the web, however the best match from Microsoft itself: https://msdn.microsoft.com/en-us/commandline/wsl/install_guide

After I installed it and started to mess with it, a few things I’ve noticed so far:

  • Since it’s a separate Subsystem it has its own OS and Home Directories
  • Any Package you install remains within bash only
  • Running Services remain running while you have at least one bash instance window open. Otherwise, you need to re-run them Manually

Besides the joy having most bash commands in my CMD, my hands were itching to try installing Apache2 and PHP7, and dang! Works as if I’ve installed them on my local machine!

WSL Apache with PHP
WSL Apache with PHP successfully running from localhost.

As you can see I am able to access Apache directly from localhost with no port forwarding needed!

While you have your own home and OS directories for Ubuntu, you still can access your windows drives and folders just by navigating to /mnt/ directory then all your drives are listed there.

Then my hands go itchier to try adding some sort of virtualization to it, so I decided to install Oracle VirtualBox, but unfortunately, I didn’t succeed with this approach with some kernel errors rising. Maybe there’s something missing, or needs another round with more precise trial.

To keep the distribution up to date easily running to Ubuntu commands apt-get update and apt-get upgrade will keep you up. And if you screw it up and want to start over, luckily you can do it with a simple CMD commands

C:\> lxrun.exe /uninstall /full
C:\> lxrun.exe /install

A good blog post from windows.com inspires you to have fun with bash:

https://blogs.windows.com/buildingapps/2016/07/22/fun-with-the-windows-subsystem-for-linux

And another article Installing Ansible easily to windows for tasks automation:

http://www.jeffgeerling.com/blog/2016/using-ansible-through-windows-10s-subsystem-linux

At last, I enjoy using bash in windows hoping this project stays alive and updated.

1 Comment

Leave a Reply

Your email address will not be published.Required fields are marked *