Posts

Showing posts from February, 2021

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

reset user password in moodle

Open mysql:  mysql -u root -p choose your database: use moodle; [whatever the moodle instance is called] Now change the password: update mdl_user set password=MD5('password') where username='admin';  exit;

"unknown category" - error and white screen of death error

 If moodle gives you an error called 'unknown category' and / or goes blank, this is the fix: cd /var/www/html/moodle pico config.php look for the line that mentions a theme: $CFG->theme='boost'; put a hash mark in front of it, like so: # $CFG->theme='boost'; this line in the config file basically forces moodle to use the default theme. discussion is here:  https://moodle.org/mod/forum/discuss.php?d=393412

Saving the mysql password

If you find it a nuisance to constantly type the mysql password while working with mysql, you can tell it to save, and thereafter it won't ask for it. WARNING. This exposes your database to hackers in that if they gain access to your account, your copy of mysql is also vulneralble. The command is: mysql_config_editor set --host=localhost --user=<whoever> --password

Granting permissions on a database

Login to mysql and run this, where "database" is your database, "username" is your database username, and "password" is your preferred password. grant all on database.* to 'username'@'localhost' identified with mysql_native_password by "password"; Note this is for mysql 8 and above, mysql 5 and below you remove the "with mysql_native_password" part.

Creating a moodle database

 When creating the moodle database, you need to set the owner. First, create the database. mysql> create database  moodle ; then create the  user who will have write permissions: mysql> create user ' moodle '@' localhost ' identified  with mysql_native_password  by ' somepassword '; mysql> flush privileges; If you forget the password, you can change it again like so: mysql> alter user ' moodle'@'localhost'  identified  with mysql_native_password  by ' somepassword '; If you are using mysql version 8 or later, you need "with mysql_native_password" otherwise wordpress doesn't authenticate the database owner. At least, that was still true at the time of writing this. If you are using mysql version 5 or below, you can skip that. 

bulk deleting users from moodle using mysql

Login to mysql, e.g. mysql -u root -p [password_for_database] type: use database mymoodle; [where mymoodle is the name of your moodle database] Suppose now that you want to delete ALL users except "john" and "admin", you would type: delete from mymoodle.mdl_users where (username not like "%admin%" and username not like "%john%"); exit; That's all.

Purpose of this blog

 The purpose of this blog is to list solutions for common problems with the opensource e-learning package "moodle".