Running Unix Apps on Windows
From last few months we have been involved in an interesting project that has different tiers in different platforms.
- Data Tier
- MySQL / LDAP / config files on Linux
- SQL Server on Windows
- Application Service Tier
- C/C++, Perl, Bash Scripting on Linux
- C#, ASP.NET on Windows
- Client Tier
- Desktop: C#/WinForms/SQLCE
- Web: C#/Dotnetnuke
Now we are investigating ways so that our data/application service tiers can be deployed on a single machine. We started exploring different options.
- Migrate the code from Unix to Windows; which I wanted to avoid; I will have to "take ownership" of that code base and will have to support that code...not very good option :)
- Use virtualization techniques, Microsoft's Virtual Server or VMWare to run one OS as virtual machine; not very performant option
- Explore Microsoft's "Windows Services for Unix"; something new to try out :)
Microsoft offers "Windows Services for Unix" package which is for pre Windows 2003 R2 and is a available for free at http://www.microsoft.com/windows/sfu Since Windows 2003 R2 (Including Vista Ultimate and Enterprise); these components are made part of the core OS and is now called "Subsystem for Unix-based Applications". Interix (http://en.wikipedia.org/wiki/Interix) is the POSIX/UNIX environment subsystem for Windows and its a part of this subsystem. This subsystem provides Unix environment within Windows; its not emulation of Unix...Windows kernel is designed in a way to support different sub-systems. Learn about NT Subsystems at Architecture of Windows NT.
Enabling "Subsystem for UNIX-based Applications on Windows 2003 R2/Vista doesn't install other Unix SDK/Utilities; you have to download them separately from Microsoft Download Center. Learn more about this at http://blogs.msdn.com/sfu
This subsystem provides C and Korn shells out of the box; many standard Unix utilities, GCC/GDB/NFS/X11 support is also there. http://interopcommunity.com is a great community site. http://www.interopcommunity.com/warehouse.aspx has the list of “Unix/Linux” apps compiled for Interix, meaning you can run “almost” natively many Unix apps including Squid, Apache and many other famous apps! There is also a package manager; pkg_update through which one can easily install stuff. To install pkg_update visit http://www.interopcommunity.com/pkg_install.htm and run the appropriate shell script. After that simply issue the following in the shell.
This is recommended that you set your account's home folder to something which doesnt have spaces; to do this; use standard Windows' computer users and accounts applet and set the home folder! Many Unix tools uses home folders and some of them dont like the paths with spaces!
It will ensure that all the installed packages are up to date
%pkg_update -L pkg
It will install the updated pkg catalog
%pkg_update -L bash
It will install the famous Unix bash shell
%pkg_update -L openssh
It will install the ssh libraries, client and even sshd; sshd gets configured with init and it should run fine on system startups
My "Unix developer" is confident that we would be able to use this subsystem to bundle our "Data and Application Service Tiers" into a single machine deployable package...which would be great!