SummaryThis guide serves for administrators in large institutions who needs to upgrade their Moodle version to the latest version. Administrators usually forgets to upgrade their Moodle and the problem is that the web interface connects to Moodle developer's server and attempts to upgrade to the latest version directly where as time passes, this does not work due to the administrators' Moodles' version far behind the latest version. If I am not wrong, the web interface will show that the upgrade button is no longer supported due to the far behind version and asked to upgrade manually.
My Server Specifications
I have the following packages installed: sudo apt install apache2 mysql-server php php-mysql php-xml php-curl php-zip php-gd php-mbstring php-xmlrpc php-soap php-intl If using newer version like php7, I recommend to install php5 stable along side it because we are handling older version of Moodle, so follow https://lornajane.net/posts/2016/php-7-0-and-5-6-on-ubuntu: sudo add-apt-repository ppa:ondrej/php sudo apt update sudo apt install php5.6 php7.0 Here is an example command to switch from php7 to php5.6 sudo a2dismod php7.0 sudo a2enmod php5.6 sudo service apache2 restart Backup your Moodle
sudo cp -rv /var/www/yourmoodledata /var/www/yourmoodledatabackup sudo cp -rv /var/www/html/yourmoodle /var/www/html/yourmoodlebackup sudo mysqldump -u root -p yourpassword yourmoodle.sql > yourmoodle.sql For safety try on a duplicate moodle first or ignore this suggestion if you are confidentsudo cp -rv /var/www/html/yourmoodle /var/www/html/youmoodleduplicate sudo cp -rv /var/www/html/yourmoodledata /var/www/yourmoodledataduplicate sudo chown -R www-data /var/www/html/yourmoodledataduplicate sudo mysql -u root -p create database yourmoodleduplicate; quit mysql -u root -p yourmoodleduplicate < yourmoodle.sql
Delete Any Moodle CustomizationUnfortunately I didn’t succeed in upgrading customized moodle, you have to download fresh moodle and replace your current moodle directory. I like using git here. cp -v /var/www/html/yourmoodleduplicate/config.php /var/www/html/config.php rm -rv /var/www/html/yourmoodleduplicate If using git: git clone git://git.moodle.org/moodle.git /var/www/html/yourmoodleduplicate cp -v /var/www/html/config.php /var/www/html/yourmoodleduplicate/config.php cd /var/www/html/yourmoodleduplicate && git checkout MOODLE_19_STABLE If not, download moodle 1.9 stable (depending on your start) and name it /var/www/html/yourmoodleduplicate. Convert Database to UTF8Access from your browser your moodle site for example http://localhost/yourmoodleduplicate. Login to your administrator account and follow the instructions. It may ask you for some unicode stuff to your moodle database. If so follow instructions here https://docs.moodle.org/32/en/Converting_your_MySQL_database_to_UTF8: mysqldump -u root -p your password -c -e --default-character-set=utf8mb4 --single-transaction --skip-set-charset --add-drop-database -B --no-data yourmoodledatabase > dump.sql sed -i.bak -e 's/DEFAULT CHARACTER SET latin1/DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci/' -e 's/DEFAULT CHARSET=latin1/DEFAULT CHARSET=utf8mb4/' dump.sql sed -i.bak2 's/ENGINE=InnoDB/ENGINE=InnoDB ROW_FORMAT=DYNAMIC/' dump.sql mysql -u root -p yourpassword < dump.sql mysqldump -u root -p yourpassword -c -e --default-character-set=utf8mb4 --single-transaction --skip-set-charset --add-drop-database -B --no-create-info yourmoodledatabase > data.sql mysql -u root -p yourpassword < data.sql If it’s asking for more php dependencies then install for example if it asks for php curl then “apt install php5.6-curl”. Login to your administrator account again after finishing. Upgrade to Moodle 2.2Download next higher stable version of fresh moodle and replace your current moodle directory. I like using git here and if using git: cd /var/www/html/yourmoodleduplicate && git checkout MOODLE_22_STABLE If not, download moodle 2.2 stable and replace /var/www/html/yourmoodleduplicate. Access from your browser your moodle site for example http://localhost/yourmoodleduplicate. Login to your administrator account and follow the instructions. Login to your administrator account again after finishing. Upgrade to Moodle 2.7Download next higher stable version of fresh moodle and replace your current moodle directory. I like using git here and if using git: cd /var/www/html/yourmoodleduplicate && git checkout MOODLE_27_STABLE If not, download moodle 2.7 stable and replace /var/www/html/yourmoodleduplicate. Access from your browser your moodle site for example http://localhost/yourmoodleduplicate. Login to your administrator account and follow the instructions. Install dependencies if it asks. Login to your administrator account again after finishing. Upgrade to Moodle 2.9Download next higher stable version of fresh moodle and replace your current moodle directory. I like using git here and if using git: cd /var/www/html/yourmoodleduplicate && git checkout MOODLE_29_STABLE If not, download moodle 2.9 stable and replace /var/www/html/yourmoodleduplicate. Access from your browser your moodle site for example http://localhost/yourmoodleduplicate. Login to your administrator account and follow the instructions. Install dependencies if it asks. Login to your administrator account again after finishing. Change database to innodbIt may ask to change your database engine to innodb, follow instruction here http://www.woblag.com/2012/04/moodle-php-script-to-convert-mysql.html: Create a script for example yourscript.php: <?php // WARNING: PLEASE TEST BEFORE RUNNING ON A PRODUCTION DATABASE // Tested on Moodle 1.9 and Moodle 2.0/2.2 // // Disclaimer: // // This script was written to be executed from the command line in // Linux using a MYSQL database // and MYISAM storage engine. It converts the storage engine to // INNODB using the ALTER TABLE command. // // It assumes that the INNODB engine has been enabled. // This can be confirmed by logging into the mysql prompt // and running the command: // show engines; // // If it is disabled, check your my.cnf and // comment out the line: skip-innodb // // It does not check if disabled, so the script would execute //and attempt to co // It contains secure information, so DO NOT PLACE IN WEB DIRECTORY // // Execute from /temp and delete afterwards // // This is a modification of a script located here: // http://stackoverflow.com/questions/3856435/how-to-convert-all-tables-from-myisam-to-innodb // // Version : 1.2 // Date : 11 April 2012 // Diff : check for recordset before executing alter table // // Version : 1.1 // Date : 31 January 2012 // Diff : Added Timer to script; Display user and DB being affected // // // Version : 1.0 // Date : 25 January 2012 // // // // Noveck Gowandan http://noveckg.blogspot.com //Time Calculation - start count $time = explode(' ',microtime()); $time = $time[1] + $time[0]; //return array $begintime = $time; //define begin time //Your database connection items here $host = 'myhost'; //Specify host $dbuser = 'myuser'; // Specify user with alter permissions $dbpass = 'mypass'; //user password $mydb = 'mydb'; //specify schema or db to be modified //connect to database using variables above $link = mysql_connect($host,$dbuser,$dbpass); $db = mysql_select_db($mydb); if (!$link) { die('Could not connect: ' . mysql_error()); } echo "Connected Successfully to: $host." . "\n\n"; echo "Using database: $mydb." . "\n\n"; echo "Running script as $dbuser." . "\n\n"; //show tables in database $sql = 'SHOW TABLES'; $rs = mysql_query($sql); echo $sql; echo "\n"; if (!$rs) { die('SQL Recordset Error: ' . mysql_error()); } else { //loop through tables and convert to InnoDB while($row = mysql_fetch_array($rs)) { $tbl = $row[0]; $sql = "ALTER TABLE $tbl engine=InnoDB;"; mysql_query($sql); echo $sql; echo "\n"; } echo 'Operation Completed.' . "\n\n"; echo 'Confirm Storage Engine conversion using phpmyadmin ' . "\n" . 'or from mysql: show create table tblname.' . "\n"; } //close connection mysql_close($link); $time = explode(" ", microtime()); $time = $time[1] + $time[0]; $endtime = $time; //define end time $totaltime = ($endtime - $begintime); echo "Script Execution Time: $totaltime" . " seconds." . "\n\n"; ?> For me, php5.6 works: php5.6 yourscript.php Continue with Moodle upgrade on the web. Upgrade to Moodle 3.2Download next higher stable version of fresh moodle and replace your current moodle directory. I like using git here and if using git: cd /var/www/html/yourmoodleduplicate && git checkout MOODLE_32_STABLE If not, download moodle 3.2 stable and replace /var/www/html/yourmoodleduplicate. Access from your browser your moodle site for example http://localhost/yourmoodleduplicate. Login to your administrator account and follow the instructions. Install dependencies if it asks. Login to your administrator account again after finishing.
0 Comments
Leave a Reply. |
Archives
August 2022
Categories
All
source code
old source code Get any amount of 0FP0EXP tokens to stop automatic JavaScript Mining or get 10 0FP0EXP tokens to remove this completely. get 30 0FP0EXP Token to remove this paypal donation. Get 40 0FP0EXP Token to remove this donation notification! get 20 0FP0EXP Token to remove my personal ADS. Get 50 0FP0EXP Token to remove my NFTS advertisements! |