Windows Subsystem for Linux | Ubuntu | LAMP Server

Hi guys

Update: 19th April 2019

The good thing is I found a “solution” myself after wasting almost a working day, just because I was stupid enough not to read my own POST dealing with it :/

I will publish a new POST detailing what has changed & how you could avoid getting into a mess with WLS LAMP installations & configurations in a day or two.

Update: 18th April 2019

Although I was able to successfully install LAMP on multiple Windows 10 stand alone machine WLS, yet to figure out a way to install MySQL on a Windows machine running WLS that has already joined a domain. I am not sure whether it is due to some domain policy related issues, access issues or due to a corruption with my Windows. I will definitely try to find out the root cause (hopefully).

====

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

1
2

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

[code language="text" gutter="false"]

sudo apt-get install apache2
sudo apt-get install mysql-server

[/code]

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.

[code language="text" gutter="false"]

sudo apt-get install php libapache2-mod-php

[/code]

Once the packages are installed (without errors) you can restart apache to verify everything is working fine

[code language="text" gutter="false"]

sudo service apache2 restart or sudo /etc/init.d/apache2 restart

[/code]

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.

MySQL installation will GET IN TO a number of undocumented errors if you have another instance of MySQL listening to 3306 (ie, on your Windows box). Hence make sure that you shutdown the instance before attempting to install MySQL on WLS. Please remember, WLS is not another virtual machine, so if a port is open on your “HOST”, that is definitely a conflict for the WLS.

For changing the port of Apache server edit the following file

[code language="text" gutter="false"]

/etc/apache2/ports.conf

[/code]

For changing the port of MySQL server edit the following file

[code language="text" gutter="false"]

/etc/mysql/mysql.conf.d/mysqld.cnf

[/code]

Although no real show stoppers, these couple or warning/error messages could make you feel irritated whenever apache and MySQL services are started

Apache:

[core:warn]

[pid 47:tid 140569079777152] (92)Protocol not available: AH00076: Failed to enable APR_TCP_DEFER_ACCEPT

Edit the file

[code language="text" gutter="false"]

/etc/apache2/apache2.conf

[/code]

add the following line by the end of the file

[code language="text" gutter="false"]

AcceptFilter http none

[/code]

Restart the apache service

MySQL

No directory, logging in with HOME=/

Edit the file

[code language="text" gutter="false"]

/etc/passwd

[/code]

and change the MySQL user details like following (“:/nonexistent” text with /var/lib/MySQL, do not change anything before those three commas)

[code language="text" gutter="false"]

mysql:x:112:117:MySQL Server,,,:/var/lib/mysql:/bin/false

[/code]

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

[code language="text" gutter="false"]

sudo apt-get install phpmyadmin php-mbstring php-gettext

[/code]

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:

(I did a fresh WLS instance on 17th April 2019 & the phpmyadmin installation has changed a little bit here and there, asking for the webserver & an additional setup that helps to setup the phpmyadmin user passwords etc)

[code language="text" gutter="false"]

#sudo phpenmod mcrypt

#sudo phpenmod mbstring

[/code]

Restart all services

[code language="text" gutter="false"]

sudo service apache2 restart

sudo service MySQL restart

[/code]

Example:

[code language="text" gutter="false"]

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 ]
rajesh@rt04:/etc/apache2$

[/code]

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

3
4

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…

Finally

5

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.

[code language="text" gutter="false"]

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

[/code]

Now you should able to connect to WSL instance using a client like putty.

regards,

rajesh

Active Directory Listing Software

Hi guys

Today I am going to share a compact software that could generate moderately detailed information about the Windows active directory member computers, servers and users from a single console, that I started developing many years back.

This software helps you to export the fetched details to an excel sheet for future references. While there are no restrictions exclusively attached to the usage of this software, the source code for the application is ONLY available against written requests. Refer the readme.txt file for more details.

Please download the zip file from this link and extract to a single folder. Double click open “WpfWMI” to run the software (No installations required). We are using open source EPPlus.dll for the excel export and you must insure that the dll file is within the same folder of the executable file (WpfWMI.exe)

Pre-requisites: The computer you are running this software MUST have .Net framework 4.5 installed.

Expected bugs:

  • When you are not connected to a domain, software will show you a message “Not connected to Domain, Aborting”. However, the main application will load and trying to load objects will crash. I’ll fix this the earliest possible.
  • If your internal & external domains have same name, for example internal domain name is “abc.com” and your public website is “www.abc.com”, you may experience the above mentioned crash while connected to your network over a VPN connection.
  • Poorly designed About, help sections. I apologize for the same as I never had intensions to release it for public usage. Will try to accommodate as much with next public release.

Test it & post your comments and suggestions.

regards,

rajesh

Windows 10 | 0x80070035

Update: In my case, I was able to fix the issues by re-installing Windows using the installation media over an existing Windows 10 1709 installation. I chose to keep files and applications and once after the re-installation successfully completed, achieved the desired results.

Update: Basically this is a bug, which doesn’t affect those who were keeping on upgrading from builds to new builds (ie from 15xx to 17xx). Affects most of the users who did clean installation of 1703/1709 which is yet to be addressed by Microsoft. My case, I did an upgrade from 16xx and resetting the TCP/IP, Winsock etc did the damage for me (Well, it realized that, this issue also exists ;) )

Today, I managed to realize that by just unchecking OK, Checking again and OK combinations on File and Printer Sharing Services for the network adapter fixes the dreaded issues until a restart.

12

Here are the workaround solutions until Microsoft finally releases a patch/update for it.

http://partnersupport.microsoft.com/en-us/par_clientsol/forum/par_win/windows10-1703-file-and-sharing-printer-net-view/9569d27f-d979-4c5a-9a01-98cd9c99c4f2?page=2

Other references:

https://social.technet.microsoft.com/Forums/windows/en-US/671fdb58-7d82-4078-a372-e3b50433faa4/windows-file-sharing-stops-after-every-restart?forum=win10itpronetworking

https://superuser.com/questions/443329/windows-7-file-and-printer-sharing-doesnt-work-for-me

 

Hi guys

Recently I tried to enable mobile hotspot on my Windows 10 (1709) Pro machine at work that is a domain member. By the time I figured out that the connection issues clients connected to the ad-hoc network were purely related to some authentication issues with our UTM device…it was too late.

I did enough damage to the network stack of my box, reset winsock, rebuilt TCP/IP, resetting the firewall.. and after fixing the issues with mobile hotspot, started having issues with the HP printer and a particular folder that I share with my team.

Both the printer and shared folder cannot be accessed over network, the funniest part was from my local machine itself I couldn’t access the shared folder by calling it like

\\mymachinename\foldername

So as usual I tried to fix the issues using Windows trouble shooters and all the time I was getting the same info “0x80070035” and further diagnostics gave me:

“The device or resource <<HOSTNAME>> is not set up to accept connections on port “The File and printer sharing (SMB)”.”

I tried to find more details, especially about the above statement and unfortunately, none of the questions asked by users in relation were satisfactorily answered by Microsoft.

Then I landed on a Microsoft page @ https://answers.microsoft.com/en-us/windows/forum/windows_10-networking/windows-10-pc-rejecting-incoming-connections/a36974c7-3208-4489-ad44-962838c38b29

The last contributor asks Is “File and Printer sharing for Microsoft Networks” enabled under the properties of the network card?, for obvious reasons I was sure that this service is enabled under the network properties of my Ethernet device.

Logically, my next approach was to uninstall this service from the adaptor, re-install it. Immediately after reinstalling the service, all the shared assets from my laptop were accessible over the network.

Still not happy, I rebooted the machine, to find out that the shares were once again having the same issue(s).

0x80070035

So I uninstalled and reinstalled the “File and Printer sharing for Microsoft Networks” service and this time reset the Defender Firewall to defaults. Instead of restart I did a shutdown, waited few minutes and restarted it.

As I am drafting this post, I have checked the access it is working perfect. Will reboot one more time to insure that this fix is permanent.

I don’t know the technical reasons behind this erratic behavior, however it looks like one more time uninstalling and installing the “File and Printer sharing for Microsoft Networks” fixes the issues (minimum for now) & until a reboot.

If you are facing the same issue(s), why don’t give it a try.

regards,

rajesh