Posts

PHP version problems

  How to force a specific version of php on linux: Let's say you want to force the linux machine to use php 7.2 specifically Do this: sudo add-apt-repository -y ppa:ondrej/php sudo apt-get install php7.2 php7.2-cli php7.2-common now tell apache: sudo a2dismod php5.6 sudo a2enmod php7.2 sudo service apache2 restart now tell bash: sudo update-alternatives --set php /usr/bin/php7.2 sudo update-alternatives --set phar /usr/bin/phar7.2 sudo update-alternatives --set phar.phar /usr/bin/phar.phar7.2

Controlling moodle from the command line when you can't login

 Sometimes you can't login to moodle because a plugin or other dependency has broken it. Install Moosh. sudo apt-add-repository 'deb http://ppa.launchpad.net/zabuch/ppa/ubuntu trusty main' sudo apt-get update sudo apt-get install moosh The command Moosh understands the following sub-commands: activity-add activity-config-set activity-delete activity-move admin-login admin-remove-orphaned-modules apache-parse-extendedlog apache-parse-missing-files apache-parse-perflog audit-passwords auth-list auth-manage backup-info badge-delete base-path block-add block-manage cache-add-redis-store cache-clear cache-config-get cache-course-rebuild cache-edit-mappings cache-test category-config-set category-create category-delete category-export category-import category-list category-move category-resortcourses chkdatadir code-check cohort-create cohort-enrol cohort-enrolfile cohort-unenrol config-get config-pl

What to do if you crashed your database

Please see this page for detailed instructions.  https://johnsmysqlblog.blogspot.com/2021/04/what-to-do-if-you-crashed-your-database.html

could not find course/ could not find top level course/ could not find course category

Could not find course category If you get this error (could not find course category) this basically means the course/s that exist don't have categories in the category table. Look at the mdl_course table in mysql. Column 2 is the course category. Every course listed (per row) must have a category identified in the table mdl_course_categories . For example, if you have this as your data (1, 0 , 0, "course name", " course name ", "", "summary" , 0, "site", 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", "", "", 1606214720, 1606215795, 0, 0, 0, 1606215383); You see the course category is zero . But there is a course category number one in the mdl_course_categories  table: |  1 | Miscellaneous | NULL     | NULL        |                 0 |      0 |     10000 |           0 |       1 |          1 |   1606214720 |     1 | /1   | NULL  | If there is a mismatch, correct it, e.g. by updating the course to belon

Making a new moodle instance

Once you have installed Moodle and have it working, you might need to make new instances for new organisations. That is, you might not want to share your first instance (copy) with other organisations, but you might get asked to nonetheless do so. The easiest way around this is to make a copy of a working copy of Moodle.  I find Moodle is a bit easy to destabilise/break with plugins or changes, hence, it is also best just to take a backup copy anyway. By default, Moodle consists of three main parts. The app, the database, and the varying/variable data or caches. Caches and variable data are usually in /var/www/moodledata The app itself is usually in /var/www/html/moodle The database is usually in mysql or similar. Once you have it installed and working, I'd suggest immediately making a backup copy to use for creating instances later on. I'd suggest doing it straight away because it is quite quick to climb up to 1 GB or larger which takes ages to process. To make the backup, o

choosing a php version

Moodle is fussy about which version of php it wants. Let's say it wants php7.1 specifically. Type the following commands: sudo add-apt-repository ppa:ondrej/php sudo apt-get update sudo apt-get install php7.1 sudo apt-get install php7.1-cli php7.1-common php7.1-json php7.1-opcache php7.1-mysql php7.1-mbstring php7.1-mcrypt php7.1-zip php7.1-fpm sudo a2dismod php7.2 sudo a2enmod php7.1 sudo service apache2 restart

php file size upload limits too low

By default, php allows 2-8 MB file size uploads. These days, you need probably 1-2 GB in case someone wants to upload a video. [edit] /etc/php/php.ini find other versions: find /etc/php -name "php.ini*" -name edit those as well Search for these entries and change them as shown: post_max_size = 2000M upload_max_filesize = 2000M