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.
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.
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.
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.}
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
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.
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.