Upgrading Docs - Work in Progress!

I've been trying to assemble my thoughts about how to upgrade Moodle to Moodle 5.1, prior to making changes in the docs, focusing on these few sections of the official Moodle docs.

Transitioning to Moodle 5.1 and later from earlier Moodle versions

When attempting to upgrade to Moodle 5.1 or later from pre-Moodle 5.1 versions, because of changes to Moodle's code directories and its security model, you will likely not succeed with your normal upgrading method.  It is better to think of this upgrade as a "one-time transition" instead of an upgrade. Most methods of upgrading Moodle should work after this one-time transition.

Due to the directory structure changes, you should pay attention to your additional plugins.

Due to the secruity model changes, you should pay attention to Moodle's code location and which folders should be web-accessible.

Some Moodle sites placed the entire codebase in the web server’s document root (e.g., www, public_html, htdocs), while others placed it in a subfolder (e.g., www/moodle, public_html/moodle, htdocs/moodle, wwwroot/moodle). Both methods remain supported.

Moodle 5.1 now includes a /public folder that is intended to be the only /public be accessible to the public.

The simplest way to comply with Moodle 5.1’s new security model is to place the entire Moodle codebase outside of web root instead of within web root (e.g., /home/mydomain/moodle/www instead of /home/mydomain/www/moodle). This is similar to the recommended practice of placing the moodledata folder outside of web root (e.g., /home/mydomain/moodledata/www).

If you place the entire codebase in the web server’s document root you must point the “document root” to the /moodle/public folder. If you place the entire codebase in a folder outside web root, you must make a sybolic link to ../moodle/public in the webroot. There are several methods for doing this, as explained below.

Since Moodle 5.1 involves changes in structure and security, you may want to first set up Moodle 5.1 as a new instance and then migrate your old Moodle to it. Future updates can use your normal upgrade methods.

Some people manually upgrade Moodle, while others use Git. Both approaches are described below.

Moodle 5.1 in a subfolder

If you put Moodle in a subfolder of your website rather than in the domain root, then consider using the following approach. This "manual" approach assumes that you have a correctly installed and working version of Moodle 4.2.3 or later. It covers sites with URLs such as:

These instructions assume:

You can complete these steps using whatever tools you are comfortable using, such as Terminal, cPanel, or FTP. Although we want to upgrade my Moodle 5.0 to 5.1, we begin by first installing a brand new Moodle 5.1. Once we know that it is working, we will then complete the upgrade.

  1. Create a temporary database called moodlex. This will eventually be removed.
  2. Create a folder such as "sites" in /home/moodleuser. This optional step creates a folder to hold this moodle's code and future moodle code. The folder name can be anything you wish. "sites" is a suggestion, and it will be used in this example.
  3. Put the latest Moodle 5.1 tar file into "sites" and unzip it. You should now have /home/moodleuser/sites/moodle. If you use Git, the following command can download and unzip Moodle.
    git clone -b v5.1.0 https://github.com/moodle/moodle ~/mdl_sites/moodle
  4. Temporarily rename /home/moodleuser/public_html/moodle to /home/moodleuser/public_html/moodlex.
  5. Create a symbolic link to /home/moodleuser/sites/moodle/public and put it into public_html. The Terminal command to do this is:
    ln -s ~/sites/moodle/public ~/public_html/moodle. If you lack Terminal, you can accomplish this task with the php code shown below.
  6. Now is a good time to test that Moodle 5.1 runs on your server by going to www.example.com/moodle. You will be taken through Moodle's installation routine.
    Note: What you have done thus far is install new Moodle 5.1 from scratch, in four steps. Steps 7 to 10 are somewhat like "migrating" a Moodle.

  7. Move all old plugins from your old moodle to the new moodle corresponding folders.
    For example, move /home/moodleuser/public_html/moodle/checklist to /home/moodleuser/sites/moodle/public/checklist
    If desired, you can test that Moodle 5.1 sees your plugins on your server by going to www.example.com/moodle, logging in, and letting Moodle do its reinstall routine.
  8. Edit /home/moodleuser/sites/moodle/config.php. Change the database and moodledata to match your old, found in /home/moodleuser/public_html/moodlex/config.php.
  9. Go to www.example.com/moodle and log into Moodle to complete the upgrade.
  10. When successful, you can remove moodlex from public_html.

This upgrade does not disturb anything else that you might have on your web server. Also, this method supports running multiple Moodles on one server.

Git-ting Moodle

git clone -b v5.1.0 https://github.com/moodle/moodle ~moodle (from James) It works in cPanel|Terminal.

Which version of moodle gets downloaded?

What happens to this command when Moodle becomes 5.2?

 

{Editing is complete to here.}

Moodle 5.1 in your Document Root

If your Moodle site is located in the root of your website rather than a subfolder then you may be able to use the following approach. This approach covers sites with URLs such as:

These instructions assume:

Ugrade your moodle as you normally would. Don't access your moodle from your browser, yet.

Rename public_html to moodle.

Point your "Document Root" to www.example.com/public

or

mv public_html moodle

ln -s moodle/public ./public_html

Moodle in a Subdomain

If you desire to run multiple Moodle on your website with each one being at webroot, one solution is to use subdomains. This would allow the following:

This technique requires that you can create subdomains. Within a subdomain, use the "Moodle in your Document Root" techniques from above, by first installing a new Moodle 5.1 in your webroot.

Git Techniques

 Download and copy files into place

Moodle code can be placed in a folder in your web server, or directly in web root.   Sometimes this is a personal choice and sometimes it can depend on your specific system and/or web server. See the documentation for your web server if you are unsure.

Prior to Moodle 5.1, if you wanted to keep the moodle code in it's folder, it was typical to place the entire moodle folder in your web server's web root, such as ../www/moodle/.  Then from a browser on the Internet, the moodle application would be accessible at https:/yourwebserver.com/moodle/.  However, beginning with Moodle 5.1, the moodle folder cannot be web accessible, only the /public folder      .               For Moodlle 5.1 and newer, you should  link to moodle's /public folder with a symbolic link, making the moodle application accessible at https:/yourwebserver.com/moodle/, just as before.

If you want to put the moodle code in web root, you can copy all the contents from the moodle folder into you web server's web root.  However, you must configure your server's Document root to point to Moodle's /public/ folder. From a browser on the Internet, your Moodle will be simply http://yourwebserver.com.