Usually I prefer a virtual machine for all my Linux/Development requirements. Well, Microsoft is “trying” to setup a Linux subsystem within Windows 10 from a while, which is “yet” to be fully functional in many means. Many benchmarks proven that Microsoft Subsystem for Linux for has the poorest I/O which Microsoft claims, will be addressed in the future releases.
So, why someone will choose WSL against a VM which has better functionalities? From an eager inquisitive person’s perspectives, I will choose WSL for just couple of reasons and they are:
WSL could access the full hardware, when a VM has limited resources. Ie, say your computer running has 4 cores and 8GB memory, you will be limited to 2 cores for your VM (anything beyond that would cause unexpected issues) and maximum of 4GB memory. Here WSL don’t have such limitations, it could access all your 4 cores and the maximum memory & could be launched like just another win32 application!
I’ve been trying to setup WSL using both Ubuntu & OpenSUSE Leap 42.3 over my Windows 10 1709 & I had better results with Ubuntu. OpenSuse has many issues those were beyond my skills to address and resolve. Hence, I chose to stick with Ubnutu for now.
So, installation of WSL on Windows 10 recent versions were made pretty easier compared to the previous releases. A seasoned Windows user could install Ubuntu for WSL very easily by following the instructions below
Once rebooted, from the Windows store, search for Ubuntu or OpenSUSE and just install it! That simple it is.
Once installed, as mentioned with the first image, one can start the WSL either from command prompt or by clicking the tile that is available with the start menu.
As a developer, I would take the pain to setup the WSL for ONLY few reasons like testing PHP application(s) those are based on MySQL database (and outta curiosity)
So next, let us see we can setup LAMP server (LAMP is an archetypal model of web service stacks, named as an acronym of the names of its original four open-source components: the Linux operating system, the Apache HTTP Server, the MySQL relational database management system (RDBMS), and the PHP programming language. The LAMP components are largely interchangeable and not limited to the original selection. As a solution stack, LAMP is suitable for building dynamic web sites and web applications) on our new WSL
You may refer to this post for a detailed information about how to install individual components like apache, MySQL and PHP. Please note, the link that I provided deals with PHP5, which is not anymore available from Ubuntu repositories, hence I chose to go ahead with PHP7.0 for my WSL instance
Issue the following command(s) to install Apache, MySQL,PHP and phpMyAdmin
sudo apt-get install apache2
sudo apt-get install mysql-server
During the installation, you will be prompted for setting up MySQL root credentials, which is mandatory in order to access the MySQL server at later stages using phpmyadmin module
For PHP, you must install libapache2-mod-php, else you would experience php pages being blank when functions like phpinfo(); are called.
sudo apt-get install php libapache2-mod-php
Once the packages are installed (without errors) you can restart apache to verify everything is working fine
sudo service apache2 restart or sudo /etc/init.d/apache2 restart
If your windows box already has IIS listening to port 80 and a Windows instance for MySQL is listening to port 3306, then you must change the ports for both apache and MySQL before restarting the services.
For changing the port of Apache server edit the following file
For changing the port of MySQL server edit the following file
Although no real show stoppers, these couple or warning/error messages could make you feel irritated whenever apache and MySQL services are started
[core:warn] [pid 47:tid 140569079777152] (92)Protocol not available: AH00076: Failed to enable APR_TCP_DEFER_ACCEPT
Edit the file
add the following line by the end of the file
AcceptFilter http none
Restart the apache service
No directory, logging in with HOME=/
Edit the file
and change the MySQL user details like following
Restart all services to make sure that there are no more warning/error messages
So far so good, let us install phpmyadmin, which you will use to manage your MySQL instance
sudo apt-get install phpmyadmin php-mbstring php-gettext
During the installation you will be prompted for selecting the http server stack and password for MySQL root account. You must provide the root password that you have set during the MySQL installation at this prompt
(Refer https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-phpmyadmin-on-ubuntu-16-04 for more details)
Once the phpmyadmin is installed, you need to manually enable couple of extensions and they are dealt like following:
#sudo phpenmod mcrypt
#sudo phpenmod mbstring
Restart all services
sudo service apache2 restart
sudo service MySQL restart
rajesh@rt04:/etc/apache2$ sudo service apache2 restart
* Restarting Apache httpd web server apache2 [ OK ]
rajesh@rt04:/etc/apache2$ sudo service mysql restart
* Stopping MySQL database server mysqld [ OK ]
* Starting MySQL database server mysqld [ OK ]
Now you can see that there are no errors or warning while starting both apache and MySQL. So let us go ahead and check phpmyadmin
That’s all folks!
There is no shutdown for WSL, just type “exit” and you are good. I am yet to test whether mere exiting does anything harmful to running instances of apache and MySQL. Until I find them…
I don’t really understand why, yet, many users are asking for a “way” to ssh into the Linux subsystem. The pre-installed openBDS ssh server doesn’t allow a connection from clients like putty. Hence a re-installation of SSH server is required.
sudo apt-get remove --purge openssh-server
sudo apt-get install openssh-server
sudo service ssh --full-restart
Create a firewall inbound rule if required
Now you should able to connect to WSL instance using a client like putty.