Documenting a Moodle install on WSL

Documenting a Moodle install on WSL

by James Steerpike -
Number of replies: 22
I have documented an installation method for a non-production server using WSL. Why do we need another installation method? Because I think this may be the best way to install a learning Moodle on Windows.
  • It is Linux, the preferred OS for servers. 'nix dominates the market because of price, effectiveness and security. Ubuntu, Debian, Suse - your choice.
  • It runs on a Windows 10 or above desktop, isolated from Windows but able to access files. You can continue to use all Windows programs and cut and paste between Windows and Linux. It is not an add-on, it is part of the Windows Operating System, fully supported by Microsoft.
  • It is the easiest way to set up a Linux server. Open a command prompt, enter wsl --install -d Ubuntu and you are done.
  • It is a learning path to a production server. Install WAMP and you have learnt how to install a Moodle which shouldn't be used with real students. WSL gives you a LAMP stack, recommended for a production server. Step up from WSL to a generic cloud VPS.

If you have a spare few minutes, could you try to follow these directions? You need to cut and paste a few commands and wait for downloads but you can continue to use your machine because everything happens in a desktop window. Interested to see if new users can follow to the end or where there are problems.

Here is the link Installation guide for Windows using WSL (Windows Subsystem for Linux)

Average of ratings: Useful (7)
In reply to James Steerpike

Re: Documenting a Moodle install on WSL

by Ken Task -
Picture of Particularly helpful Moodlers

Well done!

Don't have a Windows x to tinker with.   So pardon my ignorance with below in advance!

Suggestion ?:

Am annoyed having to type 'sudo' in front of every command.

If one issues sudo -s then provides the password of the user they are logged in as, if
user is in sudoers group, their prompt will change to 'root' user and they will no longer
have to use sudo in front of every command.

To exit shell, one would have to type: exit [ENTER] twice! smile


Questions:

Once installed and up and running, when user reboots Windows, does the Ubuntu instance in the WSL shutdown gracefully? ie, stops mysqld stops apache and then shutdown -h now.  Linux can take a beating but will eventually will suffer if one continually shuts down improperly ... I know that for a fact in providing support for a small school librarian who also was server admin for their internet servers/network etc. - bless her heart!


After the Windows 10 or x has rebooted, is Ubuntu automatically running again ... with all services needed for moodle launched?

One last suggestion:

On the Moodle doc for this, additonal links to Ubuntu's docs for the version of Ubuntu.

Again ... well done!

'SoS', Ken

In reply to Ken Task

Re: Documenting a Moodle install on WSL

by Ken Task -
Picture of Particularly helpful Moodlers

Follow up to my own posting ... sick!

Towards questions I asked ... maybe providing links in other info more info at bottom of Moodle how 2 page?

Networking
https://docs.microsoft.com/en-us/windows/wsl/networking

and main resource for overall coverage of WSL 2:
https://docs.microsoft.com/en-us/windows/wsl/

'SoS', Ken

In reply to Ken Task

Re: Documenting a Moodle install on WSL

by James Steerpike -
I will add more links. A useful one might be an intro to Linux. I still remember seeing the Redhat CLI for the first time and being completely unable to do anything.
In reply to Ken Task

Re: Documenting a Moodle install on WSL

by James Steerpike -
Thanks for your encouragement. Some thoughts
I like my copy and paste so sudo has never bothered me. One advantage is sudo discourages logging in as root and running theses commands. I will add that suggestion to my list.
From my reading, a Win shutdown shuts down the WSL window and should gracefully terminate all processes on WSL. Relying on MS here but it is their product integrated into their OS. A habitual cord puller would probably wreck every computer system though.
WSL does not automatically start nor does MySql or Apache, All must be manually started but the process could be automated within both Win and Linux. My thoughts are for a non production server, a manual startup is better.
The Ubuntu version is a MS version so a link could be misleading. wsl --list --online gives a list of available versions including
NAME FRIENDLY NAME
Ubuntu Ubuntu
Debian Debian GNU/Linux
kali-linux Kali Linux Rolling
openSUSE-42 openSUSE Leap 42
SLES-12 SUSE Linux Enterprise Server v12
Ubuntu-16.04 Ubuntu 16.04 LTS
Ubuntu-18.04 Ubuntu 18.04 LTS

For simplicity I have gone with Ubuntu.
In reply to James Steerpike

Re: Documenting a Moodle install on WSL

by Ken Task -
Picture of Particularly helpful Moodlers

A follow up ... realize it might be obvious, but ...

Once installed and up and running, how does the installer "see" the Moodle?   URL to use?

And yet another ... which might be intermediate or advanced ... networking.  And think a few would ask fairly quickly ... how does one access the moodle from another workstation on the same private LAN? 

One of my dislikes for MAMP/XAMMP or whatever of those flavors ... all localhost.   When developing a Moodle course/content which will be backed up and restored to production environment/server, things like videos or multi-media content aren't being served over a network if using localhost.  An inexperienced/un-aware content developer can and do fool themselves!

My 2 cents! smile

'SoS', Ken

In reply to Ken Task

Re: Documenting a Moodle install on WSL

by James Steerpike -
I now realise my error.
WSL gives me a 192.168.0.X reference when it opens. I think that will always be the same when it restarts. My Ubuntu test page is accessible throughout the network at that IP. Moodle isn't because I installed it on localhost during the web based install when I should have installed on the IP address. I will retest and amend this,
Would this fix this issue?
In reply to James Steerpike

Re: Documenting a Moodle install on WSL

by Ken Task -
Picture of Particularly helpful Moodlers

IP address kinda depends upon home network or the private network DHCP.

At home, my private IP LAN uses 192.168.1.x ... not 0.x.  When I worked at an ESC, before retirement, DHCP at that bulding had a 10.2.3.x range of IP's or in computer lab a 10.2.4.x range of IP's.

I used to do presentations about Moodle at conferences at various locations/ISD's/venues in Texas.   Didn't know what private IP's were to be used in advance ... ever.  

My VirtualBox, CentOS X, would pull a DHCP address.   So I had the Virtual OS send to my email address a message automagically ... my ip is X.x.X.x.

With that, I'd edit workstation host file and map that IP to the fake .org domain I'd used to **install** the moodle ... something like devmoodle.tcea.org ... which wasn't present in any DNS anywhere.  

Why did I do that?   With 100+ curious educators and techies in the room, even IF I asked them not to attempt acquiring an account, many would.   Sometimes, about half way through the presentation, I'd get a question from one in the audience that was bold enough to ask why they couldn't get to the site they were seeing projected on the screen.   Wink! Wink!   Told them I'd be happy to explain and show them after the presentation was over! (in many presentations/sessions similar, had only 1 network tech wanna know!).

Anyhoo ... 

If one looks at docs for setting up a moodle with true hosting, 2 things should be first ... would be first ... a fully qualified domain name ... which should be used for the install ... and apache/web service running under https ... Https a little too techie for a beginner, but maybe not a FQDN.

If not giving presentations, etc. one could use what one sees in tutorials for home networks ... something like devmoodle.mynet.lan.

In the host file of a Mac or PC one could map that IP to the 'fake' FQDN.   Thus access to the moodle ... and the config.php and all the tables in the DB that referred to the moodle ... would never change.

About WSL linux offerings ... not doing anyone any favor by offering 16.04 ... even if it is long term support.    Just so happens I've spent last week with a 1U Dell PowerEdge 1950 drop shipped to me to fix the moodle that has Ubuntu 16.04 installed.  1950 was model number of server ... not anything to do with date ... That server has a thing called DRAC on it.   Think when customer got the server first setup, back then, the focus was protections for Windows servers.   Took days to find old documentation for 16.04 to set the guest OS with a static IP so I could work on fixing ... then getting site backup + course backups off that box to customer.    A server with no networking (TCP/IP stack) makes for a very good boat anchor! :|

So for simplicity, Ubuntu means what?  Ubuntu's latest and greatest?

Also ... php-sodium extension wasn't listed ... but newer versions of Moodle will recommend it be installed.

Again ... good work!

'SoS', Ken

In reply to Ken Task

Re: Documenting a Moodle install on WSL

by James Steerpike -
I can see the advantages of running old versions but perhaps not for Moodle.
I see WSL as a stepping stone. There is more than enough to handle for someone who wants to run a LAMP Moodle.. For a FQDN I think you need a cloud server and maybe that will be my next documentation project, WSL takes you half way there while providing a usable Moodle for admin or content creation. Mostly I see it for tinkering, which is really hands-on learning.
One problem for Linux has always been competing ways to do things. Ubuntu, Apache and mysql are good choices for a newbie and eliminating "if this, do this, if that do that" does makes things simpler. Anyone who decides Debian, Nginx or whatever is better should be able to adapt for their favourite setup.







I thi
In reply to James Steerpike

Re: Documenting a Moodle install on WSL

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
I don't know WSL, but it sounds like virtualization to me, comparable to VMWare/VirtualBox. If its IP 192.168.0.X is reachable in the LAN, that means the network of the virtualized environment is bridged to the host network. What is the IP of the host, your Windows machine? I expect it to be in the same IP network, so 192.168.0.Y. If so, configure Moodle to $CFG->wwwroot='http://192.168.0.X';
In reply to Visvanath Ratnaweera

Re: Documenting a Moodle install on WSL

by James Steerpike -
The problem was in doing the browser installation on localhost. Changing $CFG would have fixed it but I wanted to test my instructions so I went back to scratch and used the IP address this time.
I have gone as far as I want on the document in adding a plugin install requiring permission changes. I wouldn't want to add students but for learning a Moodle LAMP install it should be useful.
Anyone managed to follow and create a WSL LAMP Moodle?



In reply to James Steerpike

Re: Documenting a Moodle install on WSL

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
> The problem was in doing the browser installation on localhost.

Do you mean, you kick the install script from the browser in the Ubuntu Linux? I assumed it to be the Ubuntu Server, i.e. CLI only and therefore the browser to be from the host, the Windows machine - so _host_ not localhost.

If ultimately everything is in a full Ubuntu Linux (GUI), what is the difference between a "Moodle install on WSL" and "Moodle install on a desktop Ubuntu"?
In reply to Visvanath Ratnaweera

Re: Documenting a Moodle install on WSL

by James Steerpike -
Do you mean, you kick the install script from the browser in the Ubuntu Linux?
There is no browser in the WSL Ubuntu I installed, No gui either. It is command line only and the browser runs on Windows and both the VM Linux and the Windows box have the same IP address. Which is why when I specified localhost as my Moodle address, only the Win machine running the VM could see it. and not networked machines.

If ultimately everything is in a full Ubuntu Linux (GUI), what is the difference between a "Moodle install on WSL" and "Moodle install on a desktop Ubuntu"?

Moodle install on a CLI Ubunto Server actually.
I could have written a 2 line document.
  1. Open a Windows command line and type wsl --install -d Ubuntu
  2. Refer to the Moodle Installation Guide
But which installation guide?
  • There is the Installation quick guide intended for administrators who are experienced with installing web server applications.
  • Installing Moodle - again written at SysAdmin level
  • Installing Moodle on Debian based distributions looks promising as Ubuntu is a Debian based distro. Installing php7.1 though? Looks to be out of date and skimpy on detail.
  • But there is the Step-by-step Installation Guide for Ubuntu, the best so far.

The best but:

  • It recommends Vim, the world's most unfriendly text editor when the nano editor is standard on even a bare Ubuntu install.
  • It takes over 2500 words to tell you how to install a LAMP stack.  In all of that, it doesn't tell you how important it is to setup cron (a cron page link does appear on a sidebar).
  • The plugin page is also linked but that page does not tell you what to do when your folder is not writable. After all, that is Linux specific but the Ubuntu page does not tell how to make a folder temporally writable.  
  • Information in some areas appears confusing. For instance do we still need to add to add repositories for php7? Are there versions of Ubuntu with mysql lower than version 8 that require editing of config files?
Documentation tends to grow and I have added to it.  I think the whole area needs pruning.
In reply to James Steerpike

Re: Documenting a Moodle install on WSL

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Hi James

You wrote:
> There is no browser in the WSL Ubuntu I installed, No gui either. It is command line only and the browser runs on Windows and both the VM Linux and the Windows box have the same IP address.

Sorry, that is not what I expected. I haven't tried WSL. (You know, everything starting with a 'W' stays out of my computers.) Then WSL more a container rather than a VM. Not that it is bad, one just has to know.

> Which is why when I specified localhost as my Moodle address, only the Win machine running the VM could see it. and not networked machines.

That is the normal behaviour. Each machine its own localhost.

> Moodle install on a CLI Ubunto Server actually.
> I could have written a 2 line document.
> > Open a Windows command line and type wsl --install -d Ubuntu

Odd. There are so many Ubuntu Linux flavours. WSL seems to call one of them Ubuntu.

> Refer to the Moodle Installation Guide
> > But which installation guide?

Don't ask me. The last time I raised the same question, I was asked not to whine here.
sad
In reply to Visvanath Ratnaweera

Re: Documenting a Moodle install on WSL

by Hugo Ribeiro -
Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Does cron works on WSL? Never managed to set it up
In reply to James Steerpike

Re: Documenting a Moodle install on WSL

by AL Rachels -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Any idea as to what the trick is to get copy and paste to work in the Ubuntu terminal window?
In reply to AL Rachels

Re: Documenting a Moodle install on WSL

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
The perils of copy-and-paste on terminals aside, Ctrl-Shift-C for copy, Ctrl-Shift-V for paste on Xterm and the like.
big grin
Average of ratings: Useful (1)
In reply to James Steerpike

Re: Documenting a Moodle install on WSL

by Roberto Catanuto -
Hi James, I was searching something like this. We have a resourceful W10 computer at school, but I want to tinker a bit with installing Moodle 4.0 on a Linux-based machine, without removing W10 altogether. If your Guide is still open, I'd be glad to test it and give you some feedback

In reply to Roberto Catanuto

Re: Documenting a Moodle install on WSL

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
I'm not James, and I know, this comes very late. But if you have a powerful machine running Microsoft Windows 10 and don't want to touch the OS, there is a well-known, well-documented path: Install a virtualizer like VirtualBox and install pure Linux distros on that. See "Video Tutorial - Install Moodle on a virtual Box from scratch" https://moodle.org/mod/forum/discuss.php?d=199542#p870100.

Or, is decade old technology is outdated? WSL https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux is an imitation of Cygwin https://en.wikipedia.org/wiki/Cygwin. AFAICS Microsoft is peddling back to conventional Linux distros, not one but two!

In reply to Visvanath Ratnaweera

Re: Documenting a Moodle install on WSL

by Roberto Catanuto -
Thanks for those links, but in this field 10+ years ago, well means a lot. Those posts date back to 2012.
In reply to Roberto Catanuto

Re: Documenting a Moodle install on WSL

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Do you "feel" 10+ years to be a lot? Or did you find inaccuracies due to age? Can you show them?

Believe it or not, I found somebody in our local Linux community who would send me his paper copy of "Pascal User Manual and Report" Jensen and Wirth, Second Corrected Reprint of the Second Edition from 1978 for teaching programming in schools in the third world. Not because of nostaligia, because Pascal is the language in their curriculum. I have to admit that it suits me, I was lucky enough to learn (structured) programming from from the greats. https://en.wikipedia.org/wiki/Niklaus_Wirth (Turing Award 1984!)
wink

Back to your Moodle installation, I am not saying that VirtualBox is the only solution, there are simply too many alternatives. For example, you can leave your W10 box alone and buy a Raspberry Pi and write MoodleBox https://moodlebox.net image in a SD card, stick it in and power up.

In reply to Visvanath Ratnaweera

Re: Documenting a Moodle install on WSL

by jhon walker -
It is RedHat 6.10, and from what I can tell, it is no longer supported. I was given the task of maintaining this LMS for the next few months while we migrate our data centre to AWS. I updated Moodle because we experienced SCORM problems, which I know were resolved in subsequent versions.
In reply to Roberto Catanuto

Re: Documenting a Moodle install on WSL

by James Steerpike -
For tinkering, a good choice. Tinkering sounds dismissive but actually it is hands on learning on a Linux machine. Realize its limitations though, it is not suitable for a production server.
I find it easier to install than a virtual machine. It may not be, as Visvanath says the best technology but sometimes simple beats best. You can install from the Windows App store.