Installing Moodle: Difference between revisions

From Newroco Tech Docs
Jump to navigationJump to search
 
(3 intermediate revisions by 2 users not shown)
Line 9: Line 9:
sudo apt-get install php-zip php-xml php-mbstring php-ldap libapache2-mod-php
sudo apt-get install php-zip php-xml php-mbstring php-ldap libapache2-mod-php
sudo apt-get install postgresql postgresql-contrib
sudo apt-get install postgresql postgresql-contrib
sudo apt-get install unoconv ghostscript
</pre>
</pre>


Line 310: Line 311:
<pre>
<pre>
cd /opt
cd /opt
git clone git://git.moodle.org/moodle.git
git clone https://github.com/moodle/moodle.git
cd moodle
cd moodle
git branch -a                                                  (2)
git branch -a                                                  (2)
Line 338: Line 339:
<pre>
<pre>
cd  /opt/old_moodle/blocks
cd  /opt/old_moodle/blocks
diff -q /opt/old_moodle/blocks/ /var/www/html/moodle/blocks/
cp -r community attendance teaching_team karma participants quickfindlist turnitin /var/www/html/moodle/blocks
cp -r community attendance teaching_team karma participants quickfindlist turnitin /var/www/html/moodle/blocks
sudo cp -r /opt/old_moodle/local/mass_enroll /var/www/html/moodle/local
sudo cp -r /opt/old_moodle/local/mass_enroll /var/www/html/moodle/local
Line 366: Line 368:
</pre>
</pre>


'''Since V3.9 the configuration has changed and the custom theme settings  might hide or disable some buttons of functions. In this case check /var/www/html/moodle/lib/form/filemanager.js
Notice: After disabling the maintenance mode go to your website and finish the upgrade process via interface. Afterwards it might pop up the update plugins, check if they are stable with the current version of the moodle update and do them.
and /var/www/html/moodle/lib/navigation.php for any configuration options!!!'''
If everything goes well it will pop up a reports page with the status of each settings, for safety reasons move the node_modules from moodle folder or delete it so it wont have a security breach due to it.Also for config.php if it pops up warning/critical messages you should leave permissions only for read to the file. And via moodle interface -> site administration -> disable the following if they pop up in the reports ... .swf , enable site(secure) cookies. For web cron warning enable the setting that will not allow anonymous users to access cron. via search


Notice: After disabling the maintance mode go to your website and finish the upgrade process via interface. Afterwards it might pop up the update plugins, check if they are stable with the current version of the moodle update and do them.
== Bug : errors generated by /var/www/html/moodle/lib/form/filemanager.js ==
If everything goes well it will pop up a reports page with the status of each settings, for safety reasons move the node_modules from moodle folder or delete it so it wont have a security breach due to it.Also for config.php if it pops up warning/critical messages you should leave permissions only for read to the file. And via moodle interface -> site administration -> disable the following if they pop up in the reports ... .swf , enable site(secure) cookies. For web cron warning enable the setting that will not allow anonymous users to access cron. via search
 
Since V3.9 the configuration has changed and the custom theme settings might hide or disable some buttons or functions. In this case /var/www/html/moodle/lib/form/filemanager.js is accessing some buttons without checking if they exist resulting in errors that prevent the rest of the code to run. The fix is to add some conditions to check these buttons exist on the interface before adding triggers or style to them.
Also check /var/www/html/moodle/lib/navigation.php for any configuration options!!!


== Bug : outcomes do not appear in right order on grader ==
== Bug : outcomes do not appear in right order on grader ==

Latest revision as of 08:11, 23 December 2022

Prepreq

sudo apt-get install apache2
sudo apt-get install graphviz aspell php-pspell php-xmlrpc php-ldap php-soap
sudo apt-get install php-gd php-json php-pgsql php-curl
sudo apt-get install php-intl php-mcrypt php-imagick
sudo apt-get install php-zip php-xml php-mbstring php-ldap libapache2-mod-php
sudo apt-get install postgresql postgresql-contrib
sudo apt-get install unoconv ghostscript

Creating Moodle Database

These instructions assume that the database server and web server are on the same machine

Log into the PostgreSQL command line client. The exact form depends on how your PostgreSQL is configured but will be something like

$ psql -U postgres
Password for user postgres:

Create the user for the Moodle database and assign a password:

postgres=# CREATE USER moodleuser WITH PASSWORD 'quickM@ss50';

Provide a suitably strong password. Please note that the actual authentication method depends on your PostgreSQL server's pg_hba.conf file. Some authentication methods (like ident) do not require the password.

Create the database:

postgres=# CREATE DATABASE moodle WITH OWNER moodleuser;

Edit PostgreSQL settings to allow local connections for yourdbuser to the nextcloud database (on all DB servers):

# vi /etc/postgresql/<version number>/main/pg_hba.conf

Adding a line before the default "local" permission line e.g.

# "local" is for Unix domain socket connections only
local   all      moodleuser                                trust
local   all             all                                     peer

Then restart postgresql

systemctl restart postgresql

Download and copy files into place

Setup your local repository and download Moodle, We will use /opt for this installation.

Git is what is called a "version control system". By using git it will much easier down the road to update the moodle core application. Within Step 5 there is a little more detail on why we put the moodle core application code in the /opt directory.

cd /opt

Download the Moodle Code and Index

sudo git clone git://git.moodle.org/moodle.git

or 

sudo git clone git://github.com/moodle/moodle.git

If the error appear

fatal: The remote end hung up unexpectedly7.96 MiB | 179.00 KiB/s   
fatal: early EOF
fatal: index-pack failed

try

git config --global http.postBuffer 524288000

Or

git config --global core.compression 0

Next, let's do a partial clone to truncate the amount of info coming down:

git clone --depth 1 <repo_URI>

When that works, go into the new directory and retrieve the rest of the clone:

git fetch --unshallow 

or, alternately,

git fetch --depth=2147483647

Now, do a regular pull:

git pull --all
</code/

Change directory into the downloaded Moodle folder
<pre>
cd moodle

Retrieve a list of each branch available

sudo git branch -a

Tell git which branch to track or use

sudo git branch --track MOODLE_33_STABLE origin/MOODLE_33_STABLE

Finally, Check out the Moodle version specified

sudo git checkout MOODLE_33_STABLE

Copy local repository to /var/www/html/

sudo cp -R /opt/moodle /var/www/html/
sudo mkdir /var/moodledata
sudo chown -R www-data /var/moodledata
sudo chmod -R 777 /var/moodledata
sudo chmod -R 0755 /var/www/html/moodle

Explanation

Since we setup a local repository in the previous step, you will copy it to your webroot after any updates and making changes. Having your local repository outside of the webroot, like we have in /opt, you will be able to prepare and stage your upgrades in a more efficient manner. For example, you want to make some changes or add some plug-ins, you would download the plugin and copy it to your local moodle repository. After you have added the plug-in and any other changes you might have made you will need to edit the file located in /opt/moodle/.git/info/exclude. Within that file you want to tell git which files/folders to exclude when it pulls down the updates when you run your next "sudo git pull". An example entry would be the certificate mod located in /opt/moodle/mod/certificate so within the exclude file you want to add "/mod/certificate" below the last comments. You would add additional entries, 1 per line, for each plug-in or file you might have changed. If I were to change the favicon.ico file you would just add "favicon.ico" to the exclude file. Now when you run "sudo git pull" to update moodle to the latest version it will ignore those files and directories and just update the core moodle code. Before copying to your webroot to upgrade you want to make sure and download and copy over the latest versions of the plug-ins you might have added.


IMPORTANT

While there are now a number of places you can get the Moodle code, you are strongly advised to obtain Moodle from moodle.org. If you run into problems it will be a great deal easier to support you.

Start Moodle install

Note - If you are not comfortable using terminal to create the config.php file that needs to be created when going through the installer, you should temporarily make the webroot writable by doing the following:

sudo chmod -R 777 /var/www/html/moodle

Installer

Change the path for moodledata : /var/moodledata 

Database type : postgresql

Database Settings

Host server: localhost

Database: moodle

User: moodledude (the user you created when setting up the database)

Password: passwordformoodledude (the password for the user you created)

Tables Prefix: mdl_

Open your browser and go to http://IP.ADDRESS.OF.SERVER/moodle

Or

sudo -u www-data /usr/bin/php7.0 admin/cli/install.php

                                 .-..-.       
   _____                         | || |       
  /____/-.---_  .---.  .---.  .-.| || | .---. 
  | |  _   _  |/  _  \/  _  \/  _  || |/  __ \
  * | | | | | || |_| || |_| || |_| || || |___/
    |_| |_| |_|\_____/\_____/\_____||_|\_____)

Moodle 3.3.1+ (Build: 20170714) command line installation program
-------------------------------------------------------------------------------
== Choose a language ==
en - English (en)
? - Available language packs
type value, press Enter to use default value (en)
: en
-------------------------------------------------------------------------------
== Data directories permission ==
type value, press Enter to use default value (2777)
: 
-------------------------------------------------------------------------------
== Web address ==
type value
: https://moodle.dbsberlin.newro.co/moodle    
-------------------------------------------------------------------------------
== Data directory ==
type value, press Enter to use default value (/var/www/moodledata)
: /var/moodledata
-------------------------------------------------------------------------------
== Choose database driver ==
 pgsql 
type value, press Enter to use default value (pgsql)
: pgsql
-------------------------------------------------------------------------------
== Database host ==
type value, press Enter to use default value (localhost)
: localhost
-------------------------------------------------------------------------------
== Database name ==
type value, press Enter to use default value (moodle)
: moodle
-------------------------------------------------------------------------------
== Tables prefix ==
type value, press Enter to use default value (mdl_)
: mdl_
-------------------------------------------------------------------------------
== Database port ==
type value, press Enter to use default value ()
: 5432
-------------------------------------------------------------------------------
== Database user ==
type value, press Enter to use default value (root)
: user_moodle
-------------------------------------------------------------------------------
== Database password ==
type value
: parola_moodle
-------------------------------------------------------------------------------
== Full site name ==
type value
: Moodle
-------------------------------------------------------------------------------
== Short name for site (eg single word) ==
type value
: Moodle
-------------------------------------------------------------------------------
== Admin account username ==
type value, press Enter to use default value (admin)
: admin_moodle
-------------------------------------------------------------------------------
== New admin user password ==
type value
: parola_moodle
-------------------------------------------------------------------------------
== New admin user email address ==
type value, press Enter to use default value ()
: name@newro.co
-------------------------------------------------------------------------------
== Upgrade key (leave empty to not set it) ==
type value
: 
-------------------------------------------------------------------------------
== Copyright notice ==
Moodle  - Modular Object-Oriented Dynamic Learning Environment
Copyright (C) 1999 onwards Martin Dougiamas (http://moodle.com)

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

See the Moodle License information page for full details:
http://docs.moodle.org/dev/License

Have you read these conditions and understood them?
type y (means yes) or n (means no)
: y
-------------------------------------------------------------------------------
== Setting up database ==
-->System
++ Success ++


After you have ran the installer and you have moodle setup, you need to revert the permissions so that it is no longer writable using the below command.

sudo chmod -R 0755 /var/www/html/moodle


For http

append into the confing file /var/www/http/moodle/config.php

$CFG->sslproxy=true;

Upgrade moodle to a new version

Verify the version prerequisites https://docs.moodle.org/dev/Moodle_<version>_release_notes.

Set up moodle into maintenance mode

sudo -u www-data /usr/bin/php /var/www/html/moodle/admin/cli/maintenance.php --enable

Backup the moodle folder (THere no need to copy the hole folder. Just need to have a copy of the custom changes to moodle : theme, config.php, custom plugins )

 cp -r /var/www/html/moodle/ /opt/old_moodle 


Obtaining the new code from Git ( [guide | https://docs.moodle.org/35/en/Git_for_Administrators] )

cd /opt
git clone https://github.com/moodle/moodle.git
cd moodle
git branch -a                                                   (2)
git branch --track MOODLE_35_STABLE origin/MOODLE_35_STABLE     (3)
git checkout MOODLE_35_STABLE      

Notice: If it doesn't work and pops up a message about "stash" just do:

 git stash

And afterwards redo the above step.

Delete the old version ( Don't make your life harder make a back-up of the folder before deleting, or a snapshot of the vm )

rm -rf /var/www/html/moodle

Copy the new version and the custom config

cp -r /opt/moodle /var/www/html/
cp /opt/old_moodle/config.php /var/www/html/moodle/
cp -r /opt/old_moodle/theme/boost /var/www/html/moodle/theme/

Copy all the additionally installed blocks and plugins (compare the new moodle directory with the old_moodle directory and copy all the plugins or bloks):

cd  /opt/old_moodle/blocks
diff -q /opt/old_moodle/blocks/ /var/www/html/moodle/blocks/
cp -r community attendance teaching_team karma participants quickfindlist turnitin /var/www/html/moodle/blocks
sudo cp -r /opt/old_moodle/local/mass_enroll /var/www/html/moodle/local
sudo cp -r /opt/old_moodle/grade/grading/form/multigraders /var/www/html/moodle/grade/grading/form
sudo cp -r /opt/old_moodle/mod/scheduler /var/www/html/moodle/mod/
sudo cp -r /opt/old_moodle/mod/turnitintooltwo /var/www/html/moodle/mod/
sudo cp -r /opt/old_moodle/plagiarism /var/www/html/moodle/

Run the installer via command line or by disabling the maintenance mode opening the browser and accessing the moodle address To not have problems with folder rights run

sudo chown -R www-data:www-data /var/www/html/moodle
sudo chmod -R 0777 /var/www/html/moodle
sudo chmod -R 0444 /var/www/html/moodle/config.php
sudo -u www-data /usr/bin/php /var/www/html/moodle/admin/cli/upgrade.php

After the installer has finished with success restore rights on the folder

 sudo chmod -R 0755 /var/www/html/moodle 

Disable maintenance mode

sudo -u www-data /usr/bin/php /var/www/html/moodle/admin/cli/maintenance.php --disable

From the web app purge the theme cache:

Home/Site administration/Development/Purge caches

Notice: After disabling the maintenance mode go to your website and finish the upgrade process via interface. Afterwards it might pop up the update plugins, check if they are stable with the current version of the moodle update and do them. If everything goes well it will pop up a reports page with the status of each settings, for safety reasons move the node_modules from moodle folder or delete it so it wont have a security breach due to it.Also for config.php if it pops up warning/critical messages you should leave permissions only for read to the file. And via moodle interface -> site administration -> disable the following if they pop up in the reports ... .swf , enable site(secure) cookies. For web cron warning enable the setting that will not allow anonymous users to access cron. via search

Bug : errors generated by /var/www/html/moodle/lib/form/filemanager.js

Since V3.9 the configuration has changed and the custom theme settings might hide or disable some buttons or functions. In this case /var/www/html/moodle/lib/form/filemanager.js is accessing some buttons without checking if they exist resulting in errors that prevent the rest of the code to run. The fix is to add some conditions to check these buttons exist on the interface before adding triggers or style to them. Also check /var/www/html/moodle/lib/navigation.php for any configuration options!!!

Bug : outcomes do not appear in right order on grader

Check the name of the outcomes that have this problem. Find their id into the moodle database and change the id of them to be into the right order.

update mdl_grade_items set itemnumber = 1005 where id = 2097; update mdl_grade_items set itemnumber = 1001 where id = 2098;

Reset User Password

Note: Run the command with a space in front of it so it is not stored in the commands history

sudo -u www-data /usr/bin/php <moodle_path>/admin/cli/reset_password.php --username=<username> --password=<password>

Bug : login does not work after update

Since 3.5 or so they implemented a security fix , but since not all the plugins haven't yet implemented this feature not even in 3.6 one quickaround would be to edit config.php and add the following line :

//security check for moodle <---> plugins disable token


$CFG->disablelogintoken = true;

Bug : save settings doesnt work

Spawned at 3.5 + so on update to 3.6+ or other version it might pop up go to moodle->theme->boost->core_admin->settings.mustache and add the following :

       {{#params}}
           <input type="hidden" name="Template:Name" value="Template:Value">
           <input type="hidden" name="action" value="save-settings">   <----- this is the line that needs to be added
       Template:/params

Increase disk space

The second disk used for moodle date has no partition created (e.g. /dev/vda1), instead it's using the whole disk (/dev/vda) as a partitionless filesystem. If you need to increase it here's how you can do it.

Put moodle in maintenance mode:

sudo -u www-data /usr/bin/php /var/www/html/moodle/admin/cli/maintenance.php --enable

Go to the host, shutdown the VM, increase the disk image and start the VM.

virsh shutdown moodle

qemu-img resize /moodle_data/moodle_data.qcow2 +50G

virsh start moodle

After the VM started SSH back to the moodle VM and increase the volume at the VM level as well

umount /dev/vda

e2fsck -f /dev/vda

resize2fs /dev/vda

mount /dev/disk/by-uuid/8642b96b-5e42-4211-b116-a86726398693 /var/moodledata

After finishing disable the maintenance mode on moodle

sudo -u www-data /usr/bin/php /var/www/html/moodle/admin/cli/maintenance.php --disable