Upgrading: Difference between revisions

From MoodleDocs
mNo edit summary
Update nginx configuration
Line 46: Line 46:


In Nginx:
In Nginx:
 
root /var/www/moodle/public;
''Info to be added...''
 
Apply the change then restart the web server.
Apply the change then restart the web server.



Revision as of 09:20, 3 October 2025

This page explains in detail how to upgrade Moodle. For a summary of the process, see Upgrade overview.

Warning: The directory structure of Moodle files has changed in 5.1. A new "public" folder has been introduced to contain all web accessible files. Configuration and other sensitive files are now stored below this folder for better security. You will need to reconfigure your web server to accommodate this change as part of the upgrade process. See the section below Code directories restructure.


Check the requirements

Note: You need to upgrade to Moodle 4.1.2 or later before upgrading to 5.2.

Before upgrading, check that your server meets all requirements for 5.2 in Site administration > Server > Environment.

See the Moodle 5.2 release notes for server and client software requirements.

Before upgrading

We advise that you test the upgrade first on a COPY of your production site, to make sure it works as you expect.

Consider setting the upgrade key for your site.

Backup important data

There are three areas that should be backed up before any upgrade:

  1. Moodle software (For example, everything in server/htdocs/moodle)
  2. Moodle uploaded files (For example, server/moodledata)
  3. Moodle database (For example, your Postgres or MySQL database dump)

See Site backup for more specific information.

Check for plugin updates

If you have Automatic updates deployment enabled, you will be able to update installed plugins automatically during the upgrade. Just make sure you check for available updates (via the button for it) at the Plugins check screen.

If you are updating plugins manually, it is a good moment now to check in the Moodle Plugins directory whether there is a 5.2 version available for any plugins (including themes) installed on your site. If so, download the plugin package. In the next step, you will copy it to the appropriate location in your Moodle code (see Installing plugins).

The upgrade of the plugin will then happen as part of the Moodle upgrade process.

If an out-of-date plugin causes your upgrade to fail, you can usually delete the plugin code rather than uninstalling it from within Moodle so that the data associated with it is not deleted.

Put your site into maintenance mode

Before you begin upgrading your site, you should put it into maintenance mode to stop any non-admin users from logging in. Then you should wait for any currently running cron processes to complete before proceeding.

Code directories restructure

The directory structure of Moodle files has changed in 5.1. In previous versions, the entire Moodle codebase sat within the web server’s document root. From Moodle 5.1 onwards, only the files that are safe to be accessed directly are located in /public.

Important: You need to update your web server configuration so that the document root points to /moodle/public.

In Apache:

DocumentRoot /var/www/moodle/public
<Directory /var/www/moodle/public>
   AllowOverride None
   Require all granted
</Directory>

In Nginx:

root /var/www/moodle/public;

Apply the change then restart the web server.

Install the new Moodle software

You can download the latest release from Moodle downloads.

Standard install package

  1. Move your old Moodle software program files to another location. Do NOT copy new files over the old files.
  2. Unzip or unpack the upgrade file so that all the new Moodle software program files are in the location the old files used to be in on the server. Moodle will adjust SQL and moodledata if it needs to in the upgrade.
  3. Copy your old config.php file back to the new Moodle directory.

As mentioned above, if you had installed any plugins on your site you should add them to the new code tree (Moodle directory structure) now. It is important to check that you get the correct version for your new version of Moodle. Be particularly careful that you do not overwrite any code in the new version of Moodle and that you place the plugin folders in the correct directory (the same directory that they are in in the current installation.)

Your moodledata folder should be located separately to your Moodle code folder and, as such, should not need anything done to it. Moodle 3.0 will throw a warning if it is located in a web accessible folder and the moodledata should never be located in the Moodle code folder. If you are moving your installation to a new server or new location on your server, then you will need to follow the Migration documents.

Linux

mv moodle moodle.backup
tar xvzf moodle-latest-5.2.tgz

Next, copy across your config.php, any custom plugins, and your .htaccess file if you created one (check that custom plugins are the correct version for your new Moodle first):

cp moodle.backup/config.php moodle
cp -pr moodle.backup/theme/mytheme moodle/public/theme/mytheme
cp -pr moodle.backup/mod/mymod moodle/public/mod/mymod

Don't forget to make moodle/config.php (and the rest of the source code) readable by your www server. For maximum security the files should not be writeable by your server. This is especially important on a 'production' server open to the public internet.

chown -R root:root moodle (Linux debian - or even create a user especially for moodle. Don't use the web server user, e.g. www-data)
chmod -R 755 moodle

If you use cron, take care that cron.php is executeable and uses the correct php command:

chmod 740 admin/cli/cron.php (some configurations need chmod 750 or chmod 755)
copy the first line from cron.php (if it looks like '#!/usr/local/bin/php' or '#!/usr/local/bin/php5.3', no need to copy '<?php') 

if necessary. However, for a simple upgrade, there should be no need to change anything with cron.

Using Git

You can use Git for updating or upgrading your Moodle. See Git for Administrators for details.

Command line upgrade

On Linux servers, Moodle 5.2 supports running the upgrade from the command line, rather than through a web browser. This is likely to be more reliable, particularly for large sites.

Finishing the upgrade

The last step is to trigger the upgrade processes within Moodle.

If you put your site into Maintenance mode earlier; take it out now!

To do this just go to Site administration > Notifications.

Moodle will automatically detect the new version and perform all the SQL database or file system upgrades that are necessary. If there is anything it can't do itself (very rare) then you will see messages telling you what you need to do.

Assuming all goes well (no error messages) then you can start using your new version of Moodle and enjoy the new features!

Note: If you are running multiple servers or find some functionality missing (such as the filepicker not loading) then you should purge all caches manually (via Site administration > Development > Purge all caches) after completing the upgrade.

Fatal error: Maximum execution time of 30 seconds exceeded...

If your server uses a main language other than English, you may encounter a 'Fatal error: Maximum execution time of 30 seconds exceeded' when you try to upgrade it. You can increase max_execution_time = 160 on php.ini to allow the scripts enough time to process the language update. Otherwise, you can switch to English as the default language before doing the upgrade and back to your original language after a successful upgrade. See the forum discussion at https://moodle.org/mod/forum/discuss.php?d=119598.

Possible issues that may affect you in Moodle 5.2

Moodle code restructure

As noted above, the directory structure of Moodle files has changed. Make sure your web server has been configured to use this new structure. For configuration information, see Code Restructure | Moodle Developer Resources.

Activity chooser enhancements

Activity chooser items are organised into categories according to their purpose.

The setting 'Activity chooser tabs' in the Site administration is removed, as activities are no longer classified as activity or resource.

In the Activity chooser, to select an activity, you need to click it and then click the Add button. Alternatively, to quickly go to the Add activity page you can double-click an activity. Previously, a single click took you to the Add activity page; the Add button provides an improved user experience.

Activities and Section links blocks removed

The Activities and Section links blocks are no longer included in Moodle 5.1 onwards, as the functionality is provided elsewhere. The Activities overview lists all activities in the course and the course index includes links to sections.

Main menu block renamed Additional activities block

The Main menu block is renamed Additional activities block. The block can also be used in courses in Single activity format to show links to additional activities in the course. The title of the block can be changed if required.

Social course format is disabled by default

Social course format is disabled by default in Site administration > Plugins > Manage course formats in Moodle 5.1 onwards, and will be removed in a future version, as the functionality is provided by Single activity format with Forum as the type of activity.

Any courses using Social format will remain unchanged, though it is recommended that you change the course format to Single activity format with Forum as the type of activity.

Forgotten password page reCAPTCHA

You can protect against automated attacks by adding reCAPTCHA to the forgotten password page in Site administration > Plugins > Manage authentication.

Media drag and drop setting removed

Media drag and drop is always enabled. The setting 'Media drag and drop' (label | dndmedia) in Site administration > Plugins > Text and media area is removed, as there is no reason to disable the functionality.

Maximum number of sections setting deprecated

The setting 'Maximum number of sections' (maxsections) in Site administration > Courses > Course default settings is no longer used in any standard feature. The setting is deprecated and will be removed in a future version. A teacher can add as many sections as they want to their course with no limit.


See also the list of upgrade_notes-labelled issues and ui_change-labelled issues.

New capabilities in Moodle 5.2

  • moodle/customfield:configureshared

Moodle 4.1, 4.2, 4.3, 4.4 and 4.5 upgrading notes

Depending on which version you are upgrading from, please see the section 'Possible issues that may affect you' in the documentation:

Any questions about the process?

Please post in the Installing and upgrading help forum on moodle.org.