Ubuntu on Windows

windows-category-inverted

In the Anniversery Update, Microsoft added support for “Bash on Ubuntu on Windows”, a full linux subsystem, allowing you to run virtually any console level Linux application, including things like Apache, MySQL, PHP and other standard offerings, without any modification.

Of course, these are available for Windows as well, but having a full LAMP (Linux Apache MySQL PHP) stack on your local system without having to run a full VM is kind of useful.

When I picked up my new Ultrabook, I decided to try out Ubuntu on Windows instead of using Wampserver for my local PHP development.

Installing Ubuntu for Windows was easy enough, enable the feature in Windows and away you go.  Once finished, you can then run Bash and get a full Linux command line available.

Installing packages is exactly the same as with Ubuntu, for example to install Apache, simply do a “sudo apt-get install apache2”.

MySQL, PHP, Apache, phpMyAdmin, etc. all installed without issue and I had a functional LAMP stack soon afterwards.

It’s quite an impressive feature really, but there are a few drawbacks:

  • Apache started automatically with the system, but for some reason that I haven’t tracked down yet, MySQL doesn’t.
  • File system access (see more below)

Overall, it’s a useful tool if you need Linux but don’t want to install a full VM.

File System Access

Here’s the show stopper though.  The files system inside of the Ubuntu install is a real Linux file system, everything you expect is there; etc, mnt, var, …

To accomplish that, Microsoft has created “root” directory inside the current users home directory.

In Windows you can browse to it via:

C:\Users\[username]\AppData\Local\lxss

Inside the Ubuntu instance, Microsoft has mounted your permeant drive letters under the /mnt directory.

This let’s you move files back and forth between Ubuntu and Windows.

That sounds like a great idea until you notice that to accomplish this trick Microsoft has created different file properties for Windows and Ubuntu.  So for example if you edit a file in Linux, the last modified date is update in Linux but not Windows.

Likewise if you create a file through Windows in the Linux file system, it won’t show up in Linux as it doesn’t have the “right” file properties associated with it.

This makes trying to do development in this mixed environment virtually impossible.

For example, if your working on a PHP app and editing the file in your favorite Windows editor and save it, PHP will never see the file modified and not reload it in to the cache so you will always get the unedited code running on the server.

There are a few ways around this, like disabling opcache in PHP, or “touching” the files after editing, but these are hacks at best.

In addition, I found some files simply disappeared from Linux after being edited in a Windows editor and the only way to get them back was to remove them and copy them from /mnt/c.

Conclusion

It’s an interesting option to have, but it’s too immature at this point to use in any serious fashion.

I’ll keep an eye on it, but I’m removing the LAMP stack and going back to Wampserver for the time being.

 

 

 

 

Greg

Greg

Greg is the head cat at JumbleCat, with over 20 years of experience in the computer field, he has done everything from programming to hardware solutions. You can contact Greg via the contact form on the main menu above.

More Posts - Website

Greg

Greg

Greg is the head cat at JumbleCat, with over 20 years of experience in the computer field, he has done everything from programming to hardware solutions. You can contact Greg via the contact form on the main menu above.