Moodle Upgrade 4.2.3 to 5.1

From Notes_Wiki
Revision as of 06:32, 16 October 2025 by Kamal (talk | contribs)

Home > Ubuntu > Ubuntu 22.04 > Ubuntu 22.04 Moodle Upgrade > Moodle Upgrade 4.2.3 to 5.1

  • Take the DB dump
mysqldump -u <db-user> -p <db-name> > moodle_db_backup_before_5.sql
  • Backup moodle directories
sudo tar czf moodledata_backup_before_5.tar.gz /var/moodledata
 
sudo tar czf moodle_code_backup_before_5.tar.gz /var/www/html/moodle
  • Go to moodle directory
 
cd /var/www/html
  • Rename the old moodle folder
 
sudo mv moodle moodle_old_42
  • Download the moodle package from the official website and extract the package
sudo tar -zxvf moodle-latest-501.tgz
  • Copy the configuration file from the old moodle
sudo cp moodle_old_42/config.php moodle/
  • Give required permissions and ownership
sudo chown -R www-data:www-data moodle

sudo chmod -R 755 moodle

sudo chown -R www-data:www-data /var/moodledata
  • Update the apache file:
vim /etc/apache2/sites-available/000-default.conf

	DocumentRoot /var/www/html/moodle/public
	<Directory /var/www/html/moodle/public>	
  • Update the default SSL file:
vim /etc/apache2/sites-available/default-ssl.conf

	DocumentRoot /var/www/html/moodle/public
  • Restart the webserver:
sudo systemctl reload apache2
  • Install PHP 8.4:
sudo apt update

sudo apt upgrade -y

sudo apt install software-properties-common ca-certificates lsb-release apt-transport-https -y

sudo add-apt-repository ppa:ondrej/php

sudo apt install php8.4 libapache2-mod-php8.4 -y

sudo apt install php8.4-mysql php8.4-cli php8.4-common php8.4-curl php8.4-gd php8.4-mbstring php8.4-xml php8.4-zip -y
  • Disable the php8.1 module:
a2dismod php8.1
  • Enable the php8.4:
sudo a2enmod php8.4
  • Check the PHP Version:
php -v
  • Use the below command to select the php8.4 version, if the version is not reflected:
sudo update-alternatives --config php
  • Restart the webserver:
sudo systemctl restart apache2
  • Edit the php.in file, uncomment and change the value to 5000
vim /etc/php/8.4/apache2/php.ini

	max_input_vars = 5000
  • Download MYSQL 8.4 version:
wget https://dev.mysql.com/get/mysql-apt-config_0.8.33-1_all.deb
  • Install the package:
sudo dpkg -i mysql-apt-config_0.8.33-1_all.deb
  • Select 8.3 version
  • Update the repositories:
sudo apt update
  • Install mysql-server:
sudo apt install mysql-server -y
  • Restart mysql and apache:
sudo systemctl restart mysql

sudo systemctl restart apache2
  • Install php extensions:
sudo apt install -y php8.4-curl php8.4-intl php8.4-soap

sudo apt-get install php8.4-ldap
  • Restart the webserver:
sudo systemctl restart apache2
  • Install composer:
apt install composer
  • Run the below command in the moodle directory:
composer install --no-dev --classmap-authoritative
  • Give required permissions and ownerships:
sudo chown -R www-data:www-data /var/www/html/moodle/vendor

sudo chmod -R 755 /var/www/html/moodle/vendor

Restart the web server:

sudo systemctl restart apache2
  • Open the website on a browser and follow the steps to upgrade Moodle.