5

I recently got WSL installed, and after playing a bit was wondering about a couple things... first, is it possible to treat it as a server? For example, if I wanted to host a small mysql db- it looks like that's no problem. But is it possible to connect to that mysql instance from a different machine? How would I do so?

Can I target this subsystem to develop C++ applications for linux from Visual Studio 2015? How do I connect to the 'remote machine'- which in this case is the same box that I'm running VS2015 from?

Or what if I were running a webserver (can I?) and can I connect to that server from my windows 10 machine using chrome or some such tool?

3

I have been able to "apt-get install apache2" and start the service "/etc/init.d/apache2 start". At that point, you will be able to access the server locally (from the Windows 10 box), an if you open up the Windows firewall, can access it from other machines. I have not tried mysql or PHP, and the WSL developers are still adding new system calls (pseudo ttys were just added, and timer_create is currently not supported for example), so somethings won't work. For example, apache warns you that it cannot enable APR_TCP_DEFER_ACCEPT. However, I was able to run tightvncserver, twm, firefox, and xterm within WSL and connect to it remotely from VNC (fun!).

It is important to note that upstart or init.d does not kick off automatically when you start a Windows 10 box with WSL, so you will need to kick off services in a script or manually.

You can communicate to WSL by network or direct file access. WSL can access the C: drive through /mnt/c/, and Windows 10 can access WSL through c:\Users\%USERNAME%\AppData\Local\lxss. To write files on /mnt/c, you need to start bash as an administrator. You cannot run Windows executables through WSL.

WSL runs Ubuntu 14.04 ELF binaries, so I imagine you'd need the Visual C++ for Linux Development extension (which I have not tried).

Good luck!

  • Thanks! Good info, and looks promising. The WSL instance has the host windows 10 machines IP I take it? Did you connect to VNC just through a specific port? I wonder if I'm running IIS on port 80 of the win10 machine, and apache on WSL port 80... what happens? – Nicros Jun 17 '16 at 17:49
2

It works just like a Linux machine. We are currently running an LAMP site, and it's snappy. No issues setting up the domains either.

Tips & Things to consider:

  • You will need to setup your Windows Firewall properly to forward an external domain.
  • DO NOT access or edit the subsystem from its Windows folder. It will screw stuff up (at least in its current iteration)
  • If you still want to edit files in Visual Studio (or other editor), just setup SSH access to the WSL (see link below), and add your Apache site as a remote site, or just configure it as a git repo (which is the best approach)
  • Use this great terminal client designed just for WSL https://github.com/goreliu/wsl-terminal
  • Create another user (default is root)
  • If using PHP7, you will need to set it up "manually", since the default apt repo doesn't include it.

Helpful links:

Good luck, post any specific questions and I'll help out as I'm able.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.