You might remember the Reese's Peanut Butter slogan, "Two great tastes that taste great together." Linux running on windows is not novel, nor is windows running on linux. VMWare and VirtualBox have been around for quite some time. However, Windows subsystem for Linux (WSL) is a bit different. WSL was released as part of the windows 10 anniversary update and I finally had an interesting use case that allowed me to give it a spin. Let's dig in and discover if WSL is the next tasty treat served up by Microsoft.
As most of you are aware we have four currently active GitHub properties. If you were not familiar with these let me provide a quick overview:
- https://github.com/elementps -- repositories that provide sample code for the Element/Express platform.
- https://github.com/mercurypay -- repositories that provide sample code for the MercuryPay platform.
- https://github.com/litleco -- repositories that provide sample code/sdks for the vantiv ecomm platform.
- https://github.com/vantivlabs -- where innovation, fun, and commerce collide!
We receive occasional pull requests (updates to the code fixing issues or proposing changes) and we received one this week that resolved issues in our HostedCheckout.PHP repository. I do not have PHP installed on the computer I use day to day but I do have a windows 10 computer that is the perfect experimenting rig. I have been reading articles about Bash on Ubuntu on Windows and WSL and I could not get the vision of a Turducken out of my head (strange but definitely intriguing).
The following is a walk through of installation and use.
Type: "control panel" in search. Open it up, click Programs, under Programs and Features choose Turn Windows features on or off, then put an x next to Windows Subsystem for Linux (Beta).
Now enter 'bash' in the search and you'll see 'Bash shell' or 'Bash on Ubuntu on Windows'. Open that up and you'll follow a few steps to install everything, create a username/password, and you're ready to roll.
Before you know it you'll be a Linux machine.....on windows. If you are interested in digging in head on over to the Microsoft blog and take a deeper dive: Bash on Ubuntu on Windows 10 Anniversary Update – Windows Subsystem for Linux .
Now that WSL is installed we will continue with this use case which is testing the pull request to the GitHub code. Normally I would test the code first and then apply the changes but these were relatively minor so I went ahead and merged the code and then downloaded it to my windows computer here:
How do you access this directory from WSL? Easy:
If you're curious how the WSL filesystem works there is a great blog post here: WSL File System Support – Windows Subsystem for Linux
Ok, now we need to install PHP. I typed 'php' and hit return and was prompted to use apt-get to install php. If I remember correctly the command is: sudo apt-get install php5.
Now let's run the code! Oooops....too soon. Before we run the code we need to replace all of the [Merchant] and [Password] "prompts" with the actual merchantid and password. Because we are truly geeking out we use vi to make the edits. Using vi on windows! It was possible with the Cygwin tools and/or virtual machines but this feels...well, integrated, and easy. Ok, merchantid and password added. Now let's run the code.
And here's the output:
The code hits the hosted checkout server returns a PaymentID and then uses that PaymentID to run a VerifyPayment. This does not seem magical but the fact that one of our partners initiated the pull request and I was able to quickly test the changes and experiment with WSL at the same time truly made for a happy Vantiv day.
There are a few things I would still like to investigate:
- If I uninstall WSL does that uninstall remove everything? And when reinstalling will I have a clean version of Ubuntu?
- Is it possible to run triPOS on Linux on this version of Ubuntu (note: triPOS on linux is currently only supported on CentOS but we can still have some fun!)?
Thank you Microsoft...WSL is most definitely a treat. Our open platform loves your open platform!
How will you leverage WSL?