Did anybody got expiriences with WSL (Windows 10 and Ubuntu bash) ?

60 views
Skip to first unread message

PatternStitcher911

unread,
Oct 11, 2017, 12:49:16 PM10/11/17
to web2py-users
Hey there I'm new here and got some real good experiences with web2py.
I followed the step by step of pitch and tukker :-), help a lot.

The only bad issue had been with CYGWIN, it's work, of course, but some times i have to switch in between Windows and CYGWIN, so that is not so comfortable
and it's not a real Linux, so new software has to be install with CYGWIN setup, which is not a big deal.

I'm working with Windows 10 and Ubuntu bash a long time, and today, because I had the time, I did think over, what will Ubuntu bash doing with web2py.

And amazing, it's work like a Charme, really. But yes you have to prepare some things.
First good thing Python is already on board, Mercurial and gedit (as GUI) can be installed.

So I tried, and after a short time work, is fantastic running. It did more time to writing down all the things to know.

Thanks a lot Massimo Di Pierro  for web2py, and Marco Laspe for the step by step instruction.


If you are interested how I did WSL running with web2py, just read ahead, later one I'll generate a web side with web2py about this theme :-)
But for today, it's quite a lot, i hacked on my keyboard :-)



Windows 10 with Ubuntu bash [mostly called WSL] - (Ubuntu 14.4) running the awesome web side constructor "web2py"

One thing in mind to use this workflow: every command in bash, don’t use the "", I use it in the workflow only to make sure, every
letter's which once to the complete command is clear. Example: "sudo apt-get update" has to look in bash:$ sudo apt-get update
only to know :-)

If you already have experiences with Linux, followed workflow will feel you at it's just a joke, because it's easy, but
the most of the Windows user, don't mind, because they have to learn.

And yes of course, you can run the hole setup for Web2py on Windows directly, with web2py.win (together with CYGWIN),
plus an IDE-Editor, and several circumstances.


Windows 10 Insider Preview with activated BASH-Ubuntu
What to do first, if not already done ?
1.) Windows Insider Preview and activated WSL
    follow the instruction at that link to do:
        https://www.howtogeek.com/249966/how-to-install-and-use-the-linux-bash-shell-on-windows-10/
2.) Install xming to have choice of get run GUI Application , like GEDIT
    follow the instruction at that link to do:
    http://pjdecarlo.com/2016/06/xming-bash-on-ubuntu-on-windows-x11-window-system-running-from-windows-10-subsystem-for-linux.html
   
    Keep in mind, to start the display server x11 (x11-apps), with: "export DISPLAY=localhost:0.0"
    As a first trial in WSL, we can generate a bash script, to call this function easier.
    But later, not right now, we need to run GEDIT in a GUI
   
3.) Now it's time to check, if BASH runs smooth :-)
    Just push right mouse button on the start button of windows, than choose execute and write : bash + ENTER
    WSL should open than and ask you for a user name, at first time, and a password,  hack in the password (twice).

    Otherwise it's starts true to the main bash, with the home folder of your user account :-)
    Well done, we can go ahead than and prepare WSL, to get some useful programs running.

Until here that take's some time to do, but is not really difficult, if you follow the link's above.

At next, as an good idea I thing, we install GEDIT (GEDIT is a Text-Editor for Ubuntu, with IDE proper arrangement for script languages).
Install gedit with: "sudo apt-get install gedit"

So we put in our WSL:

"sudo apt-get update"

[the password you entered twice is to use now]:-)

    Therewith, we get an updated repository of the WSL, that is a must to do first, before install new programs every time !!
Than we upgrade all needs to never version's if necessary, sometimes it is.

So we put in our WSL:
"sudo apt-get upgrade"
    :-( by the way, it's not a got idea, to make a dist-upgrade, WSL is not 100% Linux, beware of this, and don't try ever.

Now we have the newest version off WSL and we can go ahead with our installation.
Before we go ahead, make shure, that you complete work out, true point 1.) and 2.), otherwise you will feel in a bad condition,
because, some arranged thing's in WSL are missing.

4.) To install Gedit, hack in your WSL : "sudo apt-get install gedit"

    Let's start gedit, to check it's running smooth.

    First hack in your WSL : "export DISPLAY=localhost:0.0"
    And than let's start gedit with : "gedit"

    And just we have running gedit, let us do a first trail in Linux scripting :-)
    Why ? Learning by doing, is best practice.

    Of course, before you start your GUI driven programs, like GEDIT, you can hack in WSL : "export DISPLAY=localhost:0.0"
    every time, or, with is easier, we write a small script :-)

    Let's go, it isn't careful :-)

    With CRTL + N, you open an empty new file.

    we put in the first line :      "#!/bin/bash"
                    and than :          "export DISPLAY=localhost:0.0"
                  and latest :          "gedit $1" ; where $1 let us send a file name while call gedit
        Than we have to make the new script useable [executable] with : "chmod -x gedit.sh"
       
        With "#!/bin/bash" in the first line, we let Linux know, that this file is a Linux bash script file.
        The extension ".sh" is not a must in Linux, but later, after a while using Linux, you will work faster, because you know, that ".sh"
        stays for "LINUX BASH SCRIPT" :-)
    and now we save the new bash script : with the name "gedit.sh"

    Use the menu in gedit, to do.
    Close your gedit, with CTRL + Q, or with the menu.

    From now on you can start gedit (remember, you had to call the display first, but not with the script:-)
    with only hack "./gedit.sh" in the bash.
   
So, at next, I feel, it's a got idea to have GIT or Mercurial installed, to push your work on it for backup.
And of course, if you work together with others, that is a must to have.

Off course you can use a USB-Stick instead, to make your backup's.
But it's much easier with Mercurial, and you can work on your project at any computer, without any copy session's :-)
My favourite is Mercurial, because it's work perfect for python, which is our base !!

Of course GIT is running as well, but more difficult, i feel.

5.) To Install Mercurial, hack in your WSL : "sudo apt-get install mercurial"
    To prepare smooth running of Mercurial, we have to put a file ".hgrc" in our home folder.

    Ohh, what is a home folder, in Linux, well, the same you have in Windows, where your Documents, Video, Music and other staff is placed.

    Aha ! But it's a little bit different in WSL under Windows 10, I don’t know why they did it, but it is. :-) no matter about, we change !

    You can find your installation folder of WSL at : >> C:\Users\USERNAME\AppData\Local\lxss <<, which USERNAME is your name !!
    So to find your Home-Folder in WSL: open a new bash, and than your are in your Home-Folder automatically !
    In real Linux, you come back to your Home-Folder, when hack: "CD /~" in the command line of WSL, it's close the same,
    but not really, because you see there as well your Folder from Windows 10, like Documents, APP-Data, Downloads.
   
    !! Be careful in WSL, that you not damage your User-Workplace. I find, it's not a good idea from Microsoft, to put Linux /home and Windows
    USER-Workplace in the same folder, but it's made, but we have a possibility to change, that's again good news. :-)

    And therefore, I generate a new /home folder in WSL, like i have it in real Linux:
    with "mkdir /mnt/c/home", you generate this folder in 
    Linux, and for the user than "mkdir /mnt/c/home/UsernameInUbuntuBash.
   
    To change from the mixed one, you have to use a Linux command for this:  
   
    sudo usermod -d /mnt/c/home/UsernameInUbuntuBash/ UsernameInUbuntuBash
   
    normally,

    but in WSL it pops up an error, because the username is in use of the WSL, and secured, what is absolute ok here.
   
    Therefore you have to switch to root with [lxrun setdefaultuser root] in the WINDOWS-COMMANDline (CMD), not in WSL.

    To make this procedure clear, my change has been:

    start bash to come in WSL: you know already how to start.

    Than hack in your opened WSL bash:

    "mkdir /mnt/c/home"
    "mkdir /mnt/c/home/tklinux" ; tklinux has to be change to your username !!

    Exit your WSL !

    Than you have to switch WSL in root: do it with "lxrun setdefaultuser root" + ENTER in the WINDOWS-COMMANDline (CMD), not in WSL.

    That get's you able to change the home folder for your user name
    for me it has been:
   
    "usermod -d /mnt/c/home/tklinux tklinux" ; while tklinux is my username, you don't have to pre hack sudo, because your are root now.

    Very important, switch back to your WSL user name again :-), otherwise you moving around as root in WSL, and don't find your user space :-)
   
    To do so : "lxrun setdefaultuser USERNAME" + ENTER,  in the WINDOWS-COMMANDline (CMD), not in WSL.

    For me in real again "lxrun setdefaultuser tklinux" + ENTER

    Uuaahaa, not really, but yes it's looks a bit difficult, doesn't matter, your are learning a lot while doing :-)
    The most important news is, that we are able to switch user --> root --> user, that's quite a real good thing to know,
    if something get wrong and we have to fix as real root, like in Linux normal working.

Now I come back to setup Mercurial, because we need a special file, and that had to be in our home folder
Enter your WSL, and start gedit: we have to create the file .hgrc (the dot is important, don't forget)
with

"./gedit.sh .hgrc" +ENTER

Yes it's true, start the script with the name of the file in once :-)

Now we have generate the new file with the name .hgrc, which is empty, but not long, we will fill it with needed information.

In the first line hack:      "[ui]"
                                      "<username> <em...@somewhere.aa>"
                                      "editor = gedit"

if done, please save the file with CRTL + S, and quit gedit.
To use Mercurial you have to sign up a free account at www.bitbucket.org , for example, but there are as well other's.

6.) Because we have a new, and separated home folder, we can act now, like it is possible in real Linux, which is amazing simple.

    We need first a storage for the web2py software, because it's a system undepant software and run with Python, a good choice is
    your home folder. After starting your WSL, your are already there.

    Hack in your WSL bash :


    for download the source.

    Than unzip with : "unzip web2py_src.zip"

    unzip is already installed in WSL, if not, don't wonder, just do it with "sudo apt-get install unzip" :-)

    Switch in the new folder in your home : "cd web2py"

    Because Python (2.7) is already installed in WSL, we can start installation of WEB2PY

    To do it, start the script: "./web2py"

    after a short while, you will prompted for a password, take a simple on, because
    you have to hack in every time as a new password, when start WEB2PY.

    That's all, WEB2PY is running with WSL, what is a real big shut, isn't it ?

    For further information, how to work perfectly with web-development WEB2PY
    please take the lesion’s with the link : http://killer-web-development.com/section/1/1
    don't wonder, the name is crazy, like Marco Laspe, he made it :-)

    But it's real good staff, light understandable, easy in use, and at the end, you
    have a complete Website made, with database, controlling, funny styles.

    But make your own experience, I'm shure, you will post me a big thumb, if you could :-)
   
    regards Thomas

PatternStitcher911

unread,
Oct 13, 2017, 5:13:28 AM10/13/17
to web2py-users
:-)

maybe I did made something wrong, nobody interessed in expierience with WSL ?

黄祥

unread,
Oct 13, 2017, 5:39:34 AM10/13/17
to web2py-users
great, thx 4 sharing, thought this day people use vagrant (vm) or docker (container) to use the *.nix env.

best regards,
stifan
Reply all
Reply to author
Forward
0 new messages