https://docs.moodle.org/310/en/api.php?action=feedcontributions&user=Leonstr&feedformat=atomMoodleDocs - User contributions [en]2024-03-29T08:20:27ZUser contributionsMediaWiki 1.39.6https://docs.moodle.org/310/en/index.php?title=Standard_themes&diff=140600Standard themes2021-09-13T09:15:46Z<p>Leonstr: "Note:" prefix added by wiki, changed <code> to <syntaxhighlight></p>
<hr />
<div>{{Themes}}<br />
{{Note|Clean, More and Bootstrapbase have been removed from core in Moodle 3.7. You are advised to use the [[Classic theme]] instead.}}<br />
==Standard themes==<br />
<br />
Moodle has two standard themes: ''[[Boost theme|Boost]]'' and ''[[Classic theme|Classic]],'' a responsive, bootstrap-based theme combining the navigation structure of the deprecated Clean and More themes and the customisation options of the Boost theme.<br />
<br />
Other themes are available from the [https://moodle.org/plugins/browse.php?list=category&id=3 Themes section of the Moodle plugins directory].<br />
<br />
===Example of a customised Boost theme===<br />
[[File:SchoolDemoBoost.png|thumb|center|600px]]<br />
<br />
The Moodle School demo site, [http://school.moodledemo.net Mount Orange], uses standard Boost with customisations as follows:<br />
* An image for the front page and a background image need to be uploaded and referenced in the code.<br />
*'''Front page topic section:'''<br />
<br />
<syntaxhighlight lang="html"><br />
<div class="frontpage container-fluid"><br />
<br />
<div class="jumbotron jumbotron-fluid" style="background-image: url('YOUR UPLOADED FRONT PAGE IMAGE.jpg');"><br />
<div class="texts"><br />
<h2>YOUR HEADING</h2><br />
<p class="lead">SENTENCE/TAG LINE</p><br />
</div><br />
</div><br />
<br />
<div class="row-fluid"><br />
<div class="fp-block col-md-6"><br />
<h3>SMALLER HEADING</h3><br />
<p>Paragraph of text</p><br />
<p class="button"><a class="btn btn-primary" href="BUTTON LINK URL">BUTTON TEXT »</a></p><br />
</div><br />
<div class="fp-block col-md-6"><br />
<h3>SMALLER HEADING</h3><br />
<p>Paragraph of text.</p><br />
<p class="button"><a class="btn btn-primary" href="BUTTON LINK URL">BUTTON TEXT »</a></p><br />
</div><br />
</div><br />
<br />
</div><br />
</syntaxhighlight><br />
<br />
*'''Boost theme Advanced settings - Raw initial SCSS:'''<br />
<syntaxhighlight lang="css"><br />
$brand-primary: #0070a8;<br />
$body-color: #336;<br />
$font-family-sans-serif: "Helvetica Neue", Helvetica, Arial, sans-serif;<br />
$breadcrumb-bg: #fff;<br />
</syntaxhighlight><br />
<br />
*'''Boost theme Advanced settings - Raw SCSS:'''<br />
<syntaxhighlight lang="css"><br />
body {<br />
background-image: url("YOUR UPLOADED BACKGROUND IMAGE.png");<br />
background-size: cover;<br />
background-repeat: no-repeat;<br />
background-attachment: fixed;<br />
letter-spacing: .3px;<br />
}<br />
h1, h2, h3, h4, h5, h6 {<br />
color: #f98012;<br />
font-weight: normal;<br />
}<br />
.navbar-brand {<br />
display: none;<br />
}<br />
#nav-drawer {<br />
background-color: rgba(236, 238, 239, .9);<br />
}<br />
#page-header.row {<br />
margin-left: -30px;<br />
margin-right: -30px;<br />
}<br />
#page-header .card {<br />
background-color: transparent;<br />
border: none;<br />
margin-bottom: 0;<br />
}<br />
#page-header h1 { <br />
color: #fff;<br />
font-weight: 500;<br />
text-shadow: 0px 1px 1px rgba(0, 0, 0, 0.2); <br />
}<br />
#page-header .breadcrumb {<br />
padding: .50rem 1rem;<br />
}<br />
.block-region .card-block .card-title {<br />
color: #f98012;<br />
font-size: 1.07rem;<br />
font-weight: 400;<br />
}<br />
#page-footer a {<br />
color: #f98012;<br />
}<br />
#page-site-index #page-header {<br />
display:none;<br />
}<br />
#page-site-index #region-main .card.card-block {<br />
padding: 0;<br />
border: 0;<br />
background-color: transparent;<br />
}<br />
#page-site-index #block-region-side-pre {<br />
margin-top: 15px;<br />
}<br />
#page-site-index .label {<br />
padding: 0;<br />
}<br />
#page-site-index .activity > div {<br />
padding: 0;<br />
}<br />
#page-site-index .mod-indent-outer {<br />
padding-left: 0;<br />
}<br />
#page-site-index .contentwithoutlink {<br />
padding-right: 0;<br />
}<br />
.frontpage.container-fluid {<br />
padding: 0;<br />
}<br />
.frontpage .jumbotron {<br />
padding:0;<br />
border-radius:0;<br />
background: transparent no-repeat right bottom / cover;<br />
line-height: 250px;<br />
}<br />
.frontpage .jumbotron .texts {<br />
color: #fff;<br />
letter-spacing: .5px;<br />
background-color: rgba(255, 99, 0, 0.70);<br />
padding: 0 20px;<br />
margin-bottom:20px;<br />
display: inline-block;<br />
vertical-align: bottom;<br />
}<br />
.frontpage .jumbotron h2 {<br />
color: #fff;<br />
font-size: 32px;<br />
font-weight: 300;<br />
text-shadow: 1px 1px 1px #444;<br />
margin-bottom: 0;<br />
margin-top: 10px;<br />
}<br />
.frontpage .jumbotron .lead {<br />
text-shadow: 1px 1px 1px #333;<br />
line-height: 30px;<br />
font-size: 21px;<br />
}<br />
.frontpage .row-fluid {<br />
line-height: 24px;<br />
background-color: #fff;<br />
padding: 10px 20px 20px;<br />
box-sizing: border-box;<br />
}<br />
.frontpage .row-fluid::after {<br />
display: table;<br />
content: "";<br />
clear: both;<br />
line-height: 0;<br />
}<br />
.frontpage .fp-block {<br />
padding: 10px 20px 0;<br />
}<br />
.frontpage h3 {<br />
font-size: 26px;<br />
line-height: 30px;<br />
font-weight: 300;<br />
margin-top: 20px;<br />
margin-bottom: 20px;<br />
}<br />
.frontpage .button {<br />
text-align: right;<br />
}<br />
.empty-region-side-pre.empty-region-side-post #region-main-box,<br />
.empty-region-side-pre.empty-region-side-post #region-main {<br />
width: 100%;<br />
}<br />
<br />
#settingsnav.box.block_tree_box.p-y-1 {<br />
padding-top: 0!important;<br />
}<br />
</syntaxhighlight><br />
<br />
==Theme selector==<br />
<br />
An administrator can set a theme for the site in ''Administration > Site administration > Appearance > Themes > Theme selector''.<br />
<br />
Different themes may be set according to 'device type' - default, legacy (for older browsers), mobile and tablet.<br />
<br />
Go to ''Administration > Site administration > Appearance > Themes > Theme selector''<br />
*Click on the "Select theme" button next to the type you wish to change<br />
*Scroll down to see the previews of the available themes and click on the "Use theme" button to chose the theme<br />
*The next screen will provide information about the theme. Click "Continue"<br />
<br />
<br />
Note 1: Moodle caches themes so if you don't immediately see changed settings that you were expecting, click the "Clear theme caches" button at the top of the Theme selector page.<br />
<br />
Note 2: The selected theme may be overridden if user/course or category themes have been allowed in the [[Theme settings]].<br />
<br />
==See also==<br />
<br />
* [[Boost theme]]<br />
* [[More theme]]<br />
* [[Theme credits]]<br />
* Using Moodle [http://moodle.org/mod/forum/discuss.php?d=189573 What counts as a 'legacy' device type?] forum discussion<br />
<br />
[[de:Standard-Designs]]<br />
[[es:Temas estándar]]<br />
[[fr:Thèmes standards]]</div>Leonstrhttps://docs.moodle.org/310/en/index.php?title=Universal_Office_Converter_(unoconv)&diff=140592Universal Office Converter (unoconv)2021-08-31T14:36:17Z<p>Leonstr: /* Installing unoconv on Windows */ Formatting and edits for clarity</p>
<hr />
<div>{{Document converters}}<br />
==What is unoconv?==<br />
<br />
"unoconv" is a command line program that is used to convert between different office document file formats. It uses an instance of [http://libreoffice.org LibreOffice] to do the conversion and is used by the [[Assignment activity]] to convert documents to pdf so that they can be annotated. If unoconv is not installed - the only impact is that the assignment activities will only allow annotations when students upload a pdf document. <br />
<br />
The steps required to install unoconv are different depending on the operating system that you have installed Moodle on. <br />
<br />
== Installing unoconv on Linux ==<br />
The required version of unoconv is at least 0.7. Depending on your flavour of linux, this may be available in your package manager and you can install it directly with:<br />
<br />
===Ubuntu 18.04 LTS===<br />
<pre><br />
apt-get install unoconv<br />
mkdir /var/www/.config<br />
chown www-data:www-data /var/www/.config<br />
</pre><br />
<br />
===Ubuntu 16.04 LTS===<br />
<pre><br />
apt-get install unoconv<br />
</pre><br />
<br />
If your package manager contains an older version of the package, you will have to find a newer version and install it manually ([https://packages.debian.org/stretch/unoconv Debian Testing]). Unoconv itself is just a python script, so it has few dependencies.<br />
<br />
Potential problems:<br />
* On some systems the apache user home directory is set to a non existent folder. This can cause unoconv to fail. There are 2 solutions to this - one is to make a (writable) home directory for the apache user (like /home/www-data). The other is to run a unoconv listener (described below) as another user other than the apache user (someone with a valid, writable home directory).<br />
* If you are still running 14.04LTS then unoconv won't work as shipped. This might not be the most efficient route but it worked by first installing unoconv (version 0.6) from the package manager as above. You will then need to grab unoconv 0.7 from Github (https://github.com/dagwieers/unoconv), then upgrade to the latest libreoffice using the PPA (https://launchpad.net/~libreoffice/+archive/ubuntu/ppa). Point moodle at the Github version of unoconv. You need to modify the Python unoconv file by changing 'python' in the first line to 'python3'. You also need to change the permissions on the directory /var/www so that the user www-data can write to it (www-data needs to write to its home directory which it cannot do by default).<br />
On Debian Stable, the cleanest method to install [https://packages.debian.org/jessie-backports/unoconv unoconv] is using Jessie-backports. First, enable backports repo line in /etc/apt/sources.list:<br />
<pre><br />
#### Jessie-backports ####<br />
deb http://ftp.debian.org/debian jessie-backports main<br />
</pre><br />
<br />
Then, update and install unoconv from jessie-backports:<br />
<pre><br />
apt-get update<br />
apt-get install -t jessie-backports unoconv<br />
</pre><br />
<br />
The package will bring all necessary dependencies for you.<br />
<br />
<br />
===Ubuntu 14.04 LTS===<br />
<br />
1) Navigate to opt directory<br />
<pre><br />
cd /opt<br />
</pre><br />
<br />
2) Download unoconv<br />
<pre><br />
sudo wget https://raw.githubusercontent.com/dagwieers/unoconv/master/unoconv<br />
</pre><br />
<br />
3) Modify the Python unoconv file by changing 'python' in the first line to 'python3'<br />
<pre><br />
sudo nano /opt/unoconv<br />
</pre><br><br />
eg. <pre>#!/usr/bin/env python3</pre><br />
<br />
4) Make unoconv executable<br />
<pre><br />
sudo chmod ugo+x /opt/unoconv<br />
</pre><br />
<br />
5) Add LibreOffice PPA to your system and install the latest version<br />
<pre><br />
sudo add-apt-repository ppa:libreoffice/ppa<br />
sudo apt-get update<br />
sudo apt-get install libreoffice<br />
</pre><br />
<br />
6) Change permissions so apache can write to its home directory<br />
<pre><br />
sudo chown www-data /var/www<br />
</pre><br />
<br />
7) From your browser navigate to<br />
''Site administration > Server > System paths'' and add the path to unoconv<br><br />
/opt/unoconv<br />
*Note: if you would like to preserve the default path add a symbolic link to /usr/bin: <br />
<pre><br />
sudo ln -s /opt/unoconv /usr/bin/<br />
</pre><br />
<br />
8) Navigate to <br />
''Site administration > Plugins > Activity modules > Assignment > Feedback plugins > Annotate PDF > Test unoconv path'' <br><br />
You should see: <br><br />
"The unoconv path appears to be properly configured."<br><br />
*Download the converted pdf test file. (if the PDF fails to load ensure that www-data can write to its home directory: /var/www)<br />
<br />
===CentOS / RedHat===<br />
Just before you start, you might like to consider installing the latest [http://www.tecmint.com/install-libreoffice-on-rhel-centos-fedora-debian-ubuntu-linux-mint/ LibreOffice 6.3.2] directly from RPM packages, that are not part of the distribution you are using.<br />
As of nov-2016, CentOS and RedHat 7.2 comes with OpenOffice 4.3 . so if you are not interested in using this version and would like to install latest 6.3 independent LibreOffice 6.3 , please remove any openoffice packages you might have on your OS by issuing:<br />
<pre><br />
yum remove openoffice* libreoffice*<br />
</pre><br />
It is recommended to chose your localized libreoffice version for better document conversions. <br />
<pre><br />
yum install libreoffice libreoffice-pyuno<br />
git clone https://github.com/dagwieers/unoconv.git<br />
# copy <br />
cp unoconv/unoconv /usr/bin<br />
# or link unoconv to /usr/bin<br />
ln -s unoconv/unoconv /usr/bin/unoconv<br />
</pre><br />
Note: depends on what version you are installing, openoffice or libreoffice, make sure you installed the *-pyuno package. (the headless package is already compiled into the core)<br />
<br />
Make sure it is properly configured:<br />
http://your-moodle/admin/search.php?query=unoconv<br />
<br />
Production servers should consider running unoconv in listener mode, see [[Installing_unoconv#Run_a_unoconv_listener]] or follow directions bellow<br />
<pre><br />
vi /etc/systemd/system/unoconv.service<br />
</pre><br />
And then copy and paste the following configuration into it:<br />
<pre><br />
[Unit]<br />
Description=Unoconv listener for document conversions<br />
Documentation=https://github.com/dagwieers/unoconv<br />
After=network.target remote-fs.target nss-lookup.target<br />
<br />
[Service]<br />
Type=simple<br />
Environment="UNO_PATH=/usr/lib64/libreoffice/program"<br />
ExecStart=/usr/bin/unoconv --listener<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
</pre><br />
And then enable and start the above service<br />
<pre><br />
systemctl enable unoconv.service<br />
systemctl start unoconv.service<br />
</pre><br />
If your selinux is enable yous should set <br />
<pre><br />
#setsebool -P httpd_execmem on<br />
</pre><br />
<br />
== Installing unoconv on OS X ==<br />
Download and install LibreOffice for Mac. Unfortunately - newer versions of LibreOffice are not currently compatible with unoconv for mac and you will have to install LibreOffice 4.2 (Direct download link - https://downloadarchive.documentfoundation.org/libreoffice/old/4.2.5.2/mac/x86_64/LibreOffice_4.2.5.2_MacOS_x86-64.dmg).<br />
<br />
Get the latest version of the unoconv python script. One way to do this is with http://brew.sh/ brew.<br />
<pre><br />
brew install unoconv<br />
</pre><br />
<br />
If you haven't done it already - install ghostscript. One way to install ghostscript is also with http://brew.sh/ brew<br />
<pre><br />
brew install ghostscript<br />
</pre><br />
<br />
Set the paths to unoconv and ghostscript in Moodle (''Site administration > Server > System paths''). If you used brew, they will both be installed to /usr/local/bin.<br />
<br />
LibreOffice needs write access to the current users home directory to create some temporary files. When unoconv is run as the webserver user (_www) it does not normally have this permission.<br />
<br />
There are some ways to get around this - one way is just to give the "_www" user write access to /Library/WebServer. <br />
<br />
Another solution is to convince LibreOffice that this users home directory is somewhere else. This can be done by inserting this code into the top of the unoconv python script.<br />
Code to insert:<br />
<pre><br />
# Set home to a writable folder. <br />
os.environ['HOME'] = '/tmp/' <br />
</pre><br />
<br />
This needs to be inserted at line 36 immediately after the line "exitcode = 0"<br />
<br />
== Installing unoconv on Windows ==<br />
Download and install LibreOffice for Windows. Open Office will work just as well, but the documentation for unonconv is set to Libre Office. <br />
<br />
Download the latest version of the unoconv script from https://github.com/dagwieers/unoconv/releases (download the zip version). <br />
<br />
From the downloaded zip file - extract the one file '''unoconv-0.7\unoconv''' (no file extension). This is the unoconv script - none of the other files in the package are required. <br />
<br />
Rename the downloaded script to '''unoconv.py''' and copy it to a folder in either '''C:\Program Files''' or '''C:\Program Files (x86)'''.<br />
<br />
Create a batch file in the same folder as '''unoconv.py''' name it something like '''unoconv.bat''', it must be a batch file, with these contents:<br />
<br />
@"C:\Program Files\LibreOffice\program\python.exe" c:\unoconv\unoconv.py %*<br />
<br />
or:<br />
<br />
@"C:\Program Files\Open Office\program\python.exe" c:\unoconv\unoconv.py %*<br />
<br />
Next, you have to '''Set paths in Moodle.''' <br />
<br />
Login as admin and go to ''Site administration > Server > System paths''<br />
<br />
Set: <br />
''Path to Ghostscript (pathtogs)'' to <code>C:\Program Files\gs\gsversion\bin\gswin64c.exe</code>.<br />
Do not use gswin32.exe or gswin64.exe, these are not command line programs - use gswin32c.exe or gswin64c.exe. <br />
<br />
Set: <br />
''Path to Python (pathtopython)'' to <code>C:\Program Files (x86)\OpenOffice\program\python.exe</code> or <code>C:\Program Files (x86)\LibreOffice\program\python.exe</code>.<br />
Identify in the path whichever program you use and include the full exe name for both Ghostscript and Python.<br />
<br />
Save the pathto statements and a green tick should appear if Moodle is communicating with the required files. <br />
<br />
Go to ''Site administration > Plugins > Document converters'' and enable '''Unoconv''' then select ''Settings''<br />
<br />
Enter the path statement to <br />
''Path to unoconv document converter'': <code>C:\Program Files (x86)\unoconv\unoconv.bat</code><br />
Include the full name of the .bat file. <br />
<br />
Test ghostscript and unoconv are working correctly in the admin test pages ''Site administration > Plugins > Activity modules > Assignment > Feedback plugins > Annotate PDF''.<br />
<br />
== Run a unoconv listener ==<br />
Unoconv utilises a client/server process when converting documents. By default, when there is no running server process - each time unoconv runs it will start a server process, send its request and shut down the server process when the request is complete. The drawback of this mode is that if 2 requests are submitted simultaneously - this can cause the first request to shutdown the server process when the second request is still in progress - and the second conversion request fails. A more robust way to configure unoconv is to start a server process at boot time, and/or run a script to monitor it and restart it if it crashes.<br />
<br />
To start a unoconv listener at boot time - you need a start up script. Different operating systems and Linux distributions use different startup scripts - but here are some examples of startup scripts for different systems.<br />
<br />
[[mod/assign/feedback/editpdf/testunoconv/upstart | Upstart script for Ubuntu based systems]]<br />
<br />
[[mod/assign/feedback/editpdf/testunoconv/launchd | Launchd script for OS X]]<br />
<br />
[[mod/assign/feedback/editpdf/testunoconv/initd | Init script for Debian]]<br />
<br />
[[mod/assign/feedback/editpdf/testunoconv/initdcentos6 | Init script for CentOS/RedHat 6.x]]<br />
<br />
[[mod/assign/feedback/editpdf/testunoconv/systemd | SystemD service script for CentOS/RedHat 7.x]]<br />
<br />
== Offload processing to a different server ==<br />
Processing office documents can put increased load on your webserver, which may impact on the responsiveness of your site. If you are installing unoconv on a large site you may want to consider running unoconv on a server that is not also serving web requests.<br />
<br />
How to do this:<br />
<br />
Install unoconv on each webservers and the remote server following the installation instructions above. <br />
<br />
Make sure unoconv is started at boot time on the remote server with the "--listener" argument and is monitored and restarted if it exits (see Debian init script for an example of how to do this). By default, unoconv will only listen on localhost (127.0.0.1): if you want to connect to the listener process from another server, you need to start the unoconv listener process with the "--server" argument too!<br />
<br />
An example command for starting a listener on a remote server (0.0.0.0 listens on all interfaces):<br />
<pre><br />
unoconv --listener --server 0.0.0.0 --port 2002<br />
</pre><br />
<br />
Open the firewall port 2002 between the moodle webservers and the machine running unoconv.<br />
<br />
Share the moodle data root between the webservers and the machine running unoconv. This folder must be mounted at the same path on all servers. <br />
<br />
Install a wrapper for unoconv on the webservers that forwards the requests to the remote server. Example:<br />
<pre><br />
#!/bin/bash<br />
# Wrapper script for unoconv to forward processing.<br />
# Install to /usr/bin/unoconv-remote with 755 permissions<br />
/usr/bin/unoconv --server=<ip of remote server> "$@"<br />
</pre><br />
<br />
Configure the path to unoconv in the Moodle admin settings to point to this wrapper script.<br />
<br />
==Additional resources==<br />
<br />
[https://github.com/dagwieers/unoconv GitHub dagwieers/unoconv] has additional information on installation of unoconv and troubleshooting tips.<br />
<br />
==Troubleshooting==<br />
* [http://webnetkit.com/soffice-bin-using-100-cpu-moodle/ soffice.bin using 100% of CPU MOODLE]<br />
<br />
==See also==<br />
<br />
* [https://moodle.org/mod/forum/discuss.php?d=335310 Is the unoconv installation a security risk?] forum discussion<br />
<br />
[[Category:Site administration]]<br />
[[Category:Assignment]]<br />
<br />
[[es:Universal Office Converter (unoconv)]]<br />
[[de:Universal Office Konverter]]<br />
[[fr:Universal Office Converter]]</div>Leonstrhttps://docs.moodle.org/310/en/index.php?title=LDAP_authentication&diff=140591LDAP authentication2021-08-25T09:12:28Z<p>Leonstr: /* User lookup settings */ Updated 'Member attribute uses dn' this is no longer automatically set from 3.8.5/3.9.2 onward https://tracker.moodle.org/browse/MDL-70596#comment-871688</p>
<hr />
<div>{{Authentication}}<br />
This document describes how to set up Lightweight Directory Access Protocol (LDAP) authentication in Moodle. We cover the basic, advanced and some trouble shooting sections to assist the user in the installation and administrating LDAP in Moodle. <br />
<br />
==Basic Scenario==<br />
The simple and straightforward approach for most installations.<br />
<br />
===Assumptions===<br />
Moodle supports several types of LDAP servers which have different directory structures, special configuration settings, etc. Even if using the same LDAP server type (e.g., MS Active Directory), each site could use a completely different directory structure to hold its user accounts, groups, etc. In order to be able to show example configuration settings in the sections below, we are going to assume a '''hypothetical''' Moodle site and LDAP server with the characteristics listed below.<br />
<br />
'''IMPORTANT NOTICE''': be sure to check '''''your''''' Moodle site and LDAP server details (including its directory structure,) and adjust the settings to reflect your own setup.<br />
<br />
# Your Moodle site is located at '''http://your.moodle.site/'''<br />
# You have configured your PHP installation with the LDAP extension. It is loaded and activated, and it shows when you go to '''http://your.moodle.site/admin/phpinfo.php''' (logged in as user 'admin').<br />
# Your LDAP server has '''192.168.1.100''' as its IP address.<br />
# You are not using LDAP with SSL (also known as LDAPS) in your settings. This might prevent certain operations from working (e.g., you cannot update data if you are using MS Active Directory -- MS-AD from here on --), but should be OK if you just want to authenticate your users.<br />
# You don't want your users to change their passwords the first time they log in into Moodle.<br />
# You are using a single domain as the source of your authentication data in case you are using MS-AD (more on this in the Appendices).<br />
# You are using a top level distinguished name (DN) of '''dc=my,dc=organization,dc=domain''' as the root of your LDAP tree. <br />
# You have a non-privileged LDAP user account you will use to bind to the LDAP server. This is not necessary with certain LDAP servers, but MS-AD requires this and it won't hurt if you use it even if your LDAP server doesn't need it. Make sure '''this account and its password don't expire''', and make this password as strong as possible. Remember you only need to type this password once, when configuring Moodle, so don't be afraid of making it as hard to guess as possible. Let's say this user account has a DN of '''cn=ldap-user,dc=my,dc=organization,dc=domain''', and password '''hardtoguesspassword'''.<br />
# All of your Moodle users are in an organizational unit (OU) called '''moodleusers''', which is right under your LDAP root. That OU has a DN of '''ou=moodleusers,dc=my,dc=organization,dc=domain'''.<br />
# You '''don't''' want your LDAP users' passwords to be stored in Moodle at all.<br />
<br />
===Enabling LDAP authentication===<br />
<br />
An administrator can enable LDAP authentication as follows:<br />
<br />
# Go to ''Site administration > Plugins > Authentication > Manage authentication'' and click the eye icon opposite LDAP Server. When enabled, it will no longer be greyed out.<br />
# Click the settings link, configure as required (see information below), then click the 'Save changes' button.<br />
<br />
[[Image:LDAPserversettings.png|center]]<br />
<br />
Now, you just have to fill in the values. Let's go step by step.<br />
<br />
====LDAP Server Settings====<br />
{| border="1" cellspacing="0" cellpadding="5"<br />
! Field name<br />
! Value to fill in<br />
|-<br />
| Host URL<br />
| As the IP of your LDAP server is 192.168.1.100, type "'''ldap://192.168.1.100'''" (without the quotes), or just "'''192.168.1.100'''" (some people have trouble connecting with the first syntax, specially on MS Windows servers).<br />
|-<br />
| Version<br />
| Unless you are using a really old LDAP server, '''version 3''' is the one you should choose.<br />
|-<br />
| LDAP Encoding<br />
| Specify encoding used by LDAP server. Most probably utf-8.<br />
|}<br />
<br />
[[LDAP_authentication#Table of Contents|Table of Contents]]<br />
<br />
====Bind settings====<br />
{| border="1" cellspacing="0" cellpadding="5"<br />
! Field name<br />
! Value to fill in<br />
|-<br />
| Don't cache passwords<br />
| As you '''don't''' want to store the users's password in Moodle's database, choose '''Yes''' here.<br />
|-<br />
| Distinguished Name<br />
| This is the distinguished name of the bind user defined above. Just type "'''cn=ldap-user,dc=my,dc=organization,dc=domain'''" (without the quotes).<br />
|-<br />
| Password<br />
| This is the bind user password defined above. Type "'''hardtoguesspassword'''" (without the quotes).<br />
|}<br />
<br />
[[LDAP_authentication#Table of Contents|Table of Contents]]<br />
<br />
====User lookup settings====<br />
{| border="1" cellspacing="0" cellpadding="5"<br />
! Field name<br />
! Value to fill in<br />
|-<br />
| User type<br />
| Choose: <br />
* '''Novel Edirectory''' if your LDAP server is running Novell's eDdirectory.<br />
* '''posixAccount (rfc2307)''' if your LDAP server is running a RFC-2307 compatible LDAP server (choose this is your server is running OpenLDAP, including Mac OS X server).<br />
* '''posixAccount (rfc2307bis)''' if your LDAP server is running a RFC-2307bis compatible LDAP server.<br />
* '''sambaSamAccount (v.3.0.7)''' if your LDAP server is running with SAMBA's 3.x LDAP schema extension and you want to use it.<br />
* '''MS ActiveDirectory''' if your LDAP server is running Microsoft's Active Directory (MS-AD)<br />
|-<br />
| Contexts<br />
| The DN of the context (container) where all of your Moodle users are found. Type '''ou=moodleusers,dc=my,dc=organization,dc=domain''' here. <br />
<br />
On a Mac OS X Server, this is usually '''cn=users,dc=my,dc=organization,dc=domain'''.<br />
|-<br />
| Search subcontexts<br />
| If you have any sub organizational units (subcontexts) hanging from '''ou=moodleusers,dc=my,dc=organization,dc=domain''' and you want Moodle to search there too, set this to '''yes'''. Otherwise, set this to '''no'''.<br />
|-<br />
| Dereference aliases<br />
| Sometimes your LDAP server will tell you that the real value you are searching for is in fact in another part of the LDAP tree (this is called an alias). If you want Moodle to 'dereference' the alias and fetch the real value from the original location, set this to '''yes'''. If you don't want Moodle to dereference it, set this to '''no'''. If you are using MS-AD, set this to '''no'''.<br />
|-<br />
| User attribute<br />
| The attribute used to name/search users in your LDAP tree. This option takes a default value based on the ''User type'' value you chose above. <u>So unless you need something special, you don't need to fill this in</u>.<br />
<br />
By the way, it's usually '''cn''' (Novell eDirectory and MS-AD) or '''uid''' (RFC-2037, RFC-2037bis and SAMBA 3.x LDAP extension), but if you are using MS-AD you could (and have to, if you intend to use NTLM SSO) use '''sAMAccountName''' (the pre-Windows 2000 logon account name) if you need too.<br />
<br />
'''Correction''': With MS-AD '''sAMAccountName''' should be used anyway. With default value ('''cn''') AD users will have to login with full name / password (Username: '''John Doe''', Password: '''john's_pass'''). If you want to enable your users to login with domain username instead (Username: '''johnd''' Password: '''john's_pass'''), you should use '''sAMAccountName'''. Sadly, but logging in with DOMAIN\user or user@domain.com will not work anyway.<br />
<br />
Note: You may wish to consider allowing extended characters in usernames in ''Administration > Site administration > Security > [[Site policies]]''. <br />
|-<br />
| Member attribute<br />
| The attribute used to list the members of a given group. This option takes a default value based on the ''User type'' value you choosed above. <u>So unless you need something special, you don't need to fill this in.</u><br />
<br />
By the way, the usual values are '''member''' and '''memberUid'''.<br />
|-<br />
| Member attribute uses dn<br />
| Whether the member attribute contains distinguished names (Yes) or not (No). This must be set to Yes for Active Directory.<br />
|-<br />
| Object class<br />
| The type of LDAP object used to search for users. This option takes a default value based on the ''User type'' value you chose above. <u>So unless you need something special, you don't need to fill this in.</u><br />
* If you leave it blank, the default value based on the ''User type'' selected above will be used (see below)<br />
* If you provide "objectClass=some-string", then it will provide "(objectClass=some-string)" as the filter.<br />
* If you provide a value that does not start with "(", it is assumed to be a value that should be set to "objectClass". So if you provide "some-string", then it will provide "(objectClass=some-string)" as the filter.<br />
* If you provide a string that starts with a "(", then it will pass that as is. So if you provide "(&(objectClass=user)(enabledMoodleUser=1))", then it will pass that as the filter.<br />
<br />
'''Note''': In the last case, that feature can be used on interactive logins,<br />
<br />
Here are the default values for each of the ''ldap_user_type'' values:<br />
* '''(objectClass=user)''' for Novel eDirectory<br />
* '''(objectClass=posixAccount)''' for RFC-2037 and RFC-2037bis<br />
* '''(objectClass=sambaSamAccount)''' for SAMBA 3.0.x LDAP extension<br />
* '''(objectClass=user)''' for MS-AD<br />
* '''(objectClass=*)''' for Default<br />
If you get an error about a problem with updating the ldap server (even if you have specified not to write changes back to the ldap server) try setting the ldap object class to * - see http://moodle.org/mod/forum/discuss.php?d=70566 for a discussion on this problem<br />
|}<br />
<br />
====Force change password====<br />
{| border="1" cellspacing="0" cellpadding="5"<br />
! Field name<br />
! Value to fill in<br />
|-<br />
| Force change password<br />
| '''NOTE: This setting is only used when creating your users with the LDAP sync users task. It's not used if your users are created as part of their first login to moodle'''.<br />
<br />
Set this to ''Yes'' if you want to force your users to change their password on the first login into Moodle. Otherwise, set this to ''no''. Bear in mind the password they are forced to change is the one stored in your LDAP server.<br />
<br />
<u>As you don't want your users to change their passwords in their first login, leave this set to ''No''</u><br />
|-<br />
| Use standard Change Password Page<br />
|<br />
* Setting this to ''Yes'' makes Moodle use its own standard password change page, everytime users want to change their passwords.<br />
* Setting this to ''No'' makes Moodle use the page specified in the field called "Password change URL" (see below).<br />
<br />
Bear in mind that changing your LDAP passwords from Moodle might require a LDAPS connection (this is actually a requirement for MS-AD). In addition to that, the bind user specified above must have the rights needed to change other users' passwords.<br />
<br />
Also, code for changing passwords from Moodle for anything but Novell eDirectory and Active Directory is almost not tested, so this may or may not work for other LDAP servers.<br />
|-<br />
| Password Format<br />
| Specify how the new password is encrypted before sending it to the LDAP server: Plain text, MD5 hash or SHA-1 hash. MS-AD uses plain text, for example.<br />
|-<br />
| Password change URL<br />
| Here you can specify a location at which your users can recover or change their username/password if they've forgotten it. This will be provided to users as a button on the login page and their user page. if you leave this blank the button will not be printed.<br />
|}<br />
<br />
====LDAP password expiration settings====<br />
{| border="1" cellspacing="0" cellpadding="5"<br />
! Field name<br />
! Value to fill in<br />
|-<br />
| Expiration<br />
| <br />
* Setting this to ''No'' will make Moodle not to check if the password of the user has expired or not.<br />
* Setting this to ''LDAP'' will make Moodle check if the LDAP password of the user has expired or not, and warn them a number of days before the password expires. When the password has expired, a "Your password has expired" message is displayed, and if the user is able to change their password from Moodle, they are offered the option to do so.<br />
<br />
Current code only deals with Novell eDirectory LDAP server and MS-AD.<br />
<br />
<u>So unless you have Novell eDirectory server or MS-AD, choose ''No'' here.</u><br />
|-<br />
| Expiration warning<br />
| This value sets how many days in advance of password expiration the user is warned that her password is about to expire.<br />
|-<br />
| Expiration attribute.<br />
| The LDAP user attribute used to check password expiration. This option takes a default value based on the ''User type'' value you chose above. <u>So unless you need something special, you don't need to fill this in.</u><br />
|-<br />
| Grace logins<br />
| This setting is specific to Novell eDirectory. If set to ''Yes'', enable LDAP gracelogin support. After password has expired the user can login until gracelogin count is 0.<br />
<br />
<u>So unless you have Novell eDirectory server and want to allow gracelogin support, choose ''No'' here.</u><br />
|-<br />
| Grace login attribute<br />
| This setting is currently not used in the code (and is specific to Novell eDirectory). <br />
<br />
<u>So you don't need to fill this in.</u><br />
|}<br />
<br />
====Enable user creation====<br />
{| border="1" cellspacing="0" cellpadding="5"<br />
! Field name<br />
! Value to fill in<br />
|-<br />
| Create users externally<br />
| New (anonymous) users can self-create user accounts on the external LDAP server and confirm them via email. If you enable this, remember to also configure module-specific options for user creation and to fill in some instructions in ''auth_instructions'' field in ''Site administration > Plugins > Authentication > Manage authentication''. Otherwise the new users won't be able to self-create new accounts.<br />
<br />
Novell eDirectory and MS-AD can create users externally. You can also create users in RFC-2307 compliant servers. <br />
|-<br />
| Context for new users<br />
| Specify the context where users are created. This context should be different from other users' contexts to prevent security issues. <br />
|}<br />
<br />
====Assign system roles====<br />
{| border="1" cellspacing="0" cellpadding="5"<br />
! Field name<br />
! Value to fill in<br />
|-<br />
| System role mapping<br />
| This section lists all roles that have can be assigned in the System context - by default this will be "Manager context" and "Course creator context", but can be customisable in the [[Creating custom roles|role definitions]].<br />
<br />
To assign LDAP users to any of the roles, specify the DN containing all users who should be granted that role at the system level.<br />
<br />
Thie DN is typically a posixGroup with a "memberUid" attribute for each user you want to be a creator. If your group is called ''creators'', type '''cn=creators,ou=moodleusers,dc=my,dc=organization,dc=domain''' here. Each memberUid attribute contains the CN of a user who is authorized to be a creator. Do not use the user's full DN (e.g., not '''memberUid: cn=JoeTeacher,ou=moodleusers,dc-my,dc=organizations,dc=domain''', but rather '''memberUid: JoeTeacher''').<br />
<br />
In eDirectory, the objectClass for a group is (by default) not '''posixGroup''' but '''groupOfNames,''' whose member attribute is '''member,''' not '''memberUid,''' and whose value is the full DN of the user in question. Although you can probably modify Moodle's code to use this field, a better solution is just to add a new '''objectClass''' attribute of '''posixGroup''' to your creators group and put the CNs for each creator in a '''memberUid''' attribute.<br />
<br />
In MS Active Directory, you will need to create a security group for your creators to be part of and then add them all. If your ldap context above is 'ou=staff,dc=my,dc=org' then your group should then be 'cn=creators,ou=staff,dc=my,dc=org'. If some of the users are from other contexts and have been added to the same security group, you'll have to add these as separate contexts after the first one using the same format.<br />
<br />
This section replaces the "Course creator" section found in Moodle 3.3. The upgrade process should migrate any DN specified to the new approach.<br />
<br />
|}<br />
<br />
====User account synchronisation====<br />
{| border="1" cellspacing="0" cellpadding="5"<br />
! Field name<br />
! Value to fill in<br />
|-<br />
| Removed ext user<br />
| Specify what to do with internal user account during mass synchronization when user was removed from external source. Only suspended users are automatically revived if they reappear in ext source.<br />
|}<br />
<br />
====NTLM SSO====<br />
{| border="1" cellspacing="0" cellpadding="5"<br />
! Field name<br />
! Value to fill in<br />
|-<br />
| Enable<br />
| If you want to use NTLM SSO (see details at [[NTLM_authentication]]), choose ''Yes'' here. Otherwise, choose ''No''.<br />
|-<br />
| Subnet<br />
| Specify the subnets of the clients that will use NTLM SSO (see details at [[NTLM_authentication]]).<br />
|-<br />
| MS IE Fast Path?<br />
| If all of you clients (or most of them) are using MS Internet Explorer, you can set this option to bypasses certain steps of the SSO login and speed up login times. This only works with MS Internet Explorer, but deals with other browsers in a sensible way (they are automatically sent to the plain login page).<br />
|}<br />
<br />
====Data Mapping====<br />
{| border="1" cellspacing="0" cellpadding="5"<br />
! Field name<br />
! Value to fill in<br />
|-<br />
| First name<br />
| The name of the attribute that holds the first name of your users in your LDAP server. This is usually '''givenName''' or '''displayName'''<br />
<br />
<u>This setting is optional</u><br />
|-<br />
| Surname<br />
| The name of the attribute that holds the surname of your users in your LDAP server. This is usually '''sn'''.<br />
<br />
<u>This setting is optional</u><br />
|-<br />
| Email address<br />
| The name of the attribute that holds the email address of your users in your LDAP server. This is usually '''mail'''.<br />
<br />
<u>This setting is optional</u><br />
|-<br />
| City/town<br />
| The name of the attribute that holds the city/town of your users in your LDAP server. This is usually '''l''' (lowercase L) or '''localityName''' (not valid in MS-AD).<br />
<br />
<u>This setting is optional</u> <br />
|-<br />
| Country<br />
| The name of the attribute that holds the country of your users in your LDAP server. This is usually '''c''' or '''countryName''' (not valid in MS-AD).<br />
<br />
<u>This setting is optional</u><br />
|-<br />
| Language<br />
| '''preferredLanguage'''<br />
<br />
<u>This setting is optional</u><br />
|-<br />
| Description<br />
| '''description'''<br />
<br />
<u>This setting is optional</u><br />
|-<br />
| Webpage<br />
| <u>This setting is optional</u><br />
|-<br />
| ID Number<br />
| <br />
<br />
<u>This setting is optional</u><br />
|-<br />
| Institution<br />
| <br />
<br />
<u>This setting is optional</u><br />
|-<br />
| Department<br />
| The name of the attribute that holds the department name of your users in your LDAP server. This is usually '''departmentNumber''' (for posixAccount and maybe eDirectory) or '''department''' (for MS-AD).<br />
<br />
<u>This setting is optional</u><br />
|-<br />
| Phone 1<br />
| The name of the attribute that holds the telephone number of your users in your LDAP server. This is usually '''telephoneNumber'''.<br />
<br />
<u>This setting is optional</u><br />
|-<br />
| Phone 2<br />
| The name of the attribute that holds an additional telephone number of your users in your LDAP server. This can be '''homePhone''', '''mobile''', '''pager''', '''facsimileTelephoneNumber''' or even others.<br />
<br />
<u>This setting is optional</u><br />
|-<br />
| Address<br />
| The name of the attribute that holds the street address of your users in your LDAP server. This is usually '''streetAddress''' or '''street'.<br />
<br />
<u>This setting is optional</u><br />
|}<br />
<br />
=====Custom User profile fields=====<br />
<br />
Any user profile fields created in ''Site administration > Users > Accounts > User profile fields'' should now automatically show up at the end of the Data mapping field list after the '''Address''' field. See example: [[File:ldapcustomuserprofilefields.jpg]]<br />
<br />
==Enabling the LDAP users sync job==<br />
<br />
The LDAP users sync job (''\auth_ldap\task\sync_task'') [[Scheduled tasks|scheduled task]] (new in Moodle 3.0; previously there was a CLI script, see MDL-51824 for more info) is responsible for creating and updating user information, and suspending and deleting LDAP accounts. <br />
<br />
After enabling LDAP server authentication, an administrator needs to enable and configure the LDAP users sync job as follows:<br />
<br />
# Go to ''Site administration > Server > Scheduled tasks'' and click the gear icon opposite LDAP users sync job.<br />
# Select the desired frequency of running and enable the task by un-ticking the disabled checkbox.<br />
{{Warning|It is important to make sure that all LDAP settings are working properly before enabling the LDAP users sync job (as well as backing up your database and moodledata folders), since incorrect LDAP configuration can result in users being wrongly deleted!}}<br />
<br />
If you find that the script is not running through all of your users properly and you have over 1000 users in each LDAP container, this is because by default some LDAP stores such as MS AD only send back 1000 users at a time and PHP versions prior to 5.4 did not implement paged support for LDAP results. If you upgrade to PHP 5.4 or higher than Moodle will obtain all your users correctly. If you can't upgrade to PHP 5.4 you may be able to follow the instructions in http://support.microsoft.com/kb/315071 to set the Active Directory MaxPageSize setting to a number higher than your total number of users (both now and in future) to fix it. This is a forest-wide setting.<br />
<br />
==Active Directory help==<br />
[[Active Directory]] is Microsoft's directory service. It is included in Windows 2000 Server and later versions of their operating system. For more information about subjects below, '''[[Active Directory|please go here]]'''.<br />
<br />
*Warning: The PHP LDAP module does not seem to be present<br />
*LDAP-module cannot connect any LDAP servers <br />
*Getting correct CNs for Contexts and Creators<br />
*Getting the right user_attribute<br />
*Installing ldp.exe Server Tool<br />
*Example Active Directory Configuration<br />
*Child Domains and the Global Catalog in MS Active Directory<br />
*Enabling the Global Catalog<br />
*Active Directory with Moodle 1.8<br />
*MS Active Directory + SSL<br />
<br />
==Advanced Scenarios - Multiple servers or locations==<br />
For larger installations with multiple LDAP servers, or multiple locations (contexts) in a LDAP tree.<br />
<br />
===Making your LDAP directory connection resilient===<br />
* Entering more than one name in the ldap_host_url field can provide some sort of resilience to your system. Simply use the syntax:<br />
<br />
ldap://my.first.server; ldap://my.second.server; ...<br />
<br />
Of course, this will only work if all the servers share the same directory information, if using eDirectory you would need to ensure your servers have viability of all relevant tree partitions, or if using Active Directory the servers are holding the same information you need though replication - see notes on a multi-domain environment if this applies.<br />
<br />
There is one drawback in Moodle 1.5 - 1.6 implementation of LDAP authentication : the auth_ldap_connect() function processes the servers sequentially, not in a round robin mode. Thus, if the primary server fails, you will have to wait for the connection to time out before switching to the following one.<br />
<br />
See also: [http://moodle.org/mod/forum/discuss.php?d=17198 Using multiple LDAP servers - Our students are on separate domain] forum discussion<br />
<br />
===Using a multi-domain AD environment===<br />
* If you're running Active Directory with multiple domains and you have users in more than one domain you will want to configure Moodle to look at your Global Catalog server. Specifically your top level domain Global Catalog server. Here is a simple example of this kind of Active Directory layout:<br />
<br />
my.domain.ca (Root AD Domain)<br />
| - dc1.my.domain.ca (Domain Controller)<br />
| - dc2.my.domain.ca (Domain Controller)<br />
|<br />
| - - students.my.domain.ca (Sub AD Domain)<br />
| - - - dc1.students.my.domain.ca (Domain Controller)<br />
| - - - dc2.students.my.domain.ca (Domain Controller)<br />
|<br />
| - - faculty.my.domain.ca (Sub AD Domain)<br />
| - - - dc1.faculty.my.domain.ca (Domain Controller)<br />
| - - - dc2.faculty.my.domain.ca (Domain Controller)<br />
<br />
In this example we have our top level domain (my.domain.ca) and two sub-domains. One sub-domain is for faculty accounts (faculty.my.domain.ca) and the other is for student accounts (students.my.domain.ca). Listed under each of those are two domain controllers.<br />
<br />
Using the above example you'll want to use the following for accessing the Global Catalog over SSL:<br />
<br />
ldaps://my.domain.ca:3269/<br />
<br />
If you prefer to access your global catalog over a non-SSL connection you'll want to use:<br />
<br />
ldap://my.domain.ca:3268/<br />
<br />
We found if you didn't configure things this way you'd get errors like:<br />
<br />
[Thu May 26 15:23:53 2011] [error] [client 192.168.xxx.xxx] PHP Warning: ldap_search() [<a href='function.ldap-search'>function.ldap-search</a>]: Search: Partial results and referral received in /xxx/xxx/moodle20/lib/ldaplib.php on line 241, referer: http://moodle.my.domain.ca/moodle20/login/index.php<br />
[Thu May 26 15:23:53 2011] [error] [client 192.168.xxx.xxx] PHP Warning: ldap_first_entry(): supplied argument is not a valid ldap result resource in /xxx/xxx/moodle20/lib/ldaplib.php on line 248, referer: http://moodle.my.domain.ca/moodle20/login/index.php<br />
<br />
===Using multiple user locations (contexts) in your LDAP tree===<br />
There is no need to use multiple user locations if your directory tree is flat, i.e. if all user accounts reside in a '''ou=people,dc=my,dc=organization,dc=domain''' or '''ou=people,o=myorg''' container. <br />
<br />
At the opposite, if you use the ACL mecanism to delegate user management, there are chances that your users will be stored in containers like '''ou=students,ou=dept1,o=myorg''' and '''ou=students,ou=dept2,o=myorg''' ...<br />
<br />
Then there is an alternative :<br />
* Look at the '''o=myorg''' level with the ldap_search_sub attribute set to '''yes'''.<br />
* Set the ldap_context to '''ou=students,ou=dept1,o=myorg ; ou=students,ou=dept2,o=myorg'''.<br />
<br />
Choosing between these two solutions supposes some sort of benchmarking, as the result depends heavily on the structure of your directory tree '''and''' on your LDAP software indexing capabilities. Simply note that there is a probability in such deep trees that two users share the same ''common name'' (cn), while having different ''distinguished names''. Then only the second solution will have a deterministic result (returning always the same user).<br />
<br />
===Using LDAPS (LDAP over SSL)===<br />
====Enabling LDAPS on your directory server====<br />
<br />
* [[Active_Directory#MS_Active_Directory_.2B_SSL|Enabling LDAPS on MS Active Directory ]]<br />
<br />
====Enabling LDAPS on your Moodle server====<br />
Enabling LDAPS on your server can be tricky and often it is hard to pinpoint where things are going wrong. There are also differences between Windows and Linux and even different versions and distributions of Linux. <br />
<br />
'''If you have not done so already you will need to decide upon your approach to establishing an SSL connection to your directory server:'''<br />
<br />
* SSL connection with unverified self-signed certificate.<br />
<br />
You can generate your own SSL certificate, and then instruct your Moodle server to ignore the fact that it is not valid. This setup is not as secure as others since you cannot be sure the server you are connecting to is not fake.<br />
<br />
* SSL connection with trusted self-signed certificate.<br />
<br />
You can generate your own SSL certificate on your directory server, and then specifically trust this certificate by installing it on your Moodle server. <br />
<br />
* SSL connection with verified certificate from Internet-trusted certificate authority (CA)<br />
<br />
In this approach the LDAP server has an installed certificate from an Internet-based CA, this means that your directory server would have an Internet address & host name. Your Moodle server must be trusting the certificate authority and have Internet access. This approach is not often used as it usually incurs a cost for the certificate, and it requires your directory server and Moodle server to be exposed to the Internet.<br />
<br />
==Linux servers==<br />
'''These instructions are for establishing a link using a trusted self-signed certificate.'''<br />
<br />
''Note: written for a Red Hat Enterprise Linux 6 server, other Linux distributions may differ, especially in the location of the SSL certificates and OpenLdap config files, but the core principals are the same.''<br />
<br />
To check that your directory server is online and accepting SSL connections on your LDAPS port (636), you can use try:<br />
openssl s_client –connect <ldap server ip address>:636<br />
<br />
Get your directory server’s certificate (.crt) and upload to Moodle server's ssl certificate directory, on RHEL6 this is at '''/etc/ssl/certs'''<br />
<br />
Convert your ‘DER’ X509 certificate into a ‘PEM’ public key certificate.<br />
openssl x509 -in my_server_certificate.cer -inform DER -out my_server_certificate.pem -outform PEM<br />
<br />
Create certificate hashes using c_rehash<br />
c_rehash<br />
''If c_rehash is not installed install with: yum install /usr/bin/c_rehash''<br />
<br />
Ensure you are able to access your LDAPS server by a DNS name, this may mean adding an entry to your host file (/etc/hosts)<br />
<ldap server ip address> my_server.mydomain.school<br />
<br />
Verify your certificate to check that it is installed correctly<br />
openssl verify -verbose -CApath /etc/ssl/certs /etc/ssl/certs/my_server_certificate.pem<br />
/etc/ssl/certs/my_server_certificate.pem: OK<br />
<br />
You should now be able to connect to your LDAPS server over SSL without any errors<br />
openssl s_client –connect <ldap server DNS name>:636<br />
<br />
Edit your OpenLDAP config, on RHEL6 this is located at '''/etc/openldap/ldap.conf'''<br />
# Define location of a CA Cert<br />
TLS_CACERT /etc/ssl/certs/my_server_certificate.pem<br />
TLS_CACERTDIR /etc/ssl/certs<br />
<br />
Finally, you may or may not need to restart Apache, before configuring Moodle to use ldaps://<server DNS name><br />
httpd -k restart<br />
<br />
==Windows servers==<br />
'''These instructions are for establishing a link using an unverified self-signed certificate.'''<br />
<br />
You can tell PHP's OpenLDAP extension to disable SSL server certificate checking to do this you must create a directory called ''''C:\OpenLDAP\sysconf\'''' In this directory, create a file called ''ldap.conf'' with the following content:<br />
<br />
TLS_REQCERT never<br />
<br />
''(If you are using certain versions of PHP 5.3.x you '''may need to place the file at other locations''', [http://bugs.php.net/bug.php?id=48866 see PHP bug #48866])''<br />
<br />
Now you should be able to use '''ldaps://''' when connecting to your LDAP server.<br />
<br />
==Appendices==<br />
<br />
=== Setting Resource Limits RedHat Directory Server ===<br />
<br />
Operational attributes can be set for the bind user DN using the command-line. <br />
One can simply use ldapmodify to add the following attributes:<br />
<br />
{| border="1" cellspacing="0" cellpadding="5"<br />
! Attribute Name <br />
! Description<br />
|-<br />
| nsLookThroughLimit<br />
| Specifies how many entries are examined for a search operation. Giving this attribute a value of -1 indicates that there is no limit.<br />
|-<br />
| nsSizeLimit <br />
| Specifies the maximum number of entries the server returns to a client application in response to a search operation. Giving this attribute a value of -1 indicates that there is no limit.<br />
|-<br />
| nsTimeLimit <br />
| Specifies the maximum time the server spends processing a search operation. Giving this attribute a value of -1 indicates that there is no time limit.<br />
|-<br />
| nsIdleTimeout <br />
| Specifies the time a connection to the server can be idle before the connection is dropped. The value is given in seconds. Giving this attribute a value of -1 indicates that there is no limit.<br />
|}<br />
<br />
<pre> LDAP Console Command-Line<br />
<br />
ldapmodify -h redhat_dir_server -p 389 -D "cn=directory manager" -w secretpwd<br />
<br />
dn: uid=MoodleAdmin,ou=system,dc=myschool,dc=edu<br />
changetype: modify<br />
add:nsSizeLimit<br />
nsSizeLimit: 1000<br />
</pre> <br />
<br />
==Any questions?==<br />
<br />
Please post in the [http://moodle.org/mod/forum/view.php?id=42 Authentication forum] on moodle.org.<br />
<br />
==See also==<br />
<br />
* [[NTLM_authentication]]<br />
* [[Active_Directory]]<br />
* [[LDAP enrolment]]<br />
* [http://download.moodle.org/download.php/docs/en/how-to_guides/ldap_auth_and_enrolment_set-up.pdf LDAP auth and enrolment set-up guide] (PDF 227KB)<br />
<br />
Forum discussions:<br />
* [http://moodle.org/mod/forum/view.php?id=42 User authentication forum]<br />
* [http://moodle.org/mod/forum/discuss.php?d=32168 PHP LDAP module does not seem to be present] forum discussion<br />
* [http://moodle.org/mod/forum/discuss.php?d=140901 Syncronisation with AUTH_LDAP_SYNC_USERS.PHP produces fewer accounts than it should] forum discussion<br />
* [http://moodle.org/mod/forum/discuss.php?d=17198 Using multiple LDAP servers] forum discussion<br />
<br />
[[es:LDAP_authentication]]<br />
[[fr:Utiliser un serveur LDAP]]<br />
[[ja:LDAP認証]]<br />
[[de:LDAP-Server]]</div>Leonstrhttps://docs.moodle.org/310/en/index.php?title=Cron&diff=140590Cron2021-08-24T16:40:08Z<p>Leonstr: /* Scaling up cron with multiple processes */ Tidied formatting</p>
<hr />
<div>{{Installing Moodle}}<br />
The Moodle 'cron' process is a PHP script (part of the standard Moodle installation) that must be run regularly in the background. The Moodle cron script runs different tasks at differently scheduled intervals.<br />
<br />
'''IMPORTANT: Do not skip setting up the cron process on your server for your Moodle. Your site will not work properly without it.'''<br />
<br />
It is recommended that ''the cron is run every minute'', as required for asynchronous activity deletion when using the [[Recycle bin|recycle bin]].<br />
<br />
The cron program (that runs the Moodle script) is a core part of Unix based systems (including Linux and OSX) being used to run all manner of time-dependent services. On Windows the simplest solution is to create a task in the Windows Task Scheduler and set it to run at regular intervals. On shared hosting, you should find the documentation (or ask support) how cron is configured. Most shared hosting systems use CPanel to manage sites, and usually will have a section for Cron Jobs on the panel.<br />
<br />
Essentially, the task involves adding a single command to the list of cron activities on your system. On Unix based systems this list is a file called a 'crontab' which all users have. <br />
<br />
== General discussion ==<br />
<br />
See the later sections for your server type; this section contains some general background information. <br />
<br />
There are essentially two steps to implementing cron:<br />
# identifying the correct command to run<br />
# finding the right place on your system to put the command<br />
<br />
=== Working out the Moodle cron command ===<br />
<br />
Moodle has two different ways to deploy cron which use different scripts within the Moodle install. These are as follows...<br />
# The CLI (command line interpreter) script. This will be at the path <pre>/path/to/moodle/admin/cli/cron.php</pre> If in doubt, this is the correct script to use. This needs to be run by a 'PHP CLI' program on your computer. So the final command may look something like <pre>/usr/bin/php /path/to/moodle/admin/cli/cron.php</pre> You can (and should) try this on your command line to see if it works. '''WARNING: Check your command-line PHP version is compatible with your chosen version of Moodle. The command-line PHP program is different to the one running your web site and is not always the same version.'''<br />
# If, for some reason, you cannot run the CLI script there is the web based script. Note that this is now deprecated and may be removed in future versions. This needs to be run from a web browser and will be accessed via a web url something like '''http://your.moodle.site/admin/cron.php'''. You can find command line based web browser (e.g. wget) so the final command may look like <pre>/usr/bin/wget http://your.moodle.site/admin/cron.php</pre> This has the advantage that it can be run from *anywhere*. If you can't get cron to work on your machine it can be run somewhere else.<br />
<br />
===The web based Moodle cron command===<br />
* If you have a choice, do not use the web based cron. It is likely to be removed in a future Moodle version. <br />
* From Moodle 2.9 onwards, the cron job can no longer be run from web by default. You will get an error message:<br />
!!! Sorry, internet access to this page has been disabled by the administrator. !!! <br />
* You can change this in ' Dashboard ► Site administration ► Security ► Site policies ' by deselecting 'Cron execution via command line only'.<br />
** You will be warned that 'Running the cron from a web browser can expose privileged information to anonymous users. Thus it is recommended to only run the cron from the command line or set a cron password for remote access.'<br />
** You can then write a 'Cron password for remote access'. If this field is left empty, no password is required.<br />
** This means that the cron.php script cannot be run from a web browser without supplying the password using the following form of URL:<br />
http://site.example.com/admin/cron.php?password=opensesame<br />
<br />
=== Finding the right place to put the command ===<br />
<br />
This really does depend on the system you are using and you should find and read the documentation for your platform or hosting. In most cases getting the Moodle cron to run consists of establishing the correct command (above) and then adding it, and the time to run the command, to some sort of file. This might be either through a specific user interface or by editing the file directly.<br />
<br />
If using the CLI version you also need to make sure that the cron process is run as the correct user. This is not an issue with the web version. <br />
<br />
Example... installing cron on Ubuntu/Debian Linux. Assuming logged in as root..<br />
<br />
''use the crontab command to open a crontab editor window for the www-data user. This is the user that Apache (the web server) runs as on Debian based systems''<br />
<pre><br />
$ crontab -u www-data -e<br />
</pre><br />
''This will open an editor window. To run the cli cron script every 1 minute, add the line:''<br />
<pre><br />
* * * * * /usr/bin/php /path/to/moodle/admin/cli/cron.php >/dev/null<br />
</pre><br />
NOTE: the final '''>/dev/null''' sends all the output to the 'bin' and stops you getting an email every 1 minute.<br />
<br />
== Setting up cron on your system ==<br />
<br />
Choose the information for your server type:<br />
<br />
*[[Cron with Unix or Linux]]- Cron services on various UNIX and Linux flavored operating systems.<br />
*[[Cron with Windows OS]] - Cron services in Windows<br />
*''Apple OSX'' - use the built-in 'crontab' service which is exactly the same as [[Cron with Unix or Linux]]. However, you might want to do it the 'Apple way' using launchd - see [[Cron with MAC OS X]]<br />
*[[Cron with web hosting services]]- Cron services in various web hosting examples.<br />
<br />
Here are some more instructions for specific hosts (please check that these are up to date):<br />
<br />
*[[Cron on 1and1 shared servers]]<br />
<br />
== Using third party cron service ==<br />
<br />
Besides using cron hosted on your own server, you may use third party cron service (usually called webcron):<br />
<br />
*[https://cron-job.org/ cron-job.org] is a free service. (1Minute cron is possible)<br />
<br />
*[https://www.easycron.com EasyCron] - A webcron service provider that eliminates the need of crontab or other task schedulers to set cron job.<br />
<br />
*[https://webcron.talent-factory.ch/ WebCron] - A free and easy webcron service provider.<br />
<br />
=== Cron settings in Moodle ===<br />
<br />
An admin can set cron execution via command line only or a cron password for remote access in 'Site security settings' in the Site administration.<br />
<br />
===Remote cron===<br />
Using the 'web based' version of cron it is perfectly ok to place the cron process on a different machine to the Moodle server. For example, the cron service on a Unix server can invoke the cron web 'page' on a Windows based Moodle server.<br />
<br />
==Scheduling tasks==<br />
An administrator can schedule cron tasks very precisely from Administration > Site administration > Server > Scheduled tasks, see [[Scheduled tasks]]<br />
<br />
==Running cron for several Moodle servers==<br />
* Tasks can run in parallel and processes use locking to prevent tasks from running at the same time which allows cron to be triggered from multiple web servers that serve the same Moodle instance.<br />
<br />
* If you are running different Moodle instances on the same server, then each Moodle instance needs a cron job. (Even a single Apache web server can run different Moodle instances on different domains by using its virtual hosts capability [https://httpd.apache.org/docs/2.2/vhosts/index.html https://httpd.apache.org/docs/2.2/vhosts/index.html].)<br />
<br />
== Debugging Scheduled Tasks ==<br />
<br />
Sometimes, a particular cron task may not be working correctly. In Moodle versions before 2.7 - any cron task that was throwing exceptions would prevent the rest of cron from running. The only way to monitor if cron was completing each time, was to add some automated checking of the output of running cron (e.g. searching for the string "Cron completed at ").<br />
<br />
In Moodle 2.7 and later, a single failing scheduled task will not prevent the remaining tasks from completing. When any single scheduled task fails, it is marked as a failure, and scheduled to be reattempted. If the task keeps failing, the next scheduled time will be backed off until it is attempted at most once every 24 hours. But checking the [[Scheduled tasks]] admin page, you can see if any task is currently failing (it will have a non-zero fail delay - which is the number of seconds to wait before reattempting a failed task). A simple way to debug a failing task, is to run it immediately using the [[Administration via command line#Scheduled_tasks|cli scheduled task runner]] and monitor the output.<br />
<br />
== Logging and monitoring ==<br />
<br />
Ideally you should also be logging the output of cron somewhere and monitoring it for issues. You can monitor the overall status of cron to make sure there are no errors by visiting:<br />
<br />
Site administration / Reports / System status (/report/status/index.php)<br />
<br />
You can also wire this status report up to tools like Icinga / Nagios using the Check API (https://docs.moodle.org/dev/Check_API) cli commands or with the help of plugins like https://github.com/catalyst/moodle-tool_heartbeat.<br />
<br />
<code sh><br />
/admin/cli/checks.php<br />
</code><br />
<br />
If there are errors then you can get more details for recently run tasks from the Logs column on the Scheduled task page, but this won't show ad hoc task failures:<br />
<br />
Site administration / Server / Tasks / Scheduled tasks (/admin/tool/task/scheduledtasks.php)<br />
<br />
To see ad hoc task failures you either need to rerun the task manually yourself and see the errors, or you need to have already collected the logs for review. For a Moodle running on a single box you could log to a simple log file, or for a cluster you might want to use syslogd or similar, e.g.:<br />
<br />
<pre><br />
* * * * * /usr/bin/php /path/to/moodle/admin/cli/cron.php 2>&1 | /usr/bin/logger ...<br />
</pre><br />
<br />
== Low latency adhoc tasks ==<br />
<br />
Each time cron is run, after the scheduled tasks the ad hoc tasks are also run. While scheduled tasks can run at most once a minute, ad hoc tasks can be queued at any moment, and generally you want them processed as soon as possible and to not have to wait for the scheduled task to run first. If you only run the normal admin/cli/cron.php then not only might it have to wait to process all the scheduled tasks first, if it has already finished you will have to wait until the next minute for cron to start again for it to be processed.<br />
<br />
Instead you can run one or more dedicated ad hoc task processors which run in parallel to the main cron process.<br />
<br />
<pre><br />
* * * * * /usr/bin/php /path/to/moodle/admin/cli/adhoc_task.php --execute --keep-alive=59<br />
* * * * * /usr/bin/php /path/to/moodle/admin/cli/adhoc_task.php --execute --keep-alive=59<br />
...<br />
</pre><br />
<br />
Starting from Moodle 3.9 the—keep-alive option runs like a daemon so when the queue is empty rather than exiting it waits for new tasks to be queued so it can start processing as soon as possible.<br />
<br />
== Scaling up cron with multiple processes ==<br />
<br />
As your site grows many of the scheduled tasks will take longer to complete, and also there will be more ad hoc tasks queued which need to be processed. The cron system is designed to work in parallel but each individual process can only process one task at a time so you must run multiple cron cli's. You can generally run a fairly high number of cron processes on a dedicated cron instance before needing to run multiple cron instances. To run more than one process simply spawn multiple cron processes each minute:<br />
<br />
* * * * * /usr/bin/php /path/to/moodle/admin/cli/cron.php<br />
* * * * * /usr/bin/php /path/to/moodle/admin/cli/cron.php<br />
* * * * * /usr/bin/php /path/to/moodle/admin/cli/cron.php<br />
⋮<br />
* * * * * /usr/bin/php /path/to/moodle/admin/cli/adhoc_task.php --execute --keep-alive=59<br />
* * * * * /usr/bin/php /path/to/moodle/admin/cli/adhoc_task.php --execute --keep-alive=59<br />
* * * * * /usr/bin/php /path/to/moodle/admin/cli/adhoc_task.php --execute --keep-alive=59<br />
⋮<br />
<br />
It can be especially important to increase the number of adhoc_task.php processes as certain plugins and systems can generate very large numbers of ad hoc tasks, or tasks that can take a long time to process. Especially tasks like document conversions and automated backups can build up more quickly than they are processed if they are left on default settings.<br />
<br />
By default only 3 scheduled tasks and 3 ad hoc tasks can be run concurrently so as you add more processes you need to increase the level of allowed concurrency:<br />
<br />
Site administration > Server > Tasks > Task processing<br />
<br />
Or in <code>config.php</code>:<br />
<syntaxhighlight lang="php"><br />
$CFG->task_scheduled_concurrency_limit = 20; // Defaults to 3<br />
$CFG->task_adhoc_concurrency_limit = 50; // Defaults to 3<br />
</syntaxhighlight><br />
<br />
Whatever you set these too make sure the server(s) hosting them can comfortably handle this many processes. Often the bottleneck will be a shared service, usually the database.<br />
<br />
You may find that certain types of very long running tasks will consume all the available task processes which means no other tasks will run. e.g. if you have 5 cli processes, but in the task queue there are 20 ad hoc tasks for an automated backup, each of which will take ten minutes to complete, then very quickly all 5 processes will be consumed by backups and nothing else. Other small very fast and light tasks like a document conversion or forum emails will not get sent until the backups are complete and a process frees up. To manage this you can limit the concurrency of specific types of ad hoc tasks. A good rule of thumb is that if all of the 'heavy' tasks consume all of their own limits then you should still have another few processes standing by on idle waiting for anything else which may be added to the queue.<br />
<br />
Automated backups are the worst known offender, so hypothetically if you are running 50 ad hoc task processes concurrently a reasonable restriction might be to cap the backups to consume no more than half of those processes, ie 25 at most:<br />
<br />
In <code>config.php</code>:<br />
<syntaxhighlight lang="php"><br />
$CFG->task_concurrency_limit = [<br />
'core\task\course_backup_task' => 25,<br />
'core_course\task\course_delete_modules' => 5,<br />
];<br />
</syntaxhighlight><br />
<br />
==See also==<br />
<br />
* [[Scheduled tasks]]<br />
* [http://en.wikipedia.org/wiki/Cron Wikipedia article on cron function]<br />
* MDL-50694 - Cron message "The operation timed out while waiting for a lock" isn't really an error<br />
<br />
Forum discussions:<br />
*[http://moodle.org/mod/forum/discuss.php?d=139263#p609060 How to log the output of a Scheduled Task on Windows] - this discussion explains a nice trick that can be very useful when you are experiencing problems with your Windows Scheduled Task and you need to log the output of the Scheduled Task to a log file.<br />
<br />
[[es:Cron]]<br />
[[fr:Cron]]<br />
[[ja:Cron]]<br />
[[de:Cron-Job]]</div>Leonstrhttps://docs.moodle.org/310/en/index.php?title=Report_builder&diff=140586Report builder2021-08-23T10:43:09Z<p>Leonstr: Changed <code> to <syntaxhighlight></p>
<hr />
<div>{{Workplace}}<br />
= Overview =<br />
Moodle Workplace provides a graphical custom reporting tool. Moodle Workplace custom reports are built using the report builder interface, which provides advanced customization options to administrators. System reports are used in every listing in Workplace: Dashboard, [[Programs]], [[Certifications]], [[Dynamic rules]], and even in the Report builder itself. <br />
<br />
{{MediaPlayer | url = https://youtu.be/gvQ6WqFYGns | desc = Moodle Workplace | Training | Report Builder}}<br />
<br />
= Accessing the report builder =<br />
The report builder can be made available to all users, and is accessed from the Workplace launcher. For instructions on granting access to a report, see the [[#Configuring_audience|configuring audience]] section below.<br />
<br />
= Creating a custom report =<br />
To create a new custom report, the administrator clicks the plus icon on the reports tab. Reports can use any data from their data sources, including data from the Workplace Datastore that contains historical information and snapshots of past events. <br />
<br />
[[File:wp-rb-new-report.png]]<br />
<br />
After selecting a data source for the new report, we can click on a column or drag it into the table to add it to the report. To use aggregation on any column, we just need to click on the "Select an aggregation for the column" icon and then we can select the kind of aggregation depending on the column data type.<br />
<br />
== Limiting number of custom reports ==<br />
A site administrator can restrict the number of custom reports that can be created per site/tenant by adding the following line(s) to the [[Configuration_file|site configuration]]:<br />
<br />
<syntaxhighlight lang="php"><br />
$CFG->tool_reportbuilder_limitsenabled = true;<br />
$CFG->tool_reportbuilder_sitelimit = <VALUE>;<br />
$CFG->tool_reportbuilder_tenantlimit = <VALUE>;<br />
</syntaxhighlight><br />
<br />
Omitting this configuration, or setting <tt>$CFG->tool_reportbuilder_limitsenabled = false;</tt> indicates that no limit should be applied to the number of custom reports that can be created. Enabling limits and setting the values to 0 will disable the creation of custom reports. Note that a tenant limit cannot exceed a site limit.<br />
<br />
== Disabling live editing in reports ==<br />
For performance reasons a site administrator may consider disabling live editing of reports, that being the constant updating of report data while editing report content (columns, filters, conditions) by adding the following to the [[Configuration_file|site configuration]]:<br />
<br />
<syntaxhighlight lang="php"><br />
$CFG->tool_reportbuilder_liveediting = false;<br />
</syntaxhighlight><br />
<br />
Omitting this configuration, or setting <tt>$CFG->tool_reportbuilder_liveediting = true;</tt> indicates that live editing is enabled.<br />
<br />
= Conditions and Filters =<br />
Clicking in the "Show/hide filters sidebar" icon on the right will expand the right panel that we can use to define conditions and filters and set the default sorting order. Using conditions, we can pre-filter the report for the users. Conditions cannot be changed in the viewing mode. In the filters tab, we can define filters and we can define the default sorting order using the last tab just by selecting and rearranging the available options. <br />
<br />
[[File:wp-rb-conditions.png]]<br />
<br />
= Preview report =<br />
Finally the report can be previewed by clicking the "Switch to preview view" icon, and it displays as it would for the person viewing the report, including any conditions defined. Filters can be reset using the icon on each filter or all at once.<br />
<br />
[[File:wp-rb-preview.png]]<br />
<br />
= Sending report results =<br />
Custom reports can be created and scheduled to be sent out to specific audiences. From the manage custom reports page, navigate to the schedules tab. Here, the administrator clicks the "New schedule" button and selects which report they would like to be sent. Various report formats are available to use for attached report data (CSV, Excel Spreadsheet, HTML, JSON, ODS, PDF), as well as recurrence options (send every weekday, month, etc). The administrator can also select which user should be used when sending the scheduled report. This allows the report to be sent to the audience as if it were being viewed by that user.<br />
<br />
The audience options allow the administrator to select which users should receive the report. In addition to selecting which position and department within an organisation should be included, it is also possible to manually select individual users and/or e-mail addresses.<br />
<br />
Finally, the message subject and content can be configured.<br />
<br />
[[File:wp-rb-schedule.png]]<br />
<br />
= Configuring audience =<br />
<br />
Any person with the capability to manage or view reports can view all custom reports defined in their tenant. It is also possible to specify [[Organisation_structure#Assigning_jobs|individual jobs]] that will grant access to the reports to their holders. To specify which jobs should be able to access a given report, navigate to the "Audience" tab when editing it. To specify a new job press the "Add job" button and select the preferred position and department that comprises the job. You can add as many jobs to set the audience for the report as necessary. Once complete, press the "Save changes" button. To confirm which users now have access to the report, switch to the "Access" tab.<br />
<br />
In addition to granting user access to reports, it is also possible to specify which users should be listed in any given report. To achieve this the "[[Report_builder_(Audience)|Relation to the report viewer]]" condition should be added to the report.<br />
<br />
[[File:wp-rb-audience.png]]<br />
<br />
= Shared reports =<br />
After enabling [[Multi-tenancy#Shared_Space|Shared space]], users can create shared reports inside of it. These shared reports will be listed in the custom reports page in all tenants and will be marked with a "Shared space" label next to it.<br />
<br />
This feature enables users to use the same report definition site-wide without duplicating the same reports in all tenants. It also allows to create cross-tenant reports. When a shared report is viewed from inside the tenant it only displays the users and entities from this tenant. When a shared report is viewed from Shared space it shows information from all tenants.<br />
<br />
[[File:Shared reports - 02.png]]<br />
<br />
Reports in the shared space can be shared with all tenants or be only accessible to users with access to the shared space.<br />
<br />
== Creating a new shared report ==<br />
Access the Shared space from the tenant switch dropdown, in the navigation bar. When inside the Shared space go to Report Builder in the Workplace launcher and create a new report as usual.<br />
<br />
There's a setting to effectively share the report to make it available in other tenants. If this is not set, the report will be available only in the shared space (see the screenshot below).<br />
<br />
[[File:Shared reports - 01.png]]</div>Leonstrhttps://docs.moodle.org/310/en/index.php?title=Course_backup&diff=140583Course backup2021-08-19T14:51:54Z<p>Leonstr: /* Backup via CLI for administrators */ Removed <code>; removed stray '\$'</p>
<hr />
<div>{{Backup}}<br />
A course can be saved with some or all of its parts by using the course backup. Typically, the site administrator will set a schedule of [[Automated course backup|automated course backups]] for the whole site. A teacher can create a backup or download an existing backup for safe keeping, or for use on another Moodle site. <br />
<br />
{{MediaPlayer | url = https://youtu.be/0qF4Qr5xTIY| desc = Course backup}}<br />
<br />
<br />
==Backing up a course==<br />
<br />
To backup a course<br />
<br />
# Go into the course.<br />
# Click the Backup link either in the gear menu or the Administration block (depending upon the theme).<br />
# Initial settings - Select activities, blocks, filters and other items as required then click the Next button. Users with appropriate permissions, such as administrators and managers, can choose whether to [[Backup of user data|include users]], anonymize user information, or include user role assignments, groups, groupings, user files, comments, user completion details, course logs and grade history in the backup.<br />
# Schema settings - Select/deselect specific items to include in backup, then click the Next button.<br />
# If desired, select specific types of activity to be backed up by clicking the link 'Show type options' <br />
# Confirmation and review - Check that everything is as required, using the Previous button if necessary, otherwise click the 'Perform backup' button<br />
# Complete - Click the Continue button<br />
<br />
{|<br />
[[File:backupgroups.png|thumb|Backup settings]]<br />
|<br />
|[[File:26backuprestore1.png|thumb|Back up screen with option to select all or none]]<br />
|<br />
|[[File:26backuprestore2.png|thumb|Back up screen with option to select activity types]]<br />
|}<br />
<br />
A backup file (with distinctive .mbz extension to avoid confusion with .zip files) is then saved in the course backup area. Backup file names are of the form ''backup-moodle2-course-coursename-date-hour.mbz'', ending in ''-nu.mbz'' when backed up with no users and ''-an.mbz'' with anonymized names.<br />
<br />
Tip: If you are satisfied with the default settings and don't wish to go through all the backup screens, you can simply click 'Jump to final step' to perform the backup.<br />
<br />
==Anonymizing user information==<br />
<br />
Anonymize user information is a backup feature which "protects user identities" by making each user anonymous. If this box is checked in the backup initial settings, Moodle will substitute aliases for real names, substituting @doesntexist.com email addresses and so forth. For example "Max Manager" might become "anonfirstname4 anonlastname4".<br />
<br />
==Asynchronous course backups==<br />
<br />
Note: With large courses it is helpful to be able to continue working while a course backup is being made. To achieve this, you need to enable asynchronous backups in ''Site Administration / Courses / Backups / Asynchronous backup/restore''.<br />
<br />
==Backup via CLI for administrators==<br />
<br />
Site administrators can backup selected courses using a CLI script.<br />
<br />
Options<br />
--courseid=INTEGER (Course ID for backup.)<br />
--courseshortname=STRING (Course shortname for backup.)<br />
--destination=STRING (Path where to store backup file. If not set the backup will be stored within the course backup file area.)<br />
-h, --help (Print out this help.)<br />
<br />
Example<br />
sudo -u www-data /usr/bin/php admin/cli/backup.php --courseid=2 --destination=/moodle/backup/<br />
<br />
On Windows you will use cmd.exe to run the /admin/cli/backup.php script. If you have your Moodledata folder setup on a separate data server you can specify a UNC path to your backup folder on that data server. From the command line CD to the Moodle ''\admin\cli'' folder and run this command:<br />
php backup.php --courseid=25 --destination=\\moodledata\backup<br />
<br />
<br />
where '--courseid' is the id of the course that you want to backup.<br />
<br />
The .mbz backup file for courseid=25 will be stored in the ''backup'' subfolder in the ''Moodledata'' ($CFG->dataroot) folder.<br />
<br />
==Tips and tricks==<br />
<br />
Lose content after a restore in Moodle 2.0 ? Do you see topic headings that say "Orphaned activities"? Solution: Go to course settings and increase the number of topic sections and things will return to normal.<br />
<br />
==Creative uses==<br />
The backup and restore processes can offer the teacher and administrators many creative solutions.<br />
*Duplicating courses or specific activities in one course to another course (similar to Import)<br />
*Updating a production Moodle site course, with material from a localhost site course<br />
*Transferring a course to a new Moodle site.<br />
*In earlier versions of Moodle, a way of rolling a course forward without past student activity<br />
*Creating a blank activity, save just that activity and then restore it to the course or another course one or more times. <br />
<br />
==General backup defaults==<br />
<br />
Default settings for course backups can be set by a site administrator in 'General backup defaults' in the Site administration.<br />
<br />
Selected settings may be locked, so that they cannot be changed when creating a course backup.<br />
<br />
By selecting a time in the "Keep logs for.." dropdown, it is possible to specify how long backup logs information is kept before being deleted. As this information may be very large, it is recommended the length of time chosen be quite short.<br />
<br />
==Course backup stops above 90%, not showing any errors==<br />
This has been reported to be caused by:<br />
* a [[Course_formats#Contributed_Course_Formats|non-standard course_format]]. Try replacing the course format.<br />
* not enough server RAM. Adding more RAM to your server is usually the first [[Performance_recommendations|performance recommendation]].<br />
<br />
==Course backup capabilities==<br />
<br />
*[[Capabilities/moodle/backup:anonymise|Anonymise user data on backup]]<br />
*[[Capabilities/moodle/backup:backupcourse|Backup courses]]<br />
*[[Capabilities/moodle/backup:backupsection|Backup sections]]<br />
*[[Capabilities/moodle/backup:backuptargetimport|Backup for import]]<br />
*[[Capabilities/moodle/backup:configure|Configure backup options]]<br />
*[[Capabilities/moodle/backup:downloadfile|Download files from backup areas]]<br />
*[[Capabilities/moodle/backup:userinfo|Backup user data]]<br />
<br />
==Error: Trying to restore user 'admin' from backup file will cause conflict ==<br />
* Before proceeding, it would be advisable to have a second admin account ''just in case something goes wrong''.<br />
* Check that the admin accounts on each server have '''different''' unique usernames and email addresses and then try again to backup up the course with user data and restore it. <br />
** If you can not make a new backup and you must use an existing 'conflicting' backup file, you will have to change the new site's main admin account with extreme care to remember the new main admin's password and email.<br />
* Note that the admin account from the imported file may loose the password and become unusable; <br />
* You are advised to update/reset the 'imported' main 'admin's account's password before logging out, as this will most likely be the main 'admin' account for the site, and you would get into serious problems if this account stops working.<br />
* If something goes terribly wrong, you can use the second admin account to fix the main admin account. <br />
<br />
==See also==<br />
<br />
*[[Course restore]]<br />
*[[Backup of user data]]<br />
*[[Activity backup]]<br />
* Administrators can use [http://moosh-online.com/commands/#course-restore MOOSH] to bulk backup and restore courses from CLI<br />
<br />
[[Category:Course]]<br />
<br />
[[de:Kurssicherung]]<br />
[[es:Respaldo del curso]]<br />
[[eu:Ikastaroaren_Segurtasun-kopia]]<br />
[[fr:Sauvegarde de cours]]<br />
[[ja:コースバックアップ]]</div>Leonstrhttps://docs.moodle.org/310/en/index.php?title=Transitioning_to_HTTPS&diff=140582Transitioning to HTTPS2021-08-18T10:26:11Z<p>Leonstr: /* Redirecting the HTTP address to the new HTTPS address */ Changed <code> to <syntaxhighlight></p>
<hr />
<div>{{Security}}<br />
There are [https://developers.google.com/web/fundamentals/security/encrypt-in-transit/why-https numerous benefits] to running your moodle site using HTTPS. This increases the level of security especially involving sessions and passwords.<br />
<br />
== Steps ==<br />
=== Before you start ===<br />
Check all the content you use supports https. Use the [[HTTPS conversion tool]] to do this.<br />
<br />
Make sure you have a staging environment. You will want to set up HTTPS the first time on a staging environment rather than updating your live site. It will take some time to convert to https and you will need to update content (see below).<br />
<br />
=== Setting up an SSL certificate ===<br />
The first thing you will need to do is acquire an SSL certificate. You can create these yourself, but this is only helpful for development purposes. Instead you will want to get your SSL certificate from a certificate authority, so that the certificate will be publicly verified.<br />
<br />
The cost of certificates has been somewhat prohibitive, they come at various costs from a few dollars to hundreds of dollars per year. For the budget constrained, the "price is right" with a new initiative brought to us by the Internet Security Research Group (ISRG). Free domain-validated certificates can be acquired from [https://letsencrypt.org Let's Encrypt]. Let's Encrypt also tries to make the process of installing and managing certificates as painless as possible and there are numerous methods and clients available.<br />
<br />
=== Setting up your server ===<br />
Then you will need enable SSL on your web server to add your certificate. This process will vary depending on your web server of choice.<br />
<br />
If you are using a proxy or load balancer, depending on your setup you will most likely want to set up the SSL certificate on your proxy server<br />
<br />
=== Setting up your Moodle ===<br />
<br />
On a basic Moodle site, it will be simple to set up https. Simply edit config.php and change http:// to https:// in $CFG->wwwroot.<br />
<br />
However if you are using a proxy or load balancer, depending on your setup you may need to set $CFG->sslproxy to 1, and not use SSL on the Moodle server. Then the load balancer or proxy server can communicate directly to your Moodle site, but serve to the clients over SSL.<br />
<br />
=== Redirecting the HTTP address to the new HTTPS address ===<br />
<br />
You may want to add a redirection so that users who have the current http:// address to your site will be redirected automatically to the https:// address instead of getting a page with a message such as "For security reasons only https connections are allowed, sorry." <br />
<br />
There are several ways to do redirections, depending on your web server, hosting, and how you prefer to do this. A common solution on Apache web servers is to create an .htaccess file with a rewrite rule such as:<br />
<br />
<syntaxhighlight lang="apacheconf"><br />
RewriteEngine On<br />
RewriteCond %{SERVER_PORT} 80<br />
RewriteRule ^(.*)$ https://www.yourmoodle.com/$1 [R,L]<br />
</syntaxhighlight><br />
or in general<br />
<syntaxhighlight lang="apacheconf"><br />
RewriteEngine On<br />
RewriteCond %{SERVER_PORT} 80<br />
RewriteRule ^(.*)$ {SERVER_NAME}/$1 [R,L]<br />
</syntaxhighlight><br />
<br />
Be sure to look up current ways to do this for your web server and host, such as the how-to article [https://www.ssl.com/how-to/force-https-connections-in-an-apache-server-environment/ Force HTTPS connections in an Apache server environment].<br />
<br />
=== Updating content ===<br />
You will need to change all embeded content from being requested over http. Links do not matter. But you will need to update images and iframes, scorm modules, and LTI external tools. You can modify external tools to open in a new window instead of in an iframe and they will work fine.<br />
<br />
A new tool was added to Moodle 3.4 to aid in this process. This is available via a link in ''Site administration > Security > HTTP security > HTTPS conversion tool''. See MDL-46269 for details.<br />
<br />
== See also ==<br />
<br />
* [https://developers.google.com/web/fundamentals/security/encrypt-in-transit/why-https Why HTTPS Matters - Google Web Fundamentals]<br />
<br />
[[es:Haciendo la transición a HTTPS]]</div>Leonstrhttps://docs.moodle.org/310/en/index.php?title=Session_handling&diff=140579Session handling2021-08-17T13:23:42Z<p>Leonstr: Changed <code> to <syntaxhighlight></p>
<hr />
<div>{{Server settings}}<br />
An administrator can change the following settings in 'Session Handling' in the Site administration.<br />
<br />
Once someone logs in to your Moodle server, the server starts a session. The session data allows the server to track users as they access different pages.<br />
<br />
==Use database for session information==<br />
<br />
Moodle needs to store the session data in some storage. By default either file or database session storage is selected, this option allows admin to change it. Large installation should use memcached driver described below.<br />
<br />
Note that this option disappears after setting the $CFG->session_handler_class in config.php file.<br />
<br />
==Timeout==<br />
<br />
If users don't load a new page during the amount of time set here, Moodle will end their session and log them out.<br />
<br />
Be sure this time frame is long enough to cover the longest test your teachers may offer. If a student is logged out while they are taking a test, their responses to the test questions may be lost.<br />
<br />
==Cookie prefix==<br />
<br />
Most of the time, you can leave this blank, unless you are running more than one Moodle site on the same server. In this case, you will want to customize the name of the cookie each Moodle site uses to track the session. This enables you to be logged into more than one Moodle site at the same time.<br />
<br />
Note: If you change "Cookie prefix" or "Cookie path" you will need to login again as the changes take effect immediately.<br />
<br />
==Cookie path==<br />
<br />
The relative path to this Moodle installation, this may be used to force sending of Moodle session cookie to parent directories. Invalid values are ignored automatically.<br />
<br />
==Cookie domain==<br />
<br />
This can be used to send session cookies to higher domains instead of just the server domain. This may be useful for some SSO solutions. Invalid values are ignored automatically.<br />
<br />
==Session drivers==<br />
User sessions may be stored in different backends. Session drivers can be configured only in config.php file - see examples in config-dist.php file.<br />
<br />
===Memcached session driver===<br />
The Memcached session driver is the fastest driver. It requires external memcached server and memcached PHP extension. Server cluster nodes must use shared session storage.<br />
<br />
Configuration options in config.php:<br />
<syntaxhighlight lang="php"><br />
$CFG->session_handler_class = '\core\session\memcached';<br />
$CFG->session_memcached_save_path = '127.0.0.1:11211';<br />
$CFG->session_memcached_prefix = 'memc.sess.key.';<br />
$CFG->session_memcached_acquire_lock_timeout = 120;<br />
$CFG->session_memcached_lock_expire = 7200; // Ignored if memcached extension <= 2.1.0<br />
</syntaxhighlight><br />
<br />
Notes:<br />
* Make sure the memcached server has enough memory.<br />
* Use different prefix when storing sessions from multiple Moodle sites in one server.<br />
* If PECL memcached extension version installed is less that 2.2.0, the locking works differently from other drivers - the lock is expired/released at the end of timeout - see MDL-42485.<br />
* '''Don't use the same memcached server for both sessions and MUC. Events triggering MUC caches to be purged leads to MUC purging the memcached server - thus terminating ALL sessions.'''<br />
* The <code php>$CFG->session_memcached_number_of_replicas</code> option is no longer supported.<br />
<br />
For windows users, PHP.net only supplies binaries for memcache, (and not memcached). (http://windows.php.net/downloads/pecl/releases/)<br />
<br />
(As of 2.7, two different contribs exist for memcache session handling - see MDL-42011 - it seems the OU one doesn't use prefix/lock_expire for some reason... possibly better to use the catalyst patch, where the only difference to the above config.php is the spelling of memcache(d).)<br />
<br />
===File session driver===<br />
This driver is used by default in new installation.<br />
<br />
Configuration options in config.php:<br />
<syntaxhighlight lang="php"><br />
$CFG->session_handler_class = '\core\session\file';<br />
$CFG->session_file_save_path = $CFG->dataroot.'/sessions';<br />
</syntaxhighlight><br />
<br />
Notes:<br />
* File based sessions require file system that supports file locking.<br />
<br />
===Database session driver===<br />
This type of driver was used by default in Moodle 2.0-2.5.<br />
<br />
<syntaxhighlight lang="php"><br />
$CFG->session_handler_class = '\core\session\database';<br />
$CFG->session_database_acquire_lock_timeout = 120;<br />
</syntaxhighlight><br />
<br />
Notes:<br />
* DB sessions are not compatible with MyISAM database engine.<br />
* If you are using MySQL/MariaDB make sure that \'max_allowed_packet\' in my.cnf (or my.ini) is at least 4M.<br />
* The performance is relatively low, it is not recommended for large sites.<br />
<br />
===Redis session driver===<br />
<br />
The [[Redis]] session driver is available in Moodle 3.1.3 onwards (see MDL-54606). It requires a [[Redis_cache_store#Installing_Redis_server|Redis server]] and the [[Redis_cache_store#Installing_Redis_php_driver|Redis extension]].<br />
<br />
Configuration options in config.php:<br />
<syntaxhighlight lang="php"><br />
$CFG->session_handler_class = '\core\session\redis';<br />
$CFG->session_redis_host = '127.0.0.1';<br />
$CFG->session_redis_port = 6379; // Optional.<br />
$CFG->session_redis_database = 0; // Optional, default is db 0.<br />
$CFG->session_redis_auth = ''; // Optional, default is don't set one.<br />
$CFG->session_redis_prefix = ''; // Optional, default is don't set one.<br />
$CFG->session_redis_acquire_lock_timeout = 120;<br />
$CFG->session_redis_acquire_lock_retry = 100; // Optional, default is 100ms (from 3.9)<br />
$CFG->session_redis_lock_expire = 7200;<br />
$CFG->session_redis_serializer_use_igbinary = false; // Optional, default is PHP builtin serializer.<br />
</syntaxhighlight><br />
<br />
Notes:<br />
* Be careful on changing the default serializer: it requires <code php>--enable-redis-igbinary</code> at ''phpredis'' extension compile time '''and''' you need to remove '''the previous session data''' before using Moodle again.<br />
<br />
== Read only sessions ==<br />
<br />
There is an experimental feature in Moodle 3.9 allowing certain pages to start readonly sessions which do not require a write lock with the aim of high performance at scale. <br />
<br />
https://tracker.moodle.org/browse/MDL-58018<br />
<br />
Details TBA<br />
<br />
==See also==<br />
* [[Sessions FAQ]]<br />
<br />
[[cs:admin/setting/sessionhandling]]<br />
[[ja:セッションハンドリング]]<br />
[[de:Sitzungsinformationen]]<br />
[[es:Manejo de la sesión]]<br />
[[fr:Gestion des sessions]]</div>Leonstrhttps://docs.moodle.org/310/en/index.php?title=LDAP_authentication&diff=140576LDAP authentication2021-08-05T08:49:29Z<p>Leonstr: /* User lookup settings */ memberattribute_isdn needs setting manually: MDL-70596</p>
<hr />
<div>{{Authentication}}<br />
This document describes how to set up Lightweight Directory Access Protocol (LDAP) authentication in Moodle. We cover the basic, advanced and some trouble shooting sections to assist the user in the installation and administrating LDAP in Moodle. <br />
<br />
==Basic Scenario==<br />
The simple and straightforward approach for most installations.<br />
<br />
===Assumptions===<br />
Moodle supports several types of LDAP servers which have different directory structures, special configuration settings, etc. Even if using the same LDAP server type (e.g., MS Active Directory), each site could use a completely different directory structure to hold its user accounts, groups, etc. In order to be able to show example configuration settings in the sections below, we are going to assume a '''hypothetical''' Moodle site and LDAP server with the characteristics listed below.<br />
<br />
'''IMPORTANT NOTICE''': be sure to check '''''your''''' Moodle site and LDAP server details (including its directory structure,) and adjust the settings to reflect your own setup.<br />
<br />
# Your Moodle site is located at '''http://your.moodle.site/'''<br />
# You have configured your PHP installation with the LDAP extension. It is loaded and activated, and it shows when you go to '''http://your.moodle.site/admin/phpinfo.php''' (logged in as user 'admin').<br />
# Your LDAP server has '''192.168.1.100''' as its IP address.<br />
# You are not using LDAP with SSL (also known as LDAPS) in your settings. This might prevent certain operations from working (e.g., you cannot update data if you are using MS Active Directory -- MS-AD from here on --), but should be OK if you just want to authenticate your users.<br />
# You don't want your users to change their passwords the first time they log in into Moodle.<br />
# You are using a single domain as the source of your authentication data in case you are using MS-AD (more on this in the Appendices).<br />
# You are using a top level distinguished name (DN) of '''dc=my,dc=organization,dc=domain''' as the root of your LDAP tree. <br />
# You have a non-privileged LDAP user account you will use to bind to the LDAP server. This is not necessary with certain LDAP servers, but MS-AD requires this and it won't hurt if you use it even if your LDAP server doesn't need it. Make sure '''this account and its password don't expire''', and make this password as strong as possible. Remember you only need to type this password once, when configuring Moodle, so don't be afraid of making it as hard to guess as possible. Let's say this user account has a DN of '''cn=ldap-user,dc=my,dc=organization,dc=domain''', and password '''hardtoguesspassword'''.<br />
# All of your Moodle users are in an organizational unit (OU) called '''moodleusers''', which is right under your LDAP root. That OU has a DN of '''ou=moodleusers,dc=my,dc=organization,dc=domain'''.<br />
# You '''don't''' want your LDAP users' passwords to be stored in Moodle at all.<br />
<br />
===Enabling LDAP authentication===<br />
<br />
An administrator can enable LDAP authentication as follows:<br />
<br />
# Go to ''Site administration > Plugins > Authentication > Manage authentication'' and click the eye icon opposite LDAP Server. When enabled, it will no longer be greyed out.<br />
# Click the settings link, configure as required (see information below), then click the 'Save changes' button.<br />
<br />
[[Image:LDAPserversettings.png|center]]<br />
<br />
Now, you just have to fill in the values. Let's go step by step.<br />
<br />
====LDAP Server Settings====<br />
{| border="1" cellspacing="0" cellpadding="5"<br />
! Field name<br />
! Value to fill in<br />
|-<br />
| Host URL<br />
| As the IP of your LDAP server is 192.168.1.100, type "'''ldap://192.168.1.100'''" (without the quotes), or just "'''192.168.1.100'''" (some people have trouble connecting with the first syntax, specially on MS Windows servers).<br />
|-<br />
| Version<br />
| Unless you are using a really old LDAP server, '''version 3''' is the one you should choose.<br />
|-<br />
| LDAP Encoding<br />
| Specify encoding used by LDAP server. Most probably utf-8.<br />
|}<br />
<br />
[[LDAP_authentication#Table of Contents|Table of Contents]]<br />
<br />
====Bind settings====<br />
{| border="1" cellspacing="0" cellpadding="5"<br />
! Field name<br />
! Value to fill in<br />
|-<br />
| Don't cache passwords<br />
| As you '''don't''' want to store the users's password in Moodle's database, choose '''Yes''' here.<br />
|-<br />
| Distinguished Name<br />
| This is the distinguished name of the bind user defined above. Just type "'''cn=ldap-user,dc=my,dc=organization,dc=domain'''" (without the quotes).<br />
|-<br />
| Password<br />
| This is the bind user password defined above. Type "'''hardtoguesspassword'''" (without the quotes).<br />
|}<br />
<br />
[[LDAP_authentication#Table of Contents|Table of Contents]]<br />
<br />
====User lookup settings====<br />
{| border="1" cellspacing="0" cellpadding="5"<br />
! Field name<br />
! Value to fill in<br />
|-<br />
| User type<br />
| Choose: <br />
* '''Novel Edirectory''' if your LDAP server is running Novell's eDdirectory.<br />
* '''posixAccount (rfc2307)''' if your LDAP server is running a RFC-2307 compatible LDAP server (choose this is your server is running OpenLDAP, including Mac OS X server).<br />
* '''posixAccount (rfc2307bis)''' if your LDAP server is running a RFC-2307bis compatible LDAP server.<br />
* '''sambaSamAccount (v.3.0.7)''' if your LDAP server is running with SAMBA's 3.x LDAP schema extension and you want to use it.<br />
* '''MS ActiveDirectory''' if your LDAP server is running Microsoft's Active Directory (MS-AD)<br />
|-<br />
| Contexts<br />
| The DN of the context (container) where all of your Moodle users are found. Type '''ou=moodleusers,dc=my,dc=organization,dc=domain''' here. <br />
<br />
On a Mac OS X Server, this is usually '''cn=users,dc=my,dc=organization,dc=domain'''.<br />
|-<br />
| Search subcontexts<br />
| If you have any sub organizational units (subcontexts) hanging from '''ou=moodleusers,dc=my,dc=organization,dc=domain''' and you want Moodle to search there too, set this to '''yes'''. Otherwise, set this to '''no'''.<br />
|-<br />
| Dereference aliases<br />
| Sometimes your LDAP server will tell you that the real value you are searching for is in fact in another part of the LDAP tree (this is called an alias). If you want Moodle to 'dereference' the alias and fetch the real value from the original location, set this to '''yes'''. If you don't want Moodle to dereference it, set this to '''no'''. If you are using MS-AD, set this to '''no'''.<br />
|-<br />
| User attribute<br />
| The attribute used to name/search users in your LDAP tree. This option takes a default value based on the ''User type'' value you chose above. <u>So unless you need something special, you don't need to fill this in</u>.<br />
<br />
By the way, it's usually '''cn''' (Novell eDirectory and MS-AD) or '''uid''' (RFC-2037, RFC-2037bis and SAMBA 3.x LDAP extension), but if you are using MS-AD you could (and have to, if you intend to use NTLM SSO) use '''sAMAccountName''' (the pre-Windows 2000 logon account name) if you need too.<br />
<br />
'''Correction''': With MS-AD '''sAMAccountName''' should be used anyway. With default value ('''cn''') AD users will have to login with full name / password (Username: '''John Doe''', Password: '''john's_pass'''). If you want to enable your users to login with domain username instead (Username: '''johnd''' Password: '''john's_pass'''), you should use '''sAMAccountName'''. Sadly, but logging in with DOMAIN\user or user@domain.com will not work anyway.<br />
<br />
Note: You may wish to consider allowing extended characters in usernames in ''Administration > Site administration > Security > [[Site policies]]''. <br />
|-<br />
| Member attribute<br />
| The attribute used to list the members of a given group. This option takes a default value based on the ''User type'' value you choosed above. <u>So unless you need something special, you don't need to fill this in.</u><br />
<br />
By the way, the usual values are '''member''' and '''memberUid'''.<br />
|-<br />
| Member attribute uses dn<br />
| Whether the member attribute contains distinguished names (Yes) or not (No). <s>This option takes a default value based on the ''User type'' value you choosed above. <u>So unless you need something special, you don't need to fill this in.</u></s> This must be set to Yes for LDAP servers such as Active Directory (see MDL-70596).<br />
|-<br />
| Object class<br />
| The type of LDAP object used to search for users. This option takes a default value based on the ''User type'' value you chose above. <u>So unless you need something special, you don't need to fill this in.</u><br />
* If you leave it blank, the default value based on the ''User type'' selected above will be used (see below)<br />
* If you provide "objectClass=some-string", then it will provide "(objectClass=some-string)" as the filter.<br />
* If you provide a value that does not start with "(", it is assumed to be a value that should be set to "objectClass". So if you provide "some-string", then it will provide "(objectClass=some-string)" as the filter.<br />
* If you provide a string that starts with a "(", then it will pass that as is. So if you provide "(&(objectClass=user)(enabledMoodleUser=1))", then it will pass that as the filter.<br />
<br />
'''Note''': In the last case, that feature can be used on interactive logins,<br />
<br />
Here are the default values for each of the ''ldap_user_type'' values:<br />
* '''(objectClass=user)''' for Novel eDirectory<br />
* '''(objectClass=posixAccount)''' for RFC-2037 and RFC-2037bis<br />
* '''(objectClass=sambaSamAccount)''' for SAMBA 3.0.x LDAP extension<br />
* '''(objectClass=user)''' for MS-AD<br />
* '''(objectClass=*)''' for Default<br />
If you get an error about a problem with updating the ldap server (even if you have specified not to write changes back to the ldap server) try setting the ldap object class to * - see http://moodle.org/mod/forum/discuss.php?d=70566 for a discussion on this problem<br />
|}<br />
<br />
====Force change password====<br />
{| border="1" cellspacing="0" cellpadding="5"<br />
! Field name<br />
! Value to fill in<br />
|-<br />
| Force change password<br />
| '''NOTE: This setting is only used when creating your users with the LDAP sync users task. It's not used if your users are created as part of their first login to moodle'''.<br />
<br />
Set this to ''Yes'' if you want to force your users to change their password on the first login into Moodle. Otherwise, set this to ''no''. Bear in mind the password they are forced to change is the one stored in your LDAP server.<br />
<br />
<u>As you don't want your users to change their passwords in their first login, leave this set to ''No''</u><br />
|-<br />
| Use standard Change Password Page<br />
|<br />
* Setting this to ''Yes'' makes Moodle use its own standard password change page, everytime users want to change their passwords.<br />
* Setting this to ''No'' makes Moodle use the page specified in the field called "Password change URL" (see below).<br />
<br />
Bear in mind that changing your LDAP passwords from Moodle might require a LDAPS connection (this is actually a requirement for MS-AD). In addition to that, the bind user specified above must have the rights needed to change other users' passwords.<br />
<br />
Also, code for changing passwords from Moodle for anything but Novell eDirectory and Active Directory is almost not tested, so this may or may not work for other LDAP servers.<br />
|-<br />
| Password Format<br />
| Specify how the new password is encrypted before sending it to the LDAP server: Plain text, MD5 hash or SHA-1 hash. MS-AD uses plain text, for example.<br />
|-<br />
| Password change URL<br />
| Here you can specify a location at which your users can recover or change their username/password if they've forgotten it. This will be provided to users as a button on the login page and their user page. if you leave this blank the button will not be printed.<br />
|}<br />
<br />
====LDAP password expiration settings====<br />
{| border="1" cellspacing="0" cellpadding="5"<br />
! Field name<br />
! Value to fill in<br />
|-<br />
| Expiration<br />
| <br />
* Setting this to ''No'' will make Moodle not to check if the password of the user has expired or not.<br />
* Setting this to ''LDAP'' will make Moodle check if the LDAP password of the user has expired or not, and warn them a number of days before the password expires. When the password has expired, a "Your password has expired" message is displayed, and if the user is able to change their password from Moodle, they are offered the option to do so.<br />
<br />
Current code only deals with Novell eDirectory LDAP server and MS-AD.<br />
<br />
<u>So unless you have Novell eDirectory server or MS-AD, choose ''No'' here.</u><br />
|-<br />
| Expiration warning<br />
| This value sets how many days in advance of password expiration the user is warned that her password is about to expire.<br />
|-<br />
| Expiration attribute.<br />
| The LDAP user attribute used to check password expiration. This option takes a default value based on the ''User type'' value you chose above. <u>So unless you need something special, you don't need to fill this in.</u><br />
|-<br />
| Grace logins<br />
| This setting is specific to Novell eDirectory. If set to ''Yes'', enable LDAP gracelogin support. After password has expired the user can login until gracelogin count is 0.<br />
<br />
<u>So unless you have Novell eDirectory server and want to allow gracelogin support, choose ''No'' here.</u><br />
|-<br />
| Grace login attribute<br />
| This setting is currently not used in the code (and is specific to Novell eDirectory). <br />
<br />
<u>So you don't need to fill this in.</u><br />
|}<br />
<br />
====Enable user creation====<br />
{| border="1" cellspacing="0" cellpadding="5"<br />
! Field name<br />
! Value to fill in<br />
|-<br />
| Create users externally<br />
| New (anonymous) users can self-create user accounts on the external LDAP server and confirm them via email. If you enable this, remember to also configure module-specific options for user creation and to fill in some instructions in ''auth_instructions'' field in ''Site administration > Plugins > Authentication > Manage authentication''. Otherwise the new users won't be able to self-create new accounts.<br />
<br />
Novell eDirectory and MS-AD can create users externally. You can also create users in RFC-2307 compliant servers. <br />
|-<br />
| Context for new users<br />
| Specify the context where users are created. This context should be different from other users' contexts to prevent security issues. <br />
|}<br />
<br />
====Assign system roles====<br />
{| border="1" cellspacing="0" cellpadding="5"<br />
! Field name<br />
! Value to fill in<br />
|-<br />
| System role mapping<br />
| This section lists all roles that have can be assigned in the System context - by default this will be "Manager context" and "Course creator context", but can be customisable in the [[Creating custom roles|role definitions]].<br />
<br />
To assign LDAP users to any of the roles, specify the DN containing all users who should be granted that role at the system level.<br />
<br />
Thie DN is typically a posixGroup with a "memberUid" attribute for each user you want to be a creator. If your group is called ''creators'', type '''cn=creators,ou=moodleusers,dc=my,dc=organization,dc=domain''' here. Each memberUid attribute contains the CN of a user who is authorized to be a creator. Do not use the user's full DN (e.g., not '''memberUid: cn=JoeTeacher,ou=moodleusers,dc-my,dc=organizations,dc=domain''', but rather '''memberUid: JoeTeacher''').<br />
<br />
In eDirectory, the objectClass for a group is (by default) not '''posixGroup''' but '''groupOfNames,''' whose member attribute is '''member,''' not '''memberUid,''' and whose value is the full DN of the user in question. Although you can probably modify Moodle's code to use this field, a better solution is just to add a new '''objectClass''' attribute of '''posixGroup''' to your creators group and put the CNs for each creator in a '''memberUid''' attribute.<br />
<br />
In MS Active Directory, you will need to create a security group for your creators to be part of and then add them all. If your ldap context above is 'ou=staff,dc=my,dc=org' then your group should then be 'cn=creators,ou=staff,dc=my,dc=org'. If some of the users are from other contexts and have been added to the same security group, you'll have to add these as separate contexts after the first one using the same format.<br />
<br />
This section replaces the "Course creator" section found in Moodle 3.3. The upgrade process should migrate any DN specified to the new approach.<br />
<br />
|}<br />
<br />
====User account synchronisation====<br />
{| border="1" cellspacing="0" cellpadding="5"<br />
! Field name<br />
! Value to fill in<br />
|-<br />
| Removed ext user<br />
| Specify what to do with internal user account during mass synchronization when user was removed from external source. Only suspended users are automatically revived if they reappear in ext source.<br />
|}<br />
<br />
====NTLM SSO====<br />
{| border="1" cellspacing="0" cellpadding="5"<br />
! Field name<br />
! Value to fill in<br />
|-<br />
| Enable<br />
| If you want to use NTLM SSO (see details at [[NTLM_authentication]]), choose ''Yes'' here. Otherwise, choose ''No''.<br />
|-<br />
| Subnet<br />
| Specify the subnets of the clients that will use NTLM SSO (see details at [[NTLM_authentication]]).<br />
|-<br />
| MS IE Fast Path?<br />
| If all of you clients (or most of them) are using MS Internet Explorer, you can set this option to bypasses certain steps of the SSO login and speed up login times. This only works with MS Internet Explorer, but deals with other browsers in a sensible way (they are automatically sent to the plain login page).<br />
|}<br />
<br />
====Data Mapping====<br />
{| border="1" cellspacing="0" cellpadding="5"<br />
! Field name<br />
! Value to fill in<br />
|-<br />
| First name<br />
| The name of the attribute that holds the first name of your users in your LDAP server. This is usually '''givenName''' or '''displayName'''<br />
<br />
<u>This setting is optional</u><br />
|-<br />
| Surname<br />
| The name of the attribute that holds the surname of your users in your LDAP server. This is usually '''sn'''.<br />
<br />
<u>This setting is optional</u><br />
|-<br />
| Email address<br />
| The name of the attribute that holds the email address of your users in your LDAP server. This is usually '''mail'''.<br />
<br />
<u>This setting is optional</u><br />
|-<br />
| City/town<br />
| The name of the attribute that holds the city/town of your users in your LDAP server. This is usually '''l''' (lowercase L) or '''localityName''' (not valid in MS-AD).<br />
<br />
<u>This setting is optional</u> <br />
|-<br />
| Country<br />
| The name of the attribute that holds the country of your users in your LDAP server. This is usually '''c''' or '''countryName''' (not valid in MS-AD).<br />
<br />
<u>This setting is optional</u><br />
|-<br />
| Language<br />
| '''preferredLanguage'''<br />
<br />
<u>This setting is optional</u><br />
|-<br />
| Description<br />
| '''description'''<br />
<br />
<u>This setting is optional</u><br />
|-<br />
| Webpage<br />
| <u>This setting is optional</u><br />
|-<br />
| ID Number<br />
| <br />
<br />
<u>This setting is optional</u><br />
|-<br />
| Institution<br />
| <br />
<br />
<u>This setting is optional</u><br />
|-<br />
| Department<br />
| The name of the attribute that holds the department name of your users in your LDAP server. This is usually '''departmentNumber''' (for posixAccount and maybe eDirectory) or '''department''' (for MS-AD).<br />
<br />
<u>This setting is optional</u><br />
|-<br />
| Phone 1<br />
| The name of the attribute that holds the telephone number of your users in your LDAP server. This is usually '''telephoneNumber'''.<br />
<br />
<u>This setting is optional</u><br />
|-<br />
| Phone 2<br />
| The name of the attribute that holds an additional telephone number of your users in your LDAP server. This can be '''homePhone''', '''mobile''', '''pager''', '''facsimileTelephoneNumber''' or even others.<br />
<br />
<u>This setting is optional</u><br />
|-<br />
| Address<br />
| The name of the attribute that holds the street address of your users in your LDAP server. This is usually '''streetAddress''' or '''street'.<br />
<br />
<u>This setting is optional</u><br />
|}<br />
<br />
=====Custom User profile fields=====<br />
<br />
Any user profile fields created in ''Site administration > Users > Accounts > User profile fields'' should now automatically show up at the end of the Data mapping field list after the '''Address''' field. See example: [[File:ldapcustomuserprofilefields.jpg]]<br />
<br />
==Enabling the LDAP users sync job==<br />
<br />
The LDAP users sync job (''\auth_ldap\task\sync_task'') [[Scheduled tasks|scheduled task]] (new in Moodle 3.0; previously there was a CLI script, see MDL-51824 for more info) is responsible for creating and updating user information, and suspending and deleting LDAP accounts. <br />
<br />
After enabling LDAP server authentication, an administrator needs to enable and configure the LDAP users sync job as follows:<br />
<br />
# Go to ''Site administration > Server > Scheduled tasks'' and click the gear icon opposite LDAP users sync job.<br />
# Select the desired frequency of running and enable the task by un-ticking the disabled checkbox.<br />
{{Warning|It is important to make sure that all LDAP settings are working properly before enabling the LDAP users sync job (as well as backing up your database and moodledata folders), since incorrect LDAP configuration can result in users being wrongly deleted!}}<br />
<br />
If you find that the script is not running through all of your users properly and you have over 1000 users in each LDAP container, this is because by default some LDAP stores such as MS AD only send back 1000 users at a time and PHP versions prior to 5.4 did not implement paged support for LDAP results. If you upgrade to PHP 5.4 or higher than Moodle will obtain all your users correctly. If you can't upgrade to PHP 5.4 you may be able to follow the instructions in http://support.microsoft.com/kb/315071 to set the Active Directory MaxPageSize setting to a number higher than your total number of users (both now and in future) to fix it. This is a forest-wide setting.<br />
<br />
==Active Directory help==<br />
[[Active Directory]] is Microsoft's directory service. It is included in Windows 2000 Server and later versions of their operating system. For more information about subjects below, '''[[Active Directory|please go here]]'''.<br />
<br />
*Warning: The PHP LDAP module does not seem to be present<br />
*LDAP-module cannot connect any LDAP servers <br />
*Getting correct CNs for Contexts and Creators<br />
*Getting the right user_attribute<br />
*Installing ldp.exe Server Tool<br />
*Example Active Directory Configuration<br />
*Child Domains and the Global Catalog in MS Active Directory<br />
*Enabling the Global Catalog<br />
*Active Directory with Moodle 1.8<br />
*MS Active Directory + SSL<br />
<br />
==Advanced Scenarios - Multiple servers or locations==<br />
For larger installations with multiple LDAP servers, or multiple locations (contexts) in a LDAP tree.<br />
<br />
===Making your LDAP directory connection resilient===<br />
* Entering more than one name in the ldap_host_url field can provide some sort of resilience to your system. Simply use the syntax:<br />
<br />
ldap://my.first.server; ldap://my.second.server; ...<br />
<br />
Of course, this will only work if all the servers share the same directory information, if using eDirectory you would need to ensure your servers have viability of all relevant tree partitions, or if using Active Directory the servers are holding the same information you need though replication - see notes on a multi-domain environment if this applies.<br />
<br />
There is one drawback in Moodle 1.5 - 1.6 implementation of LDAP authentication : the auth_ldap_connect() function processes the servers sequentially, not in a round robin mode. Thus, if the primary server fails, you will have to wait for the connection to time out before switching to the following one.<br />
<br />
See also: [http://moodle.org/mod/forum/discuss.php?d=17198 Using multiple LDAP servers - Our students are on separate domain] forum discussion<br />
<br />
===Using a multi-domain AD environment===<br />
* If you're running Active Directory with multiple domains and you have users in more than one domain you will want to configure Moodle to look at your Global Catalog server. Specifically your top level domain Global Catalog server. Here is a simple example of this kind of Active Directory layout:<br />
<br />
my.domain.ca (Root AD Domain)<br />
| - dc1.my.domain.ca (Domain Controller)<br />
| - dc2.my.domain.ca (Domain Controller)<br />
|<br />
| - - students.my.domain.ca (Sub AD Domain)<br />
| - - - dc1.students.my.domain.ca (Domain Controller)<br />
| - - - dc2.students.my.domain.ca (Domain Controller)<br />
|<br />
| - - faculty.my.domain.ca (Sub AD Domain)<br />
| - - - dc1.faculty.my.domain.ca (Domain Controller)<br />
| - - - dc2.faculty.my.domain.ca (Domain Controller)<br />
<br />
In this example we have our top level domain (my.domain.ca) and two sub-domains. One sub-domain is for faculty accounts (faculty.my.domain.ca) and the other is for student accounts (students.my.domain.ca). Listed under each of those are two domain controllers.<br />
<br />
Using the above example you'll want to use the following for accessing the Global Catalog over SSL:<br />
<br />
ldaps://my.domain.ca:3269/<br />
<br />
If you prefer to access your global catalog over a non-SSL connection you'll want to use:<br />
<br />
ldap://my.domain.ca:3268/<br />
<br />
We found if you didn't configure things this way you'd get errors like:<br />
<br />
[Thu May 26 15:23:53 2011] [error] [client 192.168.xxx.xxx] PHP Warning: ldap_search() [<a href='function.ldap-search'>function.ldap-search</a>]: Search: Partial results and referral received in /xxx/xxx/moodle20/lib/ldaplib.php on line 241, referer: http://moodle.my.domain.ca/moodle20/login/index.php<br />
[Thu May 26 15:23:53 2011] [error] [client 192.168.xxx.xxx] PHP Warning: ldap_first_entry(): supplied argument is not a valid ldap result resource in /xxx/xxx/moodle20/lib/ldaplib.php on line 248, referer: http://moodle.my.domain.ca/moodle20/login/index.php<br />
<br />
===Using multiple user locations (contexts) in your LDAP tree===<br />
There is no need to use multiple user locations if your directory tree is flat, i.e. if all user accounts reside in a '''ou=people,dc=my,dc=organization,dc=domain''' or '''ou=people,o=myorg''' container. <br />
<br />
At the opposite, if you use the ACL mecanism to delegate user management, there are chances that your users will be stored in containers like '''ou=students,ou=dept1,o=myorg''' and '''ou=students,ou=dept2,o=myorg''' ...<br />
<br />
Then there is an alternative :<br />
* Look at the '''o=myorg''' level with the ldap_search_sub attribute set to '''yes'''.<br />
* Set the ldap_context to '''ou=students,ou=dept1,o=myorg ; ou=students,ou=dept2,o=myorg'''.<br />
<br />
Choosing between these two solutions supposes some sort of benchmarking, as the result depends heavily on the structure of your directory tree '''and''' on your LDAP software indexing capabilities. Simply note that there is a probability in such deep trees that two users share the same ''common name'' (cn), while having different ''distinguished names''. Then only the second solution will have a deterministic result (returning always the same user).<br />
<br />
===Using LDAPS (LDAP over SSL)===<br />
====Enabling LDAPS on your directory server====<br />
<br />
* [[Active_Directory#MS_Active_Directory_.2B_SSL|Enabling LDAPS on MS Active Directory ]]<br />
<br />
====Enabling LDAPS on your Moodle server====<br />
Enabling LDAPS on your server can be tricky and often it is hard to pinpoint where things are going wrong. There are also differences between Windows and Linux and even different versions and distributions of Linux. <br />
<br />
'''If you have not done so already you will need to decide upon your approach to establishing an SSL connection to your directory server:'''<br />
<br />
* SSL connection with unverified self-signed certificate.<br />
<br />
You can generate your own SSL certificate, and then instruct your Moodle server to ignore the fact that it is not valid. This setup is not as secure as others since you cannot be sure the server you are connecting to is not fake.<br />
<br />
* SSL connection with trusted self-signed certificate.<br />
<br />
You can generate your own SSL certificate on your directory server, and then specifically trust this certificate by installing it on your Moodle server. <br />
<br />
* SSL connection with verified certificate from Internet-trusted certificate authority (CA)<br />
<br />
In this approach the LDAP server has an installed certificate from an Internet-based CA, this means that your directory server would have an Internet address & host name. Your Moodle server must be trusting the certificate authority and have Internet access. This approach is not often used as it usually incurs a cost for the certificate, and it requires your directory server and Moodle server to be exposed to the Internet.<br />
<br />
==Linux servers==<br />
'''These instructions are for establishing a link using a trusted self-signed certificate.'''<br />
<br />
''Note: written for a Red Hat Enterprise Linux 6 server, other Linux distributions may differ, especially in the location of the SSL certificates and OpenLdap config files, but the core principals are the same.''<br />
<br />
To check that your directory server is online and accepting SSL connections on your LDAPS port (636), you can use try:<br />
openssl s_client –connect <ldap server ip address>:636<br />
<br />
Get your directory server’s certificate (.crt) and upload to Moodle server's ssl certificate directory, on RHEL6 this is at '''/etc/ssl/certs'''<br />
<br />
Convert your ‘DER’ X509 certificate into a ‘PEM’ public key certificate.<br />
openssl x509 -in my_server_certificate.cer -inform DER -out my_server_certificate.pem -outform PEM<br />
<br />
Create certificate hashes using c_rehash<br />
c_rehash<br />
''If c_rehash is not installed install with: yum install /usr/bin/c_rehash''<br />
<br />
Ensure you are able to access your LDAPS server by a DNS name, this may mean adding an entry to your host file (/etc/hosts)<br />
<ldap server ip address> my_server.mydomain.school<br />
<br />
Verify your certificate to check that it is installed correctly<br />
openssl verify -verbose -CApath /etc/ssl/certs /etc/ssl/certs/my_server_certificate.pem<br />
/etc/ssl/certs/my_server_certificate.pem: OK<br />
<br />
You should now be able to connect to your LDAPS server over SSL without any errors<br />
openssl s_client –connect <ldap server DNS name>:636<br />
<br />
Edit your OpenLDAP config, on RHEL6 this is located at '''/etc/openldap/ldap.conf'''<br />
# Define location of a CA Cert<br />
TLS_CACERT /etc/ssl/certs/my_server_certificate.pem<br />
TLS_CACERTDIR /etc/ssl/certs<br />
<br />
Finally, you may or may not need to restart Apache, before configuring Moodle to use ldaps://<server DNS name><br />
httpd -k restart<br />
<br />
==Windows servers==<br />
'''These instructions are for establishing a link using an unverified self-signed certificate.'''<br />
<br />
You can tell PHP's OpenLDAP extension to disable SSL server certificate checking to do this you must create a directory called ''''C:\OpenLDAP\sysconf\'''' In this directory, create a file called ''ldap.conf'' with the following content:<br />
<br />
TLS_REQCERT never<br />
<br />
''(If you are using certain versions of PHP 5.3.x you '''may need to place the file at other locations''', [http://bugs.php.net/bug.php?id=48866 see PHP bug #48866])''<br />
<br />
Now you should be able to use '''ldaps://''' when connecting to your LDAP server.<br />
<br />
==Appendices==<br />
<br />
=== Setting Resource Limits RedHat Directory Server ===<br />
<br />
Operational attributes can be set for the bind user DN using the command-line. <br />
One can simply use ldapmodify to add the following attributes:<br />
<br />
{| border="1" cellspacing="0" cellpadding="5"<br />
! Attribute Name <br />
! Description<br />
|-<br />
| nsLookThroughLimit<br />
| Specifies how many entries are examined for a search operation. Giving this attribute a value of -1 indicates that there is no limit.<br />
|-<br />
| nsSizeLimit <br />
| Specifies the maximum number of entries the server returns to a client application in response to a search operation. Giving this attribute a value of -1 indicates that there is no limit.<br />
|-<br />
| nsTimeLimit <br />
| Specifies the maximum time the server spends processing a search operation. Giving this attribute a value of -1 indicates that there is no time limit.<br />
|-<br />
| nsIdleTimeout <br />
| Specifies the time a connection to the server can be idle before the connection is dropped. The value is given in seconds. Giving this attribute a value of -1 indicates that there is no limit.<br />
|}<br />
<br />
<pre> LDAP Console Command-Line<br />
<br />
ldapmodify -h redhat_dir_server -p 389 -D "cn=directory manager" -w secretpwd<br />
<br />
dn: uid=MoodleAdmin,ou=system,dc=myschool,dc=edu<br />
changetype: modify<br />
add:nsSizeLimit<br />
nsSizeLimit: 1000<br />
</pre> <br />
<br />
==Any questions?==<br />
<br />
Please post in the [http://moodle.org/mod/forum/view.php?id=42 Authentication forum] on moodle.org.<br />
<br />
==See also==<br />
<br />
* [[NTLM_authentication]]<br />
* [[Active_Directory]]<br />
* [[LDAP enrolment]]<br />
* [http://download.moodle.org/download.php/docs/en/how-to_guides/ldap_auth_and_enrolment_set-up.pdf LDAP auth and enrolment set-up guide] (PDF 227KB)<br />
<br />
Forum discussions:<br />
* [http://moodle.org/mod/forum/view.php?id=42 User authentication forum]<br />
* [http://moodle.org/mod/forum/discuss.php?d=32168 PHP LDAP module does not seem to be present] forum discussion<br />
* [http://moodle.org/mod/forum/discuss.php?d=140901 Syncronisation with AUTH_LDAP_SYNC_USERS.PHP produces fewer accounts than it should] forum discussion<br />
* [http://moodle.org/mod/forum/discuss.php?d=17198 Using multiple LDAP servers] forum discussion<br />
<br />
[[es:LDAP_authentication]]<br />
[[fr:Utiliser un serveur LDAP]]<br />
[[ja:LDAP認証]]<br />
[[de:LDAP-Server]]</div>Leonstrhttps://docs.moodle.org/310/en/index.php?title=Using_the_Microsoft_SQL_Server_Driver_for_PHP&diff=140575Using the Microsoft SQL Server Driver for PHP2021-08-04T11:32:40Z<p>Leonstr: /* Installation overview */ Changed <code> to <syntaxhighlight></p>
<hr />
<div>{{Installing Moodle}}<br />
== Using the SQL Server Driver for PHP from Microsoft ==<br />
<br />
== Introduction ==<br />
This short manual is for running Moodle 2.0 (and upwards) using the Microsoft SQL Server (MSSQL) RDBMS. The steps detailed below must be performed '''before''' installing Moodle itself.<br />
<br />
First of all, the minimum required version of MSSQL has been stabilized to MSSQL 2005 (v.9).<br />
<br />
== Installation overview ==<br />
1. Install Microsoft SQL Server including SQL Server Management Studio. ([http://www.microsoft.com/sql/editions/express/default.mspx A free version, SQL Server Express Edition] is available for testing.)<br />
:Make sure to choose mixed authentication (Windows and local accounts) to keep things simpler later. Define the "sa" account password when requested (it's the default System Administrator account which has full access to all databases by default).<br />
<br />
2. Configure Windows for MSSQL.<br />
:By default, MSSQL listens to port 1433 for incoming TCP/IP connections and this port needs to be opened in the firewall. This is explicitly configured in the firewall installed (either Windows Firewall in the Control Panel or the configuration interface for other firewalls). If the port was changed when MSSQL was installed, then specify the correct port number to open in the firewall.<br />
:Confirm the TCP/IP protocol is enabled in: '''SQL Server Configuration Manager''' -> '''Network Configuration''' -> '''Protocols''' -> '''TCP/IP enabled'''<br />
<br />
3. Create and configure a new database.<br />
:Open "SQL Server Management Studio" and create a new empty database.<br />
*Execute the following command to enable Row Versioning:<br />
<br />
<syntaxhighlight lang="tsql"><br />
USE MASTER<br />
GO<br />
ALTER DATABASE &lt;your-database-name&gt; SET READ_COMMITTED_SNAPSHOT ON<br />
GO<br />
</syntaxhighlight><br />
<br />
4. Install PHP and a web server.<br />
*PHP can be downloaded from [http://www.php.net/downloads.php www.php.net]<br />
*If IIS is used as the web server, IIS 7.0 or later is recommended with [http://www.iis.net/download FastCGI and WinCache]. <br />
<br />
5. Install the SQL Server Driver for PHP.<br />
:On the web server, install [http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=20098 SQL Server Driver for PHP] including all the pre-requisites listed on the download page. Note: it is critical to install the SQL Server Native Access Client version documented on the download page of the SQL Server Driver for PHP.<br />
:Configure PHP to use the appropriate SQLSRV driver. In php.ini, set the following:<br />
<br />
For PHP 5.2.4 (or later)<br />
<br />
<syntaxhighlight lang="ini"><br />
[PHP_SQLSRV]<br />
extension=php_sqlsrv_52_nts_vc9.dll<br />
</syntaxhighlight><br />
<br />
For PHP 5.3.2 (or later)<br />
<br />
<syntaxhighlight lang="ini"><br />
[PHP_SQLSRV]<br />
extension=php_sqlsrv_53_nts_vc9.dll<br />
</syntaxhighlight><br />
<br />
For PHP 5.6.24 (or later)<br />
<br />
<syntaxhighlight lang="ini"><br />
[PHP_SQLSRV]<br />
extension=php_sqlsrv.dll<br />
</syntaxhighlight><br />
<br />
The Microsoft documentation for the SQL Server Driver for PHP is available at: http://msdn.microsoft.com/en-us/library/ee229548(v=SQL.10).aspx <br />
<br />
6. Install and configure Moodle.<br />
:Continue with the [[Installing Moodle|standard Moodle installation]].<br />
<br />
7. The Moodle '''config.php''' should include lines like these:<br />
<syntaxhighlight lang="php"><br />
$CFG->dbtype = 'sqlsrv'; // Required<br />
$CFG->dbhost = 'localhost'; // Assuming that MSSQL is on the same server, otherwise <br />
// use the actual name or IP address of your database server<br />
$CFG->dbname = 'moodle'; // The name of the newly created Moodle database<br />
$CFG->dbuser = 'yourusername'; // your database username<br />
$CFG->dbpass = 'yourpassword'; // your database password<br />
$CFG->dbpersist = true;<br />
$CFG->prefix = 'mdl_'; // The prefix can be changed per individual preferences, <br />
// but NEVER leave this blank!<br />
</syntaxhighlight><br />
<br />
:If the config.php file doesn't exist, it will be generated as normal from the Moodle installer. Alternatively, use the config-dist.php file that comes with the Moodle package to create a custom config.php file.<br />
<br />
8. Restart or start your web server.<br />
:If Moodle still cannot communicate with the database server, turn '''display_startup_errors''' to "On" in the /PHP/php.ini file, then restart the web server and check for any errors that may indicate incorrect DLL versions or missing dependencies. These error reports, turned off by default in PHP, can be vital in locating a problem with new extension installations.<br />
<br />
9. Test the database connection.<br />
:Try this PHP script, just add a text file called test.php from the example below and change ('localhost', 'db_user', 'db_password') to align with the config.php settings, and load from local host (http://localhost/test.php).<br />
<br />
<syntaxhighlight lang="php"><br />
<?php<br />
$link = sqlsrv_connect($this->dbhost, array('DATABASE'=>'db_name', 'UID' => 'db_user', 'PWD' => 'db_password'));<br />
if($link === FALSE) {<br />
echo 'Could not connect';<br />
die('Could not connect: ' . sqlsrv_errors(SQLSRV_ERR_ALL));<br />
}<br />
echo 'Successful connection';<br />
sqlsrv_close($link);<br />
?><br />
</syntaxhighlight><br />
<br />
10. Complete the rest of the Moodle installation as usual.<br />
<br />
== See Also ==<br />
* [[Errors FAQ]]<br />
* [[Installing MSSQL for PHP]], about how to install Moodle on SQL*Server using the FreeTDS drivers.<br />
* Using Moodle [http://moodle.org/mod/forum/view.php?id=28 Installation problems forum]<br />
* Microsoft SQL Server Driver for PHP solves major Moodle performance problems. See: [http://moodle.org/mod/forum/discuss.php?d=183987 Hardware and Performance Forum]<br />
<br />
[[Category:XMLDB]]</div>Leonstrhttps://docs.moodle.org/310/en/index.php?title=Installing_plugins&diff=140574Installing plugins2021-07-31T09:55:50Z<p>Leonstr: /* Preventing installing plugins from within Moodle */ Changed <code> to <syntaxhighlight></p>
<hr />
<div>{{Installing Moodle}}<br />
==Why install additional plugins?==<br />
<br />
Plugins enable you to add additional features and functionality to Moodle, such as new activities, new quiz question types, new reports, integrations with other systems and many more. <br />
<br />
Note: Certain hosting solutions, such as [https://moodle.com/cloud/ MoodleCloud], prevent plugins being installed from within Moodle.<br />
<br />
==Choosing the best plugins for your site==<br />
<br />
Note: It is recommended that you proceed with caution and always try installing these plugins in a local experimental server before installing them in a production server.<br />
<br />
* Moodle has a [https://moodle.org/plugins/report/index.php?report=favourites&p=0&l=50&s=favourited&d=DESC list of the most favourite plugins], which might be worth considering for adding to your site :)<br />
* You can find the plugins with the largest number of downloads in the last three months at [https://moodle.org/plugins/stats.php https://moodle.org/plugins/stats.php]. These are the plugins most likely to be most useful for most sites. It would probably be a good idea to consider them first.<br />
* You can test and try more than 50 of the most popular Moodle plugins at [http://plugins.moodlebites.com plugins.moodlebites.com]<br />
* See the [https://moodle.org/mod/forum/discuss.php?d=325804 list of (year 2015) favorite plugins] by Gavin Henrick<br />
* Moodle has a list of plugins that have received the [https://moodle.org/plugins/browse.php?list=award&id=1 Reviewers' choice award]. These are given by the plugins guardians and reviewers for particularly useful, well coded or otherwise interesting plugins. <br />
* If your Moodle site needs assessment beyond the sixteen [https://docs.moodle.org/310/en/Question_types#Standard_question_types standard question types included in Moodle core], see the many (49 in 2017) available [https://docs.moodle.org/310/en/Third-party_question_types third party question types].<br />
* Special cases:<br />
** All plugins with ''mobile'' in their name, are related to [https://docs.moodle.org/310/en/Moodle_Mobile mobile devices].<br />
<br />
===Elementary school teaching===<br />
You might consider some plugins for [[Gamification|gamification]], such as the [https://moodle.org/plugins/mod_quizgame Quizventure].<br />
<br />
===Plugins for K-12 teaching===<br />
For [https://en.wikipedia.org/wiki/K%E2%80%9312 K-12] teaching and learning environments, consider these plugins: <br />
* [https://moodle.org/plugins/mod_attendance Attendance]<br />
* [http://bigbluebutton.org/ BigBlueButton]<br />
* [https://moodle.org/plugins/mod_checklist Checklist]<br />
* [https://moodle.org/plugins/atto_chemistry Chemistry editor]<br />
* [https://moodle.org/plugins/mod_choicegroup Group choice]<br />
* [https://moodle.org/plugins/block_xp Level up!]<br />
* [https://moodle.org/plugins/mod_quizgame Quizventure]<br />
* [https://moodle.org/plugins/tinymce_wordcount Word count]<br />
<br />
===Plugins for University teaching===<br />
For universities, there is a [https://docs.moodle.org/310/en/Tertiary_education#Moodle_plugins_by.2Ffor_Universities list of plugins by/for Universities], and a [https://docs.moodle.org/310/en/Tertiary_education#Discipline-specific_plugins link to discipline-specific plugins], which might be worth considering.<br />
<br />
== Considerations for production sites (skip if you're just moodling) ==<br />
<br />
'''VERY IMPORTANT''' Warning: Please be aware that some plugins have not been reviewed, and the quality and/or suitability for your Moodle site has not been checked. Please be careful. It may not do what you expect, it may have serious security issues or it may even not work at all. This is however improving over time with the evolving new plugins directory system.<br />
<br />
* If you have a large site for production purposes consider if you '''really''' need the plugin? More functionality means more things to support, more things to (potentially) go wrong and more things to worry about at upgrade time. <br />
* Is the plugin supported and maintained? If something goes wrong can you get support? Will bugs be fixed?<br />
* If the plugin does not work in a future version of Moodle, what will you do about it?<br />
* Beware of ''patches'' ([https://moodle.org/plugins/browse.php?list=category&id=38 Moodle Plugins Directory Other category]) ! If a plugin modifies or replaces core files then be very careful. It can only be guaranteed to work with the exact build (version) of Moodle it was created for and is highly unlikely to survive a Moodle upgrade.<br />
* Look at [https://moodle.org/mod/forum/discuss.php?d=340821#p1373707 this] and [https://moodle.org/mod/forum/discuss.php?d=346296 also this] forum threads of users worried about installing a plugin.<br />
<br />
==Installing a plugin==<br />
<br />
To install a plugin, its source code must be put (deployed) into the appropriate location inside the Moodle installation directory and the main administration page ''Administration > Site administration > Notifications'' must be visited. There are three ways how the plugin code can be deployed into Moodle.<br />
<br />
Plugin code may be deployed from within Moodle, either directly from the Moodle plugins directory or by uploading a ZIP file. The web server process has to have write access to the plugin type folder where the new plugin is to be installed in order to use either of these methods.<br />
<br />
Alternatively, a plugin may be deployed manually at the server.<br />
<br />
{{Note|Whenever you install or download a plugin from the Moodle plugins directory, it is extremely important that you have correctly chosen your [[Moodle version]]. If you mistakenly download and install the wrong version of a plugin for your Moodle server, this may lead to some serious problems, even freezing of the Moodle site.}} <br />
<br />
===Installing directly from the Moodle plugins directory===<br />
<br />
# Login as an admin and go to ''Site administration > Plugins > Install plugins''. (If you can't find this location, then plugin installation is prevented on your site.)<br />
# Click the button 'Install plugins from Moodle plugins directory'.<br />
# Select your current [[Moodle version]], then search for a plugin with an Install button, click the Install button, then click Continue.<br />
# Confirm the installation request<br />
# Check the plugin validation report<br />
<br />
===Installing via uploaded ZIP file===<br />
<br />
# Go to the [https://moodle.org/plugins Moodle plugins directory], select your current [[Moodle version]], then choose a plugin with a Download button and download the ZIP file.<br />
# Login to your Moodle site as an admin and go to ''Administration > Site administration > Plugins > Install plugins''.<br />
# Upload the ZIP file. You should only be prompted to add extra details (in the Show more section) if your plugin is not automatically detected.<br />
# If your target directory is not writeable, you will see a warning message.<br />
# Check the plugin validation report<br />
<br />
{|<br />
| [[File:plugin1.png|thumb|Install plugins]]<br />
| [[File:add-on package validation.png|thumb|Plugin package validation]]<br />
|}<br />
<br />
===Installing manually at the server===<br />
<br />
If you can't deploy the plugin code via the administration web interface, you have to copy it to the server file system manually (e.g. if the web server process does not have write access to the Moodle installation tree to do this for you).<br />
<br />
First, establish the correct place in the Moodle code tree for the plugin type. Common locations are:<br />
<br />
* /path/to/moodle/theme/ - themes<br />
* /path/to/moodle/mod/ - activity modules and resources<br />
* /path/to/moodle/blocks/ - sidebar blocks<br />
* /path/to/moodle/question/type/ - question types<br />
* /path/to/moodle/course/format/ - course formats<br />
* /path/to/moodle/admin/report/ - admin reports<br />
<br />
See [[:dev:Plugin types]] for the full list of all plugin types and their locations within the Moodle tree.<br />
<br />
# Go to the [https://moodle.org/plugins Moodle plugins directory]; select your current [[Moodle version]], then choose a plugin with a Download button and download the ZIP file.<br />
# Upload or copy it to your Moodle server.<br />
# Unzip it in the right place for the plugin type (or follow the plugin instructions). <br />
# In your Moodle site (as admin) go to ''Site administration > Notifications'' (you should, for most plugin types, get a message saying the plugin is installed).<br />
<br />
Note: The plugin may contain language files. They'll be found by your Moodle automatically. These language strings can be customized using the standard ''Site administration > Language'' editing interface. If you get a "Database error" when you try to edit your language files, there is a strong chance that the language files included within the downloaded ZIP file of this plugin have a coding problem. If you delete the ''plugin_name/lang/other_language_different_to_English/'' folder with the new language strings and the database error disappears, this is indeed the case. Please notify the plugin maintainer, so that it can be fixed in future releases.<br />
<br />
==Troubleshooting==<br />
<br />
===Errors===<br />
<br />
If you obtain an error, please [[Debugging|turn debugging on]] to obtain additional information about the cause of the error.<br />
<br />
;Database error while doing a language customization : May not be related to the [[Language_customisation#Database_error|Language customization]], but rather a problem with a recently installed plugin.<br />
<br />
;tool_installaddon/err_curl_exec - cURL error 60 : This suggests problems with the validation of the SSL certificate of the remote (moodle.org) site. This is also a known problem in Moodle Windows 7 servers running the Moodle package for Windows. See [[SSL certificate for moodle.org]] for more info and possible solutions.<br />
<br />
===A file permissions error has occurred===<br />
<br />
On certain 3.0.x versions, when installing plugins via the administration interface, the Moodle uses the configuration settings <tt>$CFG->directorypermissions</tt> and <tt>$CFG->filepermissions</tt>. If these are not defined explicitly in your config.php, the default value is set automatically to 777 (rwxrwxrwx) for directories and 666 (rw-rw-rw-) for files (see lib/setup.php).<br />
<br />
If this default behaviour does not fit your needs and hosting environment, you may wish to specify more strict setting such as<br />
<br />
$CFG->directorypermissions = 02750;<br />
<br />
A common error after installing plugins is that when you create an instance of the module and then save and display it, it reports the error, "A file permissions error has occurred. Please check the permissions on the script and the directory it is in and try again." If you get this, the file permissions of the package are mostl likely set to 711 preventing them from running correctly. With your preferred FTP client or via your web hosts control panel, set the file permissions of all the files and directories in the installed module, e.g. /moodle/mod/[myplugin]/ to 755 and then see if you can successfully view the module instance.<br />
<br />
===Default exception handler: Error writing to database Debug: Duplicate entry 'en_us-...===<br />
* These errors are usually caused by a third party plugin. <br />
* To find the involved plugin, go to [http://lang.moodle.org http://lang.moodle.org] and use the AMOS tool to find all the strings with the given string identifier.<br />
* Remove the suspected plugin and check if the error has disappeared. If so, please contact the plugin maintainer and report this issue.<br />
* Please see [https://moodle.org/mod/forum/discuss.php?d=219504 this forum thread] for known causes and fixes.<br />
<br />
===When installing manually===<br />
<br />
* Check the file permissions. The web server needs to be able to read the plugin files. If the the rest of Moodle works then try to make the plugin permissions and ownership match. <br />
* Did you '''definitely''' unzip or install the plugin in the correct place?<br />
* Because Moodle scans plugin folders for new plugins you cannot have any other files or folders there. Make sure you deleted the zip file and don't try to rename (for example) an old version of the plugin to some other name - it will break.<br />
* Make sure the directory name for the plugin is correct. All the names '''have''' to match. If you change the name, then it won't work.<br />
<br />
===Obtaining help===<br />
<br />
Ask in a forum in [http://moodle.org/course/view.php?id=5 Moodle in English]. Make sure you describe your system (including versions of MySQL, PHP etc.), what you tried and what happened. Copy and paste error messages exactly. Provide the link to the version of the plugin you downloaded (some have very similar names).<br />
<br />
==Uninstalling a plugin==<br />
<br />
To uninstall a plugin<br />
# Go to ''Administration> Site Administration > Plugins > Plugins overview'' and click the Uninstall link opposite the plugin you wish to remove<br />
# Use a file manager to remove/delete the actual plugin directory as instructed, otherwise Moodle will reinstall it next time you access the site administration<br />
<br />
==Plugins overview==<br />
<br />
[[File:plugins overview.png|thumb|center|400px|Plugins overview highlighting available check button]]<br />
<br />
The Plugins overview page in ''Administration > Site Administration > Plugins > Plugins overview'' lists all installed plugins, together with the version number,release, availability (enabled or disabled) and settings link (if applicable).<br />
<br />
A 'Check for available updates' button enables admins to quickly check for any updates available for plugins installed on the site (from the [http://moodle.org/plugins plugins directory]). Any updates available are highlighted, with further information and a download link in the notes column opposite the plugin.<br />
<br />
===Plugin updating from within Moodle===<br />
<br />
An administrator can enable updates deployment in ''Administration > Site Administration > Server > Update notifications''. Then when updates are available, 'Install this update' buttons are shown on the Plugins overview page. See [[Automatic updates deployment]] for more details.<br />
<br />
==Preventing installing plugins from within Moodle==<br />
<br />
If required, installing and updating from within Moodle can be prevented by copying the following lines of code from config-dist.php and pasting them in config.php.<br />
<br />
<syntaxhighlight lang="php"><br />
// Use the following flag to completely disable the installation of plugins<br />
// (new plugins, available updates and missing dependencies) and related<br />
// features (such as cancelling the plugin installation or upgrade) via the<br />
// server administration web interface.<br />
$CFG->disableupdateautodeploy = true;<br />
</syntaxhighlight><br />
<br />
==See also==<br />
* [https://moodle.org/mod/forum/discuss.php?d=325804 list of (year 2015) favorite plugins] by Gavin Henrick<br />
* [[Notifications]] for further details of update notifications<br />
* [[Plugin Review Criteria]]<br />
* [[Plugins FAQ]]<br />
* Moodle in English [http://moodle.org/mod/forum/view.php?id=44 General plugins forum]<br />
* [[Installing Moodle from Git repository#Installing a contributed extension from its Git repository|Installing a contributed extension from its Git repository]]<br />
<br />
For developers:<br />
<br />
*[[:dev:Category:Plugins|Plugins developer documentation]]<br />
*[[:dev:Plugin validation]]<br />
*[[:dev:On-click add-on installation]]<br />
<br />
[[Category:Contributed code]]<br />
<br />
[[de:Plugins installieren]]<br />
[[es:Instalar complementos]]<br />
[[fr:Installation de plugins]]<br />
[[it:Installare plugin]]</div>Leonstrhttps://docs.moodle.org/310/en/index.php?title=Installing_Moodle&diff=140572Installing Moodle2021-07-30T11:24:54Z<p>Leonstr: /* Settings within Moodle */ Changed <code> to <syntaxhighlight></p>
<hr />
<div>{{Template:Installing Moodle}}<br />
''This page explains how to install Moodle. If you are an expert and/or in a hurry try [[Installation Quickstart]].''<br />
<br />
If you just want to try Moodle on a standalone machine there are 'one-click' installers for Windows (see [[Complete install packages for Windows]]) and for OSX (see [[Complete Install Packages for Mac OS X]]) or [[ install on OS X]]. These are unsuitable for production servers.<br />
<br />
If you want to avoid installing Moodle yourself completely, consider https://moodle.com/moodlecloud/<br />
<br />
== Requirements ==<br />
<br />
Moodle is primarily developed in Linux using [[Apache]], [[PostgreSQL]]/[[MySQL]]/[[MariaDB]] and [[PHP]] (sometimes known as the LAMP platform). Typically this is also how Moodle is run, although there are other options as long as the software requirements of the [{{Release notes}} release] are met.<br />
<br />
If you are installing Moodle in a Windows server, note that from php5.5 onwards, you will also need to have the Visual C++ Redistributable for Visual Studio 2012 installed from:<br />
http://www.microsoft.com/en-us/download/details.aspx?id=30679 Visual C++] ( x86 or x64) <br />
<br />
The basic requirements for Moodle are as follows:<br />
<br />
=== Hardware === <br />
* Disk space: 200MB for the Moodle code, plus as much as you need to store content. 5GB is probably a realistic minimum. <br />
* Processor: 1GHz (min), 2GHz dual core or more recommended.<br />
* Memory: 512MB (min), 1GB or more is recommended. 8GB plus is likely on a large production server<br />
* Consider separate servers for the web "front ends" and the database. It is much easier to "tune"<br />
<br />
All the above requirements will vary depending on specific hardware and software combinations as well as the type of use and load; busy sites may well require additional resources. Further guidance can be found under [[Performance_recommendations|performance recommendations]]. Moodle scales easily by increasing hardware.<br />
<br />
For very large sites, you are much better starting with a small pilot and gaining some experience and insight. A "what hardware do I need for 50,000 user?" style post in the forums is highly unlikely to get a useful answer.<br />
<br />
=== Software ===<br />
<br />
See the [{{Release notes}} release notes] in the dev docs for software requirements.<br />
<br />
== Set up your server ==<br />
<br />
Depending on the use case a Moodle server may be anything from a Desktop PC (e.g. for testing and evaluating) to a rackmounted or [[Server cluster|clustered]] solution to cloud VMs or other hosted solutions. As mentioned above there are lots of possibilities for installing the basic server software, for details see:<br />
<br />
* [[Installing AMP]]<br />
* [[Internet_Information_Services|IIS]]<br />
* [[Nginx]]<br />
* [[Apache]]<br />
<br />
It will help hugely, regardless of your deployment choices, if time is taken to understand how to configure the different parts of your software stack (HTTP daemon, database, PHP etc). Do not expect the standard server configuration to be optimal for Moodle. For example, the web server and database servers will almost certainly require tuning to get the best out of Moodle.<br />
<br />
If a hosting provider is being used ensure that all Moodle [{{Release notes}}#Server_requirements requirements] (such as PHP version) are met by the hosting platform before attempting the installation. It will help to become familiar with changing settings within the hosting provider's platform (e.g. PHP file upload maximums) as the options and tools provided vary.<br />
<br />
== Download and copy files into place ==<br />
<br />
'''IMPORTANT: While there are now a number of places you can get the Moodle code (including host provided Moodle installers), you are strongly advised to only obtain Moodle from moodle.org. If you run into problems it will be a great deal easier to support you.'''<br />
<br />
You have two options:<br />
* Download your required version from http://moodle.org/downloads and unzip/unpack...<br />
* '''OR''' Pull the code from the Git repository (recommended for developers and also makes upgrading very simple):<br />
<pre><br />
$ git clone -b MOODLE_{{Version3}}_STABLE git://git.moodle.org/moodle.git <br />
</pre><br />
<br />
For a fuller discussion see [[Git for Administrators]]. <br />
<br />
Either of the above should result in a directory called '''moodle''', containing a number of files and folders. <br />
<br />
You can typically place the whole folder in your web server documents directory, in which case the site will be located at '''<nowiki>http://yourwebserver.com/moodle</nowiki>''', or you can copy all the contents straight into the main web server documents directory, in which case the site will be simply '''<nowiki>http://yourwebserver.com</nowiki>'''. See the documentation for your system and/or web server if you are unsure. <br />
<br />
:''Tip:'' If you are downloading Moodle to your local computer and then uploading it to your hosted web site, it is usually better to upload the compressed Moodle file and then decompress on your hosted web site. If you decompress Moodle on your local computer, because Moodle is comprised of over 25,000 files, trying to upload over 25,000 files using an FTP client or your host's "file manager" can sometimes miss a file and cause errors. <br />
<br />
* '''Secure the Moodle files:''' It is vital that the files are not writeable by the web server user. For example, on Unix/Linux (as root):<br />
<pre><br />
chown -R root /path/to/moodle<br />
chmod -R 0755 /path/to/moodle<br />
</pre><br />
(files are owned by the administrator/superuser and are only writeable by them - readable by everyone else)<br />
<br />
On test/dev sites you ''may'' want to make the files writeable in order to use the built-in plugin installer. This is discouraged for live sites (at least, revert to more secure settings if you do).<br />
<br />
== Create an empty database ==<br />
<br />
Next create a new, empty database for your installation. You need to find and make a note of following information for use during the final installation stage:<br />
* '''dbhost''' - the database server hostname. Probably ''localhost'' if the database and web server are the same machine, otherwise the name of the database server<br />
* '''dbname''' - the database name. Whatever you called it, e.g. ''moodle'' <br />
* '''dbuser''' - the username for the database. Whatever you assigned, e.g. ''moodleuser'' - do not use the root/superuser account. Create a proper account with the minimum permissions needed.<br />
* '''dbpass''' - the password for the above user<br />
<br />
If your site is hosted you should find a web-based administration page for databases as part of the control panel (or ask your administrator). For everyone else or for detailed instructions, see the page for your chosen database server:<br />
* [[PostgreSQL]]<br />
* [[MariaDB]]<br />
* [[MySQL]]<br />
* [[MSSQL]]<br />
* [[Oracle]] (not recommended)<br />
<br />
== Create the (''moodledata'') data directory ==<br />
<br />
Moodle requires a directory to store all of its files (all your site's uploaded files, temporary data, cache, session data etc.). The web server needs to be able to write to this directory. On larger systems consider how much free space you are going to use when allocating this directory. <br />
<br />
Due to the default way Moodle caches data you may have serious performance issues if you use relatively slow storage (e.g. NFS) for this directory. Read the [[Performance_recommendations]] carefully and consider using (e.g.) redis or memcached for [[Caching]].<br />
<br />
'''IMPORTANT:''' This directory must '''NOT''' be accessible directly via the web. This would be a serious security hole. Do not try to place it inside your web root or inside your Moodle program files directory. Moodle will not install. It can go anywhere else convenient. <br />
<br />
Here is an example (Unix/Linux) of creating the directory and setting the permissions for '''anyone''' on the server to write here. This is only appropriate for Moodle servers that are not shared. Discuss this with your server administrator for better permissions that just allow the web server user to access these files.<br />
<br />
<pre><br />
# mkdir /path/to/moodledata<br />
# chmod 0777 /path/to/moodledata<br />
</pre><br />
<br />
==== Securing moodledata in a web directory ====<br />
<br />
If you are using a hosted site and you have no option but to place 'moodledata' in a web accessible directory. You may be able to secure it by creating an .htaccess file in the 'moodledata' directory. This does not work on all systems - see your host/administrator. Create a file called .htaccess containing only the following lines:<br />
<br />
'''Apache 2.2'''<br />
<pre><br />
order deny,allow<br />
deny from all<br />
</pre><br />
<br />
'''Apache 2.4'''<br />
<pre><br />
Require all denied<br />
</pre><br />
<br />
== Start Moodle install ==<br />
It's now time to run the installer to create the database tables and configure your new site. The recommended method is to use the command line installer. If you cannot do this for any reason (e.g. on a Windows server) the web-based installer is still available.<br />
<br />
=== Command line installer ===<br />
<br />
It's best to run the command line as your system's web user. You need to know what that is - see your system's documentation (e.g. Ubuntu/Debian is 'www-data', Centos is 'apache')<br />
<br />
* Example of using the command-line (as root - substitute 'www-data' for your web user):<br />
<pre><br />
# chown www-data /path/to/moodle<br />
# cd /path/to/moodle/admin/cli<br />
# sudo -u www-data /usr/bin/php install.php<br />
# chown -R root /path/to/moodle<br />
</pre><br />
The chowns allow the script to write a new config.php file. More information about the options can be found using <br />
<pre><br />
# php install.php --help<br />
</pre><br />
<br />
You will be asked for other settings that have not been discussed on this page - if unsure just accept the defaults. For a full discussion see [[Administration via command line]]<br />
<br />
=== Web based installer ===<br />
<br />
For ease of use you can install Moodle via the web. We recommend configuring your web server so that the page is not publicly accessible until the installation is complete.<br />
<br />
To run the web installer script, just go to your Moodle's main URL using a web browser.<br />
<br />
The installation process will take you through a number of pages. You should be asked to confirm the copyright, see the database tables being created, supply administrator account details and supply the site details. The database creation can take some time - please be patient. You should eventually end up at the Moodle front page with an invitation to create a new course. <br />
<br />
It is very likely that you will be asked to download the new config.php file and upload it to your Moodle installation - just follow the on-screen instructions.<br />
<br />
==Final configuration==<br />
<br />
=== Settings within Moodle ===<br />
There are a number of options within the Moodle Site Administration screens (accessible from the 'Site administration' tab in the 'Administration' block (Classic theme) or the Site administration button in the navigation bar (Boost). Here are a few of the more important ones that you will probably want to check:<br />
* ''Administration > Site administration > Server > Email > [[Mail_configuration#Outgoing_mail_configuration|Outgoing mail configuration]]'': Set your smtp server and authentication if required (so your Moodle site can send emails). You can also set a norepy email on this page.<br />
* ''Administration > Site administration > Server > Server > Support contact''. Set your support contact email. <br />
* ''Administration > Site administration > Server > System paths'': Set the paths to du, dot and aspell binaries.<br />
* ''Administration > Site administration > Server > HTTP'': If you are behind a firewall you may need to set your proxy credentials in the 'Web proxy' section.<br />
* ''Administration > Site administration > Location > Update timezones'': Run this to make sure your timezone information is up to date. (more info [[Location]])<br />
** [http://php.net/manual/en/timezones.php Set server's local timezone] inside <tt>php.ini</tt> (should probably be inside <tt>/etc/php.ini</tt> or <tt>/etc/php.d/date.ini</tt>, depending on the underlying OS):<br />
<syntaxhighlight lang="ini"><br />
[Date] <br />
; Defines the default timezone used by the date functions <br />
date.timezone = "YOUR LOCAL TIMEZONE"<br />
</syntaxhighlight><br />
<br />
=== Remaining tasks ===<br />
<br />
* '''Configure Cron''': Moodle's background tasks (e.g. sending out forum emails and performing course backups) are performed by a script which you can set to execute at specific times of the day. This is known as a cron script. Please refer to the [[Cron|Cron instructions]].<br />
* '''Set up backups''': See [[Site backup]] and [[Automated course backup]].<br />
* '''Secure your Moodle site''': Read the [[Security recommendations]].<br />
*'''Increasing the maximum upload size''' See [[Installation FAQ]] Maximum upload file size - how to change it?<br />
* '''Check mail works''' : From Site administration > Server > Test outgoing mail configuration, use the link to send yourself a test email. Don't be tempted to skip this step.<br />
<br />
=== Installation is complete :) ===<br />
<br />
* Create a new course: You can now access Moodle through your web browser (using the same URL as you set during the install process), log in as your admin user and creatse a new course. See [[Adding a new course|create a new course]].<br />
<br />
=== If something goes wrong... ===<br />
<br />
Here are some things you should try...<br />
<br />
* Check the [[Installation FAQ]]<br />
* Check your file permissions carefully. Can your web server read (but not write) the Moodle program files? Can your web server read and write your Moodle data directory? If you don't fully understand how file ownership and permissions work on your operating system it would be time very well spent to find out.<br />
* Check your database permissions. Have you set up your database user with the correct rights and permissions for your configuration (especially if the web server and database server are different machines)?<br />
* Create your [[Configuration file]] (config.php) by hand. Copy config-dist.php (in the root of the Moodle program directory) to config.php, edit it and set your database/site options there. Installation will continue from the right place. <br />
* Once you have a config.php (see previous tip) you can edit it to turn on debugging (in section 8). This may give you extra information to help track down a problem. If you have access, check your web server error log(s).<br />
* Re-check your php.ini / .htaccess settings. Are they appropriate (e.g. memory_limit), did you edit the correct php.ini / .htaccess file and (if required) did you re-start the web server after making changes?<br />
* Did you include any non-core (optional) plugins, themes or other code before starting the installation script? If so, remove it and try again (it may be broken or incompatible).<br />
* Explain your problem in the [http://moodle.org/mod/forum/view.php?id=28 Installation problems forum]. '''PLEASE''' list your software versions; explain what you did, what happened and what error messages you saw (if any); explain what you tried. There is no such thing as 'nothing', even a blank page is something!<br />
<br />
== Platform specific instructions ==<br />
<br />
'''Note:''' Much of this information is provided by the community. It may not have been checked and may be out of date. Please read in conjunction with the above installation instructions.<br />
<br />
* [[Windows installation]]<br />
** [[Installing Moodle on SmarterASP.NET]]<br />
* [[Unix or Linux Installation]]<br />
* [[Mac Installation]]<br />
* [[Amazon EC2 Cloud Services Installation]]<br />
<br />
== See also ==<br />
* [http://www.slideshare.net/gb2048/my-own-moodle Slideshare presentation by Gareth Barnard on installing a local installation of Moodle] and accompanying [https://drive.google.com/folderview?id=0B17B0rYH2zERU21sQnVweUZCUFk&usp=sharing help guides]<br />
* [http://moodle.org/mod/forum/discuss.php?d=182086 New Video Tutorial- How to Install Moodle on Shared Hosting via cPanel (Not Fantastico)]<br />
* [https://moodle.org/mod/forum/discuss.php?d=401983 Another one for cPanel using videos]<br />
* [http://moodle.org/mod/forum/discuss.php?d=199542 Video Tutorial - Install Moodle on a Virtual Box from scratch] <br />
<br />
[[es:Instalaci%C3%B3n_de_moodle]]<br />
[[de:Installation von Moodle]]<br />
[[fr:Installation de Moodle]]<br />
[[ja:Moodleのインストール]]</div>Leonstrhttps://docs.moodle.org/310/en/index.php?title=Administration_via_command_line&diff=140571Administration via command line2021-07-30T09:54:03Z<p>Leonstr: /* Running CLI scripts */ wwrun -> www-data, removed enrol_db sync script example as now deprecated</p>
<hr />
<div>{{Installing Moodle}}<br />
==Running CLI scripts==<br />
If you have shell access to your web server, you may find various CLI (command line interface) scripts useful during Moodle administration. Core admin CLI tools are located in the <code>admin/cli/*</code> folder. Other plugins may provide CLI functionality via scripts in their own <code>cli</code> folder.<br />
<br />
To avoid problems with access control, you should run them as the owner of the web server process. It is especially important for CLI installation and upgrade as they create new files in moodledata directory and the web server has to have write access to them. In Linux distributions, the user that runs the web server is usually apache or www-data or httpd or something similar. As a root, you will probably want to execute Moodle CLI scripts like this:<br />
<br />
$ cd /path/to/your/moodle/dir<br />
$ sudo -u apache /usr/bin/php admin/cli/somescript.php --params<br />
<br />
Most of the scripts accept common --help (or -h) parameter to display the full usage information, for example:<br />
<br />
$ sudo -u apache /usr/bin/php admin/cli/install.php --help<br />
<br />
{{Note|These scripts are supposed to be run under the identity of the web server user. Examples on this page use the <tt>apache</tt> user for illustration. The particular value depends on your OS distribution and local set-up. Typical values may be <tt>apache</tt>, <tt>www-data</tt> or <tt>httpd</tt>.}}<br />
<br />
== Upgrading ==<br />
<br />
Moodle can be upgraded from the command line. As with the installation script, there is either interactive or non-interactive mode of the upgrade. The script itself does not put the site into the maintenance mode, you have to do it on your own. Also, the script does not backup any data (if you read this page, you probably have some own scripts to backup your moodledata and the database, right?)<br />
<br />
$ sudo -u apache /usr/bin/php admin/cli/upgrade.php<br />
<br />
Upgrading via command line is a very comfortable way of Moodle upgrade if you use Git checkout of the Moodle source code (see [[Git for Administrators]]). See the following procedure how to upgrade your site within several seconds to the most recent version while preserving your eventual local customizations tracked in git repository:<br />
<br />
$ cd /var/www/sites/moodle/htdocs/<br />
$ sudo -u apache /usr/bin/php admin/cli/maintenance.php --enable<br />
$ git pull<br />
$ sudo -u apache /usr/bin/php admin/cli/upgrade.php<br />
$ sudo -u apache /usr/bin/php admin/cli/maintenance.php --disable<br />
<br />
== Installation ==<br />
<br />
There are two modes of installing Moodle from the command line. In interactive mode, the install script asks you for all data needed to properly set up new Moodle site. In non-interactive mode, you must provide all required data as the script parameters and then the new site is installed silently. The parameters can be passed in the interactive mode, too. The provided values are then used as the default values during the interactive session.<br />
<br />
$ sudo -u apache /usr/bin/php admin/cli/install.php --lang=cs<br />
<br />
If your arguments contain some specials characters for Linux based systems, don't forget to ''escape'' them with a backslash. For example, if you want to create an admin with ''pa$sword'' as password you should wrote ''pa\$sword'' instead!<br />
<br />
If required, the database install may be skipped, with just config.php populated.<br />
<br />
$ sudo -u apache /usr/bin/php admin/cli/install.php --skip-database<br />
<br />
== Maintenance mode ==<br />
<br />
To switch your site into the maintenance mode via CLI, you can use<br />
<br />
$ sudo -u apache /usr/bin/php admin/cli/maintenance.php --enable<br />
<br />
To turn maintenance mode off, execute the same script with the --disable parameter:<br />
<br />
$ sudo -u apache /usr/bin/php admin/cli/maintenance.php --disable<br />
<br />
If you don't want to enable maintenance mode immediately, but show a countdown to your users, execute the same script with the --enablelater parameter and the number of minutes which the countdown should run:<br />
<br />
$ sudo -u apache /usr/bin/php admin/cli/maintenance.php --enablelater=10<br />
<br />
This script will also create and remove the climaintenance.html file for "Offline" mode.<br />
<br />
== Offline mode ==<br />
<br />
In some situations, you may want to switch your Moodle site into offline mode so that it is not accessible via the web but you can not stop the web server completely (typically because there are other web pages and applications running there). If a file called <code>climaintenance.html</code> exists in the root folder of moodledata directory, Moodle will automatically display the contents of that file instead of any other page.<br />
<br />
$ cd /var/www/sites/moodle/moodledata/<br />
$ echo '&lt;h1&gt;Sorry, maintenance in progress&lt;/h1&gt;' &gt; climaintenance.html<br />
<br />
You can prepare a nice formatted HTML page to inform your users about the server being down and keep in the moodledata directory under a name like <code>climaintenance.off</code> and rename it to the <code>climaintenance.html</code> if needed.<br />
<br />
== Custom site defaults ==<br />
<br />
During the install and upgrade via CLI, Moodle sets the administration variables to the default values. You can use different defaults. See MDL-17850 for details. Shortly, all you need to do is to add a file <code>local/defaults.php</code> into your Moodle installation. The format of the file is like<br />
<br />
<syntaxhighlight lang="php"><br />
<?php<br />
$defaults['pluginname']['settingname'] = 'settingvalue'; // for plugins<br />
$defaults['moodle']['settingname'] = 'settingvalue'; // for core settings<br />
</syntaxhighlight><br />
<br />
These defaults are used during install, upgrade and are also displayed as defaults on Site administration pages.<br />
<br />
== Reset user password ==<br />
<br />
If you happen to forget your admin password (or you want to set a password for any other user on the site), you can use reset_password.php script. The script sets the correctly salted password for the given user.<br />
<br />
$ sudo -u apache /usr/bin/php admin/cli/reset_password.php<br />
<br />
==Converting InnoDB tables to Barracuda==<br />
<br />
Sites using MySQL with database tables using Antelope as the file format are recommended to convert the tables to the Barracuda file format.<br />
<br />
This is because tables using Antelope as the file format cannot handle more than 10 text columns. This file formats only supports ''compact'' and ''redundant'' row formats for backward compatibility reasons. This may cause a problem on larger sites when restoring a course, in which case the following error will be displayed: <br />
<br />
Row size too large (>8126). Changing some columns to TEXT or BLOB or using ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED may help.<br />
<br />
Barracuda is the newest innoDB file format. In addition to supporting ''compact'' and ''redundant'' row formats, Barracuda also supports ''compressed'' and ''dynamic'' row formats. <br />
<br />
However, converting tables to Barracuda is only recommended, and not required, since not all MySQL users are affected. (It may only be a problem for larger sites.)<br />
<br />
===Tool for converting tables===<br />
<br />
A command line tool is included in Moodle for converting tables to Barracuda.<br />
<br />
To view tables requiring conversion, use the list option:<br />
<br />
$ php admin/cli/mysql_compressed_rows.php --list<br />
<br />
Here is an example output:<br />
<br />
mdl_data Compact (needs fixing) <br />
mdl_data_fields Compact (needs fixing)<br />
mdl_enrol_paypal Compact (needs fixing)<br />
<br />
To proceed with the conversion, run the command using the fix option:<br />
<br />
$ php admin/cli/mysql_compressed_rows.php --fix<br />
<br />
Successful table conversion will be reported in the output, for example:<br />
<br />
mdl_data ... Compressed<br />
mdl_data_fields ... Compressed<br />
mdl_enrol_paypal ... Compressed<br />
<br />
Please note that the commands must be executed on your moodle directory. Once tables are fixed, the warning message will no longer be displayed.<br />
<br />
For further information on InnoDB file formats see the [http://dev.mysql.com/doc/innodb/1.1/en/glossary.html#glos_antelope MySQL InnoDB glossary - Antelope] and the [http://dev.mysql.com/doc/innodb/1.1/en/glossary.html#glos_barracuda MySQL InnoDB glossary - Barracuda].<br />
<br />
If you get errors due to having insufficient privileges to run these commands (this is quite likely) then the easiest solution is to generate the required SQL commands using,<br />
<br />
$ php admin/cli/mysql_compressed_rows.php --showsql<br />
<br />
You can then copy the generated SQL into your mysql client running as the 'root' user.<br />
<br />
==Converting to the new character set and collation==<br />
<br />
$ php admin/cli/mysql_collation.php --collation=utf8mb4_unicode_ci<br />
<br />
== Running cron via command line ==<br />
<br />
In versions 1.x, you could execute admin/cron.php either from command line or via the web. Since Moodle 2.0, only admin/cli/cron.php script can be run via command line.<br />
<br />
== Scheduled tasks ==<br />
<br />
Scheduled tasks are automatically run by the cron script, but the specific tasks which run on each cron iteration are determined by the scheduled tasks configuration. It is possible to override the scheduled tasks configuration and run a single scheduled task immediately using the admin/cli/scheduled_task.php script. <br />
<br />
This script accepts the following arguments:<br />
<br />
--list - list all the known scheduled tasks. The tasks are listed by the class name used to run the task. This class name is required as the argument to the next option in order to run a specific task immediately.<br />
<br />
--execute=<task> - Runs a single scheduled task immediately - regardless of scheduling settings. This will even run disabled tasks. Tasks will still use locking to prevent concurrent execution of the same task - even on clusters. The format of the <task> argument must be the same as returned by the --list option above.<br />
<br />
--showsql - Shows sql queries before they are execute<br />
<br />
--showdebugging - Shows developer debugging info<br />
<br />
'''Note:''' You must escape the "\" with an extra \ when using the --execute command. Take the following for example:<br />
<br />
<pre>php admin/cli/scheduled_task.php --list</pre><br />
<br />
will return something like:<br />
<br />
<pre><br />
== List of scheduled tasks (http://yourserver.com/moodle) ==<br />
\enrol_imsenterprise\task\cron_task 10 * * * * * ASAP<br />
\logstore_legacy\task\cleanup_task * 5 * * * * ASAP<br />
\logstore_standard\task\cleanup_task * 4 * * * * Wednesday, November 12, 2014, 4:35 AM<br />
\mod_forum\task\cron_task * * * * * * ASAP<br />
\core\task\automated_backup_task 50 * * * * * ASAP<br />
<br />
...<br />
</pre><br />
<br />
To run the first task in that list, you would execute<br />
<br />
php admin/cli/scheduled_task.php --execute='\enrol_imsenterprise\task\cron_task'<br />
<br />
Be aware of the single quotes. Without them, you would need to use double backlashes to avoid escaping by the shell.<br />
<br />
==Database transfer==<br />
<br />
A command line script for [[Database transfer]] may be found in ''admin/tool/dbtransfer/cli/migrate.php''.<br />
<br />
==Purge caches==<br />
<br />
You can purge caches using this script:<br />
<br />
php admin/cli/purge_caches.php<br />
<br />
==Kill all sessions==<br />
If needed for administrative reasons, you can kill all user sessions using this script:<br />
<br />
php admin/cli/kill_all_sessions.php<br />
<br />
As a result, all users will be logged out from Moodle.<br />
<br />
==Backup and restore of large courses==<br />
<br />
See Backup via CLI in [[Course backup]] and Restore via CLI in [[Course restore]] (new in 3.10 onwards).<br />
<br />
==Fix course / module sequences==<br />
<br />
In rare cases (such as after upgrading from a very old version of Moodle), the course / section / module sequence data can be out of sync. This can cause various problems for affected courses, such as sections not appearing, backups failing, pages not displaying etc. There is a specific check to check for errors caused by this problem, and to fix the data in the database if they are found. To run this script please use the command below:<br />
<br />
php admin/cli/fix_course_sequence.php -c=* --fix<br />
<br />
This will check every course in Moodle and report which ones had errors and were fixed.<br />
<br />
==Fix orphaned question categories==<br />
<br />
When a quiz is created, a new question category for the quiz is automatically created. In versions of Moodle prior to 2.9.1, if the quiz is deleted, the question category and any questions in the category remain in database. These orphaned question categories may be fixed by running the admin/cli/fix_orphaned_question_categories.php script with the --fix option.<br />
<br />
==Search and replace text==<br />
<br />
This script can be used to search and replace text throughout the whole database. Use carefully and backup first always. More info in [[Search and replace tool]].<br />
<br />
php admin/tool/replace/cli/replace.php --search=//oldsitehost --replace=//newsitehost<br />
<br />
==Build theme CSS cache==<br />
<br />
If Moodle is not running in theme designer mode it will keep a copy of the compiled CSS on local disk and serve that to the browser when it requests a page. If there isn't a copy on local disk then a copy will be built the first time a page within Moodle is requested. <br />
<br />
With this script you can pre-compile the cached CSS files for themes within Moodle to avoid having a user wait for the theme to compile during the first page request.<br />
<br />
php admin/cli/build_theme_css.php --themes=boost<br />
<br />
==Get and set configuration values==<br />
<br />
Displays the current value of the given setting, or set the given setting to the specified value.<br />
<br />
$ php admin/cli/cfg.php [--component=<componentname>] [--json] [--shell-arg]<br />
$ php admin/cli/cfg.php --name=<configname> [--component=<componentname>] [--shell-arg] [--no-eol]<br />
$ php admin/cli/cfg.php --name=<configname> [--component=<componentname>] --set=<value><br />
$ php admin/cli/cfg.php --name=<configname> [--component=<componentname>] --unset<br />
$ php admin/cli/cfg.php [--help|-h]<br />
<br />
Examples:<br />
$ php admin/cli/cfg.php --name=langmenu<br />
will display the value of ''Display language menu'' in ''Site administration > Language > Language settings'' (0 for ''No'' or 1 for ''Yes'').<br />
$ php cfg.php --name=maxsizetodownload --component=folder<br />
will display the value of ''Maximum folder download size (MB)'' accessible from ''Site administration > Plugins > Activity modules > Folder''.<br />
$ php admin/cli/cfg.php --name=langmenu --set=0<br />
will disable the ''Language menu''.<br />
<br />
==See also==<br />
<br />
* MDL-35736 - Manage plugins via command line<br />
* MDL-36237 - Resort course list via CLI<br />
* [http://moosh-online.com/ MOOSH] - MOOdle SHell. It is a commandline tool that will allow you to perform most common Moodle tasks.<br />
<br />
[[fr:Administration en ligne de commande]]<br />
[[de:Administration über Kommandozeile]]<br />
[[es:Administración por línea de comando]]<br />
[[it:Amministrazione via linea di comando]]<br />
[[ja:コマンドライン経由の管理]]</div>Leonstrhttps://docs.moodle.org/310/en/index.php?title=Administration_via_command_line&diff=140569Administration via command line2021-07-28T14:23:06Z<p>Leonstr: /* Custom site defaults */ Replaced <code> with <syntaxhighlight></p>
<hr />
<div>{{Installing Moodle}}<br />
==Running CLI scripts==<br />
If you have shell access to your web server, you may find various CLI (command line interface) scripts useful during Moodle administration. Core admin CLI tools are located in the <code>admin/cli/*</code> folder. Other plugins provide their CLI functionality via scripts in their own cli folder. For example, the enrol_db sync script is located in <code>enrol/db/cli/</code>.<br />
<br />
To avoid problems with access control, you should run them as the owner of the web server process. It is especially important for CLI installation and upgrade as they create new files in moodledata directory and the web server has to have write access to them. In Linux distributions, the user that runs the web server is usually apache or wwrun or httpd or something similar. As a root, you will probably want to execute Moodle CLI scripts like this:<br />
<br />
$ cd /path/to/your/moodle/dir<br />
$ sudo -u apache /usr/bin/php admin/cli/somescript.php --params<br />
<br />
Most of the scripts accept common --help (or -h) parameter to display the full usage information, for example:<br />
<br />
$ sudo -u apache /usr/bin/php admin/cli/install.php --help<br />
<br />
{{Note|These scripts are supposed to be run under the identity of the web server user. Examples on this page use the <tt>apache</tt> user for illustration. The particular value depends on your OS distribution and local set-up. Typical values may be <tt>apache</tt>, <tt>www-data</tt> or <tt>httpd</tt>.}}<br />
<br />
== Upgrading ==<br />
<br />
Moodle can be upgraded from the command line. As with the installation script, there is either interactive or non-interactive mode of the upgrade. The script itself does not put the site into the maintenance mode, you have to do it on your own. Also, the script does not backup any data (if you read this page, you probably have some own scripts to backup your moodledata and the database, right?)<br />
<br />
$ sudo -u apache /usr/bin/php admin/cli/upgrade.php<br />
<br />
Upgrading via command line is a very comfortable way of Moodle upgrade if you use Git checkout of the Moodle source code (see [[Git for Administrators]]). See the following procedure how to upgrade your site within several seconds to the most recent version while preserving your eventual local customizations tracked in git repository:<br />
<br />
$ cd /var/www/sites/moodle/htdocs/<br />
$ sudo -u apache /usr/bin/php admin/cli/maintenance.php --enable<br />
$ git pull<br />
$ sudo -u apache /usr/bin/php admin/cli/upgrade.php<br />
$ sudo -u apache /usr/bin/php admin/cli/maintenance.php --disable<br />
<br />
== Installation ==<br />
<br />
There are two modes of installing Moodle from the command line. In interactive mode, the install script asks you for all data needed to properly set up new Moodle site. In non-interactive mode, you must provide all required data as the script parameters and then the new site is installed silently. The parameters can be passed in the interactive mode, too. The provided values are then used as the default values during the interactive session.<br />
<br />
$ sudo -u apache /usr/bin/php admin/cli/install.php --lang=cs<br />
<br />
If your arguments contain some specials characters for Linux based systems, don't forget to ''escape'' them with a backslash. For example, if you want to create an admin with ''pa$sword'' as password you should wrote ''pa\$sword'' instead!<br />
<br />
If required, the database install may be skipped, with just config.php populated.<br />
<br />
$ sudo -u apache /usr/bin/php admin/cli/install.php --skip-database<br />
<br />
== Maintenance mode ==<br />
<br />
To switch your site into the maintenance mode via CLI, you can use<br />
<br />
$ sudo -u apache /usr/bin/php admin/cli/maintenance.php --enable<br />
<br />
To turn maintenance mode off, execute the same script with the --disable parameter:<br />
<br />
$ sudo -u apache /usr/bin/php admin/cli/maintenance.php --disable<br />
<br />
If you don't want to enable maintenance mode immediately, but show a countdown to your users, execute the same script with the --enablelater parameter and the number of minutes which the countdown should run:<br />
<br />
$ sudo -u apache /usr/bin/php admin/cli/maintenance.php --enablelater=10<br />
<br />
This script will also create and remove the climaintenance.html file for "Offline" mode.<br />
<br />
== Offline mode ==<br />
<br />
In some situations, you may want to switch your Moodle site into offline mode so that it is not accessible via the web but you can not stop the web server completely (typically because there are other web pages and applications running there). If a file called <code>climaintenance.html</code> exists in the root folder of moodledata directory, Moodle will automatically display the contents of that file instead of any other page.<br />
<br />
$ cd /var/www/sites/moodle/moodledata/<br />
$ echo '&lt;h1&gt;Sorry, maintenance in progress&lt;/h1&gt;' &gt; climaintenance.html<br />
<br />
You can prepare a nice formatted HTML page to inform your users about the server being down and keep in the moodledata directory under a name like <code>climaintenance.off</code> and rename it to the <code>climaintenance.html</code> if needed.<br />
<br />
== Custom site defaults ==<br />
<br />
During the install and upgrade via CLI, Moodle sets the administration variables to the default values. You can use different defaults. See MDL-17850 for details. Shortly, all you need to do is to add a file <code>local/defaults.php</code> into your Moodle installation. The format of the file is like<br />
<br />
<syntaxhighlight lang="php"><br />
<?php<br />
$defaults['pluginname']['settingname'] = 'settingvalue'; // for plugins<br />
$defaults['moodle']['settingname'] = 'settingvalue'; // for core settings<br />
</syntaxhighlight><br />
<br />
These defaults are used during install, upgrade and are also displayed as defaults on Site administration pages.<br />
<br />
== Reset user password ==<br />
<br />
If you happen to forget your admin password (or you want to set a password for any other user on the site), you can use reset_password.php script. The script sets the correctly salted password for the given user.<br />
<br />
$ sudo -u apache /usr/bin/php admin/cli/reset_password.php<br />
<br />
==Converting InnoDB tables to Barracuda==<br />
<br />
Sites using MySQL with database tables using Antelope as the file format are recommended to convert the tables to the Barracuda file format.<br />
<br />
This is because tables using Antelope as the file format cannot handle more than 10 text columns. This file formats only supports ''compact'' and ''redundant'' row formats for backward compatibility reasons. This may cause a problem on larger sites when restoring a course, in which case the following error will be displayed: <br />
<br />
Row size too large (>8126). Changing some columns to TEXT or BLOB or using ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED may help.<br />
<br />
Barracuda is the newest innoDB file format. In addition to supporting ''compact'' and ''redundant'' row formats, Barracuda also supports ''compressed'' and ''dynamic'' row formats. <br />
<br />
However, converting tables to Barracuda is only recommended, and not required, since not all MySQL users are affected. (It may only be a problem for larger sites.)<br />
<br />
===Tool for converting tables===<br />
<br />
A command line tool is included in Moodle for converting tables to Barracuda.<br />
<br />
To view tables requiring conversion, use the list option:<br />
<br />
$ php admin/cli/mysql_compressed_rows.php --list<br />
<br />
Here is an example output:<br />
<br />
mdl_data Compact (needs fixing) <br />
mdl_data_fields Compact (needs fixing)<br />
mdl_enrol_paypal Compact (needs fixing)<br />
<br />
To proceed with the conversion, run the command using the fix option:<br />
<br />
$ php admin/cli/mysql_compressed_rows.php --fix<br />
<br />
Successful table conversion will be reported in the output, for example:<br />
<br />
mdl_data ... Compressed<br />
mdl_data_fields ... Compressed<br />
mdl_enrol_paypal ... Compressed<br />
<br />
Please note that the commands must be executed on your moodle directory. Once tables are fixed, the warning message will no longer be displayed.<br />
<br />
For further information on InnoDB file formats see the [http://dev.mysql.com/doc/innodb/1.1/en/glossary.html#glos_antelope MySQL InnoDB glossary - Antelope] and the [http://dev.mysql.com/doc/innodb/1.1/en/glossary.html#glos_barracuda MySQL InnoDB glossary - Barracuda].<br />
<br />
If you get errors due to having insufficient privileges to run these commands (this is quite likely) then the easiest solution is to generate the required SQL commands using,<br />
<br />
$ php admin/cli/mysql_compressed_rows.php --showsql<br />
<br />
You can then copy the generated SQL into your mysql client running as the 'root' user.<br />
<br />
==Converting to the new character set and collation==<br />
<br />
$ php admin/cli/mysql_collation.php --collation=utf8mb4_unicode_ci<br />
<br />
== Running cron via command line ==<br />
<br />
In versions 1.x, you could execute admin/cron.php either from command line or via the web. Since Moodle 2.0, only admin/cli/cron.php script can be run via command line.<br />
<br />
== Scheduled tasks ==<br />
<br />
Scheduled tasks are automatically run by the cron script, but the specific tasks which run on each cron iteration are determined by the scheduled tasks configuration. It is possible to override the scheduled tasks configuration and run a single scheduled task immediately using the admin/cli/scheduled_task.php script. <br />
<br />
This script accepts the following arguments:<br />
<br />
--list - list all the known scheduled tasks. The tasks are listed by the class name used to run the task. This class name is required as the argument to the next option in order to run a specific task immediately.<br />
<br />
--execute=<task> - Runs a single scheduled task immediately - regardless of scheduling settings. This will even run disabled tasks. Tasks will still use locking to prevent concurrent execution of the same task - even on clusters. The format of the <task> argument must be the same as returned by the --list option above.<br />
<br />
--showsql - Shows sql queries before they are execute<br />
<br />
--showdebugging - Shows developer debugging info<br />
<br />
'''Note:''' You must escape the "\" with an extra \ when using the --execute command. Take the following for example:<br />
<br />
<pre>php admin/cli/scheduled_task.php --list</pre><br />
<br />
will return something like:<br />
<br />
<pre><br />
== List of scheduled tasks (http://yourserver.com/moodle) ==<br />
\enrol_imsenterprise\task\cron_task 10 * * * * * ASAP<br />
\logstore_legacy\task\cleanup_task * 5 * * * * ASAP<br />
\logstore_standard\task\cleanup_task * 4 * * * * Wednesday, November 12, 2014, 4:35 AM<br />
\mod_forum\task\cron_task * * * * * * ASAP<br />
\core\task\automated_backup_task 50 * * * * * ASAP<br />
<br />
...<br />
</pre><br />
<br />
To run the first task in that list, you would execute<br />
<br />
php admin/cli/scheduled_task.php --execute='\enrol_imsenterprise\task\cron_task'<br />
<br />
Be aware of the single quotes. Without them, you would need to use double backlashes to avoid escaping by the shell.<br />
<br />
==Database transfer==<br />
<br />
A command line script for [[Database transfer]] may be found in ''admin/tool/dbtransfer/cli/migrate.php''.<br />
<br />
==Purge caches==<br />
<br />
You can purge caches using this script:<br />
<br />
php admin/cli/purge_caches.php<br />
<br />
==Kill all sessions==<br />
If needed for administrative reasons, you can kill all user sessions using this script:<br />
<br />
php admin/cli/kill_all_sessions.php<br />
<br />
As a result, all users will be logged out from Moodle.<br />
<br />
==Backup and restore of large courses==<br />
<br />
See Backup via CLI in [[Course backup]] and Restore via CLI in [[Course restore]] (new in 3.10 onwards).<br />
<br />
==Fix course / module sequences==<br />
<br />
In rare cases (such as after upgrading from a very old version of Moodle), the course / section / module sequence data can be out of sync. This can cause various problems for affected courses, such as sections not appearing, backups failing, pages not displaying etc. There is a specific check to check for errors caused by this problem, and to fix the data in the database if they are found. To run this script please use the command below:<br />
<br />
php admin/cli/fix_course_sequence.php -c=* --fix<br />
<br />
This will check every course in Moodle and report which ones had errors and were fixed.<br />
<br />
==Fix orphaned question categories==<br />
<br />
When a quiz is created, a new question category for the quiz is automatically created. In versions of Moodle prior to 2.9.1, if the quiz is deleted, the question category and any questions in the category remain in database. These orphaned question categories may be fixed by running the admin/cli/fix_orphaned_question_categories.php script with the --fix option.<br />
<br />
==Search and replace text==<br />
<br />
This script can be used to search and replace text throughout the whole database. Use carefully and backup first always. More info in [[Search and replace tool]].<br />
<br />
php admin/tool/replace/cli/replace.php --search=//oldsitehost --replace=//newsitehost<br />
<br />
==Build theme CSS cache==<br />
<br />
If Moodle is not running in theme designer mode it will keep a copy of the compiled CSS on local disk and serve that to the browser when it requests a page. If there isn't a copy on local disk then a copy will be built the first time a page within Moodle is requested. <br />
<br />
With this script you can pre-compile the cached CSS files for themes within Moodle to avoid having a user wait for the theme to compile during the first page request.<br />
<br />
php admin/cli/build_theme_css.php --themes=boost<br />
<br />
==Get and set configuration values==<br />
<br />
Displays the current value of the given setting, or set the given setting to the specified value.<br />
<br />
$ php admin/cli/cfg.php [--component=<componentname>] [--json] [--shell-arg]<br />
$ php admin/cli/cfg.php --name=<configname> [--component=<componentname>] [--shell-arg] [--no-eol]<br />
$ php admin/cli/cfg.php --name=<configname> [--component=<componentname>] --set=<value><br />
$ php admin/cli/cfg.php --name=<configname> [--component=<componentname>] --unset<br />
$ php admin/cli/cfg.php [--help|-h]<br />
<br />
Examples:<br />
$ php admin/cli/cfg.php --name=langmenu<br />
will display the value of ''Display language menu'' in ''Site administration > Language > Language settings'' (0 for ''No'' or 1 for ''Yes'').<br />
$ php cfg.php --name=maxsizetodownload --component=folder<br />
will display the value of ''Maximum folder download size (MB)'' accessible from ''Site administration > Plugins > Activity modules > Folder''.<br />
$ php admin/cli/cfg.php --name=langmenu --set=0<br />
will disable the ''Language menu''.<br />
<br />
==See also==<br />
<br />
* MDL-35736 - Manage plugins via command line<br />
* MDL-36237 - Resort course list via CLI<br />
* [http://moosh-online.com/ MOOSH] - MOOdle SHell. It is a commandline tool that will allow you to perform most common Moodle tasks.<br />
<br />
[[fr:Administration en ligne de commande]]<br />
[[de:Administration über Kommandozeile]]<br />
[[es:Administración por línea de comando]]<br />
[[it:Amministrazione via linea di comando]]<br />
[[ja:コマンドライン経由の管理]]</div>Leonstrhttps://docs.moodle.org/310/en/index.php?title=Debugging&diff=140568Debugging2021-07-27T12:32:40Z<p>Leonstr: Changed <code> to <syntaxhighlight></p>
<hr />
<div>{{Developer tools}}<br />
==Using debugging messages==<br />
<br />
Debugging messages are intended to help diagnose problems and/or help Moodle developers. If you have a problem with your Moodle site and ask for help in a Moodle.org forum, a developer may ask you to turn enable debugging i.e. turn debugging messages on, in order to locate the cause of the problem. If you are having problems such as a blank screen or incomplete screens, then turning on debugging is usually the first thing to try. <br />
<br />
==Enabling debugging==<br />
<br />
To enable debugging, go to ''Site administration > Development > Debugging'' .<br />
<br />
===Debug messages===<br />
<br />
The options are:<br />
<br />
* NONE: Do not show any errors or warnings (Default) <br />
* MINIMAL: Show only fatal errors<br />
* NORMAL: Show warnings, errors and notices<br />
* ALL: Show all reasonable PHP debug messages<br />
* DEVELOPER: extra Moodle debug messages for developers<br />
<br />
Notes:<br />
<br />
# It is recommended that a record of error messages is kept, and for the admin to regularly monitor the error logs. This may be done by setting 'Debug messages' (debug) to Normal and leaving 'Display debug messages' (debugdisplay) off (unticked). Error messages are then recorded in the server logs.<br />
# If 'Debug messages' is set to Developer on a production (public) site, it is recommended to copy and paste the debugging message obtained and then turn off Developer debugging. This is because debugging messages can give clues to a hacker as to the set-up of your site.<br />
<br />
===Display debug messages===<br />
<br />
If you select this checkbox, the debug messages are displayed directly in the browser, otherwise they are stored in the server logs.<br />
<br />
===Debug email sending===<br />
<br />
Determines whether or not to enable verbose debug information during sending of email messages to SMTP server.<br />
<br />
==== More tools for debugging outgoing mail (SMTP) ====<br />
You can also use the config.php file to turn on more "tools" which will assist you with debugging the outgoing emails (and SMTP server configuration):<br />
* Redirect all outgoing emails to a specific address:<br />
<syntaxhighlight lang="php"><br />
// Divert all outgoing emails to this address to test and debug emailing features<br />
// $CFG->divertallemailsto = 'root@localhost.local'; // NOT FOR PRODUCTION SERVERS!<br />
</syntaxhighlight><br />
<br />
* Turn on the CRON debugging and run CLI cron.php script.<br />
<syntaxhighlight lang="php"><br />
// Force developer level debug and add debug info to the output of cron<br />
// $CFG->showcrondebugging = true;<br />
</syntaxhighlight><br />
And then use SSH (or putty.exe, on windows) to run:<br />
<syntaxhighlight lang="php"><br />
you@moodle-server(/var/www/html/moodle)# php admin/cli/cron.php<br />
</syntaxhighlight><br />
<br />
* Turn on verbose SMTP debugging and output it into system's error_log (code hack):<br />
As [https://moodle.org/mod/forum/discuss.php?d=316222#p1289850 suggested] on Moodle's discussion forums:<br />
Open [https://github.com/moodle/moodle/blob/master/lib/moodlelib.php#L5379 lib/moodlelib.php L5379] and change it to:<br />
<syntaxhighlight lang="php"><br />
if (!empty($CFG->debugsmtp)) {<br />
$mailer->SMTPDebug = 1; // 0 - no debug ... 4 - low level full debug<br />
$mailer->Debugoutput = "error_log";<br />
}<br />
</syntaxhighlight><br />
See more info about [https://github.com/moodle/moodle/blob/master/lib/phpmailer/class.phpmailer.php#L314 SMTPDebug] parameters & [https://github.com/moodle/moodle/blob/master/lib/phpmailer/class.phpmailer.php#L328 Debugoutput] parameters,<br />
Set-up mailcatcher (https://mailcatcher.me/).<br />
<br />
===Performance info===<br />
<br />
The Performance info option determines whether performance info will be included in the footer of the standard theme (and some other themes). Performance info includes the time for the page to load, the amount of memory used to generate the page, cpu usage, load, and the record cache hit/miss ration.<br />
<br />
If you add<br />
<syntaxhighlight lang="php"><br />
define('MDL_PERF', true);<br />
define('MDL_PERFDB', true);<br />
define('MDL_PERFTOLOG', true);<br />
define('MDL_PERFTOFOOT', true);<br />
</syntaxhighlight><br />
to your config.php file, then it will also count database queries. (This has to be in config.php, because Moodle starts doing DB queries before it loads the config information in the database!)<br />
<br />
To hide performance info from ordinary users, see the discussion [https://moodle.org/mod/forum/discuss.php?d=358032 Performance info only for admins?]<br />
<br />
===Show origin of languages strings===<br />
<br />
Helps with [[:dev:Translation|translation]] and also with [[Language customization]]. Sometimes <code>?strings=1</code> should be added; other times <code>&strings=1</code>. See the Wikipedia article [http://en.wikipedia.org/wiki/Query_string Query string] for details.<br />
<br />
===Show validator links===<br />
Be careful, read the warning.<br />
<br />
===Show page information===<br />
To show page information printed in the page footer.<br />
<br />
===Debug SQL queries===<br />
You can add (turn ON) any of the following dboptions in your config.php files, which log different types of SQL queries into mdl_log_queries table:<br />
* '''logall''' - log all queries - suitable only for developers, causes high server loads and NOT recommended for production.<br />
* '''logslow''' - log queries that take longer than specified number of seconds (float values are accepted).<br />
* '''logerrors''' - log all error queries.<br />
<br />
Full sample:<br />
<syntaxhighlight lang="php"><br />
$CFG->dboptions = array (<br />
//'logall' => true,<br />
'logslow' => 5,<br />
'logerrors' => true,<br />
);<br />
</syntaxhighlight><br />
<br />
==What to do if you cannot get to the admin screens==<br />
<br />
If the error is stopping you even getting to the admin screens to turn on debugging, then you can set the debugging setting manually.<br />
<br />
===Try typing the URL directly===<br />
<br />
The debug settings are at the URL <code><nowiki>http://.../admin/settings.php?section=debugging</nowiki></code> on your server. Sometimes that URL will work, even though the pages you need to go to get there (for example the site front page) do not. So it is worth trying to enter that URL directly.<br />
<br />
===In config.php===<br />
<br />
In [[Configuration file|config.php]] you can uncomment lines (delete the // at the start of the line) under Section 7 to enable debugging for all or just specific users:<br />
<br />
<syntaxhighlight lang="php"><br />
//=========================================================================<br />
// 7. SETTINGS FOR DEVELOPMENT SERVERS - not intended for production use!!!<br />
//=========================================================================<br />
//<br />
// Force a debugging mode regardless the settings in the site administration<br />
// @error_reporting(E_ALL | E_STRICT); // NOT FOR PRODUCTION SERVERS!<br />
// @ini_set('display_errors', '1'); // NOT FOR PRODUCTION SERVERS!<br />
// $CFG->debug = (E_ALL | E_STRICT); // === DEBUG_DEVELOPER - NOT FOR PRODUCTION SERVERS!<br />
// $CFG->debugdisplay = 1; // NOT FOR PRODUCTION SERVERS!<br />
//<br />
// You can specify a comma separated list of user ids that that always see<br />
// debug messages, this overrides the debug flag in $CFG->debug and $CFG->debugdisplay<br />
// for these users only.<br />
// $CFG->debugusers = '2';<br />
</syntaxhighlight><br />
<br />
Remember to comment those lines again (reinsert the // at the start of the line) when you have finished diagnosing your problem.<br />
<br />
'''NOTE 1''': do not try to modify the config database table directly, it will not work because the values are cached in MUC.<br />
<br />
'''NOTE 2''': if you find your config.php does not have the above settings (you have a cut down approx 30 lines config.php) look for a "config-dist.php" file that contains the full details. I would suggest transferring your details in the current config.php file you have into the full config file and renaming that one to "config.php".<br />
<br />
==See also==<br />
<br />
* Developers can also use [http://xdebug.org/ XDEBUG] (Installed as a module on the Apache server) to further dig into the code, step by step using an [http://xdebug.org/docs/remote XDEBUG client application]. Probably, as part of their favorite IDE. For example: [http://php.netbeans.org/ NetBeans], [http://www.jetbrains.com/phpstorm/ phpStorm] or...<br />
<br />
[[es:Depuración]]<br />
[[fr:Débogage]]<br />
[[de:Debugging]]</div>Leonstrhttps://docs.moodle.org/310/en/index.php?title=Configuration_file&diff=140567Configuration file2021-07-26T10:24:55Z<p>Leonstr: /* Forcing the value of admin settings */ Changed <code> to <syntaxhighlight></p>
<hr />
<div>{{Installing Moodle}}<br />
The name for Moodle's configuration file is config.php. The file is located in the moodle directory. It is not included in the Moodle download packages and is created by the installation process from the template file config-dist.php (which is included in Moodle packages).<br />
<br />
<br />
==config-dist.php==<br />
Although the installation process creates the config.php file for you, there may be times when you want to do this yourself. A sample config file, called config-dist.php, is shipped with Moodle.<br />
<br />
To get started simply copy config-dist.php to config.php, then edit config.php with you favourite editor. The file is very well commented. The important options (which you must supply) are all nearer the top. Other less common options are further down.<br />
<br />
==Setting $CFG->wwwroot correctly==<br />
This setting must be a fixed URL (a string constant) that points to your site. Do not try to set this with any PHP code that can generate a variable URL. This is not supported, can cause strange problems and will stop command line scripts working completely. If your site is accessed from different IP addresses this should be done with a split DNS, see [[Masquerading]]<br />
<br />
If you change your site from http to https, you '''MUST''' update this setting. If you don’t, you will have problems - for example (but not limited to) css scripts won’t load properly and you will also experience problems with logging in to your site. Also see [[Transitioning_to_HTTPS]]<br />
<br />
==Enabling password salting==<br />
<br />
See [[Password salting]].<br />
<br />
==Including passwords in backups==<br />
<br />
Hashed user passwords are no longer saved in backup files containing user data.<br />
<br />
If you really need passwords to be saved (in the rare case of restoring a [[Backup of user data|backup with user data]] to a different site), the following line may be added to config.php:<br />
<br />
$CFG->includeuserpasswordsinbackup = true;<br />
<br />
Note regarding restoring Moodle 2.5 backups to sites with old PHP versions:<br />
<br />
Because bcrypt is not supported in PHP versions below 5.3.7, course backups made using the $CFG->includeuserpasswordsinbackup setting on a site using PHP version 5.3.7+ that are subsequently restored to a site with PHP version < 5.3.7 will require a password reset.<br />
<br />
==Changing default block layout for new courses==<br />
<br />
See [[Block layout]].<br />
<br />
==Adding extra theme directory location==<br />
It is possible to add an extra themes directory stored outside of $CFG->dirroot. This local directory does not have to be accessible from internet. Themes placed in the directory specified by these variables will then be available for selection using the theme selector.<br />
<br />
For example, should you wish to place extra themes in a subdirectory called 'my_moodle_themes', your config.php might look like this:<br />
<pre><br />
$CFG->wwwroot = 'http://my.moodle.site.edu';<br />
$CFG->dirroot = '/var/www/my.moodle.site.edu/public_html';<br />
$CFG->themedir = $CFG->dirroot . '/my_moodle_themes';<br />
</pre><br />
<br />
==Disabling update notifications==<br />
<br />
See [[Notifications]].<br />
<br />
==Enabling debugging==<br />
<br />
See [[Debugging]].<br />
<br />
==Forcing the value of admin settings==<br />
<br />
As explained in config-dist.php, it is possible to specify normal admin settings here, the point is that they can not be changed through the standard admin settings pages any more. Just set the value in config.php like:<br />
<br />
<syntaxhighlight lang="php"><br />
$CFG->showuseridentity = 'email,idnumber,username';<br />
$CFG->preventexecpath = true;<br />
$CFG->pathtodu = "/usr/bin/du";<br />
$CFG->pathtodot = "/usr/bin/dot";<br />
$CFG->pathtogs = "/usr/bin/gs";<br />
</syntaxhighlight><br />
<br />
Configuration for plugins can also be forced by the syntax is different, eg continuing the example above for security to always hard coded paths to all executable files:<br />
<br />
<syntaxhighlight lang="php"><br />
$CFG->forced_plugin_settings['filter_text']['pathconvert'] = '/usr/bin/convert';<br />
$CFG->forced_plugin_settings['filter_text']['pathdvips'] = '/usr/bin/dvips';<br />
$CFG->forced_plugin_settings['filter_text']['pathdvisvgm'] = '/usr/bin/dvisvgm';<br />
$CFG->forced_plugin_settings['filter_text']['pathlatex'] = '/usr/bin/latex';<br />
</syntaxhighlight><br />
<br />
==See also==<br />
<br />
* Using Moodle [http://moodle.org/mod/forum/discuss.php?d=137889 Moodle Salting] forum discussion<br />
<br />
[[de:Konfigurationsdatei]]<br />
[[es:config.php]]<br />
[[fr:Fichier de configuration]]<br />
[[ja:設定ファイル]]</div>Leonstrhttps://docs.moodle.org/310/en/index.php?title=MySQL_full_unicode_support&diff=140566MySQL full unicode support2021-07-23T19:09:26Z<p>Leonstr: /* Steps to upgrade */ Changed <code> to <syntaxhighlight>, added semicolons to SQL, minor capitalisation changes</p>
<hr />
<div>{{Environment}}<br />
==UTF-8==<br />
<br />
UTF-8 is a character encoding that most websites use. It encodes each of the 1,112,064 valid code points. To store all of this information, four bytes is required. The most popular values are in the three byte region. MySQL by default only uses a three byte encoding and so values in the four byte range (eg. Asian characters and Emojis) can not be stored. Any attempt to enter a text that contains four byte characters will result in a Moodle database error.<br />
<br />
MySQL does provide full four byte UTF-8 support, but it requires certain database settings to be configured. From version 3.3 on Moodle uses full UTF-8 for both MySQL and MariaDB by default. Existing databases will still run with partial support, but it is recommended to move over to full support.<br />
<br />
Moodle comes with a Command Line Interface (CLI) script for converting to full UTF-8 for MySQL (and MariaDB). Before Moodle versions 3.1.5 and 3.2.2 this conversion tool would only change the Collation to some variant of 'utf8_bin'. 'utf8_unicode_ci' was the recommended Collation. We now recommend using 'utf8mb4_unicode_ci' which supports four byte characters (utf8_unicode_ci only supports three).<br />
<br />
This script will attempt to change the database Collation, Character set, default table settings and column definitions.<br />
<br />
To summarise:<br />
<br />
* Fresh installs of Moodle 3.1.5 and 3.2.2 onwards will use utf8mb4 by default, if the database server is configured appropriately (see below).<br />
* Sites upgrading to Moodle 3.1.5 or 3.2.2 can use the script to update to utf8mb4. In Moodle 3.3, 3.4 and 3.5 a warning will show that the database isn't using full UTF-8 support and suggest moving to 'utf8mb4_unicode_ci', but you may choose to keep using 'utf8_*'.<br />
<br />
===File format===<br />
<br />
To allow for large indexes on columns that are a varchar, a combination of settings needs to be set. The file format for the system needs to be using "Barracuda". This allows for the row format to be set to "Compressed" or "Dynamic". To enable this setting see the upgrade steps listed below. Moodle will not install if you have large format enabled without the Barracuda file format.<br />
<br />
===File per table===<br />
<br />
To enable this setting see the upgrade steps listed below.<br />
<br />
===Large prefix===<br />
<br />
This in conjunction with the row format being either "Compressed" or "Dynamic" allows for large varchar indexes above 191 characters.<br />
To enable this setting see the upgrade steps listed below.<br />
<br />
==Steps to upgrade==<br />
<br />
Most important: Please backup your database before making any changes or running the CLI script.<br />
<br />
* Change configuration settings for MySQL (exactly the same for MariaDB). This step is optional. You can run the script and it will try and make these changes itself. If errors occur then try manually changing these settings as listed below.<br />
** On Linux based systems you will want to alter my.cnf. This may be located in '/etc/mysql/'.<br />
** Make the following alterations to my.cnf:<br />
<br />
Important Change; InnoDB: The following InnoDB file format configuration options were deprecated in MySQL 5.7.7 and are now removed:<br />
<br />
innodb_file_format<br />
<br />
innodb_file_format_check<br />
<br />
innodb_file_format_max<br />
<br />
innodb_large_prefix<br />
<br />
<br />
<syntaxhighlight lang="ini"><br />
[client]<br />
default-character-set = utf8mb4<br />
<br />
[mysqld]<br />
innodb_file_format = Barracuda<br />
innodb_file_per_table = 1<br />
innodb_large_prefix = true<br />
<br />
character-set-server = utf8mb4<br />
collation-server = utf8mb4_unicode_ci<br />
skip-character-set-client-handshake<br />
<br />
[mysql]<br />
default-character-set = utf8mb4<br />
</syntaxhighlight><br />
* Restart your MySQL server.<br />
* Run the CLI script to convert to the new character set and collation (requires Moodle 3.1.5, 3.2.2 or newer): <br />
<pre><br />
$ php admin/cli/mysql_collation.php --collation=utf8mb4_unicode_ci<br />
</pre><br />
* Make sure to repair and optimize all databases and tables.<br />
<pre><br />
mysqlcheck -u root -p --auto-repair --optimize --all-databases<br />
</pre><br />
NOTE: On very large sites this may take a long time to run. You should probably establish how long on a test install before taking your live site offline. In some cases you might consider dumping and re-importing your data.<br />
<br />
* Adjust the $CFG->dboptions array in your '''config.php''' to make sure that Moodle uses the right collation when connecting to the MySQL Server: <br />
<pre><br />
$CFG->dboptions = array(<br />
&hellip;<br />
'dbcollation' => 'utf8mb4_unicode_ci',<br />
&hellip;<br />
);<br />
</pre><br />
<br />
If you only have access to the database command line (or something like phpMyAdmin) you can try the following SQL commands:<br />
<syntaxhighlight lang="sql"><br />
SET GLOBAL innodb_file_format = barracuda;<br />
<br />
SET GLOBAL innodb_file_per_table = 1;<br />
<br />
SET GLOBAL innodb_large_prefix = 'on';<br />
</syntaxhighlight><br />
<br />
* Try adding some Emojis (e.g. 😂💩) to your Moodle site to verify that the upgrade was successful.<br />
<br />
[[Category:Environment|UTF-8]]<br />
[[Category:UTF-8]]<br />
<br />
<br />
[[es:MySQL soporte unicode completo]]<br />
[[fr:Support unicode complet pour MySQL]]<br />
[[de:MySQL Unicode Unterstützung]]</div>Leonstrhttps://docs.moodle.org/310/en/index.php?title=Apache&diff=140565Apache2021-07-21T09:03:44Z<p>Leonstr: /* Slasharguments */ Replaced <code> with <syntaxhighlight></p>
<hr />
<div>{{Installing Moodle}}<br />
'''This article refers to the 'Apache HTTP server''''<br />
<br />
The Apache HTTP server is the software that (along with the PHP scripting language) 'runs' Moodle. Note that there are alternatives (e.g. IIS on Windows, Nginx on Linux, MacOS) but the Apache HTTP Server is very popular on all platforms. <br />
<br />
== Installing Apache ==<br />
Installers are available for most platforms from http://httpd.apache.org/download.cgi. The official installation instructions are here: http://httpd.apache.org/docs/2.0/install.html. If you are running Linux then you are recommended to use the packaged version if you can. For example, in Debian/Ubuntu it is simply:<br />
<pre><br />
sudo apt-get install apache2<br />
</pre><br />
<br />
See the documentation for your particular platform for the instructions. Apache is straightforward to build from source if you have to and the PHP documentation contains an article on building both Apache and PHP together - although you should rarely need to do that.<br />
<br />
==Performance==<br />
<br />
See [[Performance recommendations]]<br />
<br />
==Slasharguments==<br />
<br />
The function ''slash arguments'' is required for various features in Moodle to work correctly, as described in [[Using slash arguments]].<br />
<br />
To turn it on, add this line to your ''httpd.conf'', or to a ''.htaccess'' file in your local directory:<br />
<br />
<syntaxhighlight lang="apacheconf"><br />
AcceptPathInfo On<br />
</syntaxhighlight><br />
<br />
''Note:'' When using ".htaccess" in your local Moodle install folder, you may need to include/enable "AllowOverride Directive" in "httpd.conf", first.<br />
<br />
''Note:'' Using .htaccess file will cause performance hit on your server!<br />
<br />
If you are using Ionos (formerly 1&1) shared webhosting, the above does not work, there is a known bug when using PHP as CGI. The solution is to create a php.ini file in the moodle directory with this content:<br />
<br />
<syntaxhighlight lang="ini"><br />
cgi.fix_pathinfo = 0<br />
</syntaxhighlight><br />
<br />
Also Ionos requires that this php.ini be in every directory that a script executes. Use the procedure below to link a php.ini in every subdirectory back to your original php.ini file.<br />
<br />
<syntaxhighlight lang="bash"><br />
cd your_moodle_directory<br />
find -type d -exec ln -s $PWD/php.ini {}/php.ini \;<br />
</syntaxhighlight><br />
<br />
Source: [https://www.ionos.com/help/hosting/using-php-for-web-projects/applying-php-settings-to-all-subdirectories/ Ionos php.ini Help] <br />
<br />
This may affect other shared hosting providers as well.<br />
<br />
== Handling 40x errors ==<br />
<br />
This enables missing files to be themed by Moodle<br />
<br />
<pre><br />
ErrorDocument 404 /error/index.php<br />
<br />
# This sends any 403 from apache through to the same page, but also<br />
# overrides the http status with 404 instead for better security.<br />
ErrorDocument 403 /error/index.php?code=404<br />
</pre><br />
<br />
== Hiding internal paths ==<br />
<br />
<pre> <br />
RewriteEngine On<br />
<br />
# RewriteRule "(\/vendor\/)" - [F]<br />
# RewriteRule "(\/node_modules\/)" - [F]<br />
# RewriteRule "(^|/)\.(?!well-known\/)" - [F]<br />
# RewriteRule "(composer\.json)" - [F]<br />
# RewriteRule "(\.lock)" - [F]<br />
# RewriteRule "(\/environment.xml)" - [F]<br />
# Options -Indexes<br />
# RewriteRule "(\/install.xml)" - [F]<br />
# RewriteRule "(\/README)" - [F]<br />
# RewriteRule "(\/readme)" - [F]<br />
# RewriteRule "(\/moodle_readme)" - [F]<br />
# RewriteRule "(\/upgrade\.txt)" - [F]<br />
# RewriteRule "(phpunit\.xml\.dist)" - [F]<br />
# RewriteRule "(\/tests\/behat\/)" - [F]<br />
# RewriteRule "(\/fixtures\/)" - [F]<br />
</pre><br />
<br />
==SSL==<br />
<br />
Moodle has an option to enable HTTPS for the whole site or for just the login pages; either option requires that your web server is configured for SSL.<br />
<br />
* Whole site HTTPS is enabled by changing http://<url> to https:// <url> in your config.php 'wwwroot' parameter.<br />
* Login only HTTPS is enabled by setting the 'loginhttps' parameter, where the wwwroot schema should remain as http://<br />
<br />
NOTE: Login only https was deprecated and removed from Moodle 3.4: https://tracker.moodle.org/browse/MDL-42834<br />
<br />
Login only https is available in Moodle 3.3 and earlier in the admin interface via Administration>Security>HTTP Security and checking the button. (Note the warning and see ssl section below)<br />
<br />
Prior to Moodle 2.3 It was not advised to run the whole site over HTTPS due to legacy restrictions with client-side caching. This is no longer the case assuming client browsers support the 'Cache-Control: public' method, which all supported browsers for this version of Moodle do.<br />
<br />
To use HTTPS you will need to obtain an SSL certificate, you have two options:<br />
<br />
* Generate a self-signed certificate. This is fine on (say) an Intranet but unsuitable for the public internet, but users will we warned the certificated is untrusted when used publicly.<br />
* Purchase a certificate from a vendor. There is a surprising range of prices and value-added services available. Some hosting companies even provide free certificates. <br />
<br />
Debian provides instructions for installing a self-signed certificate [https://wiki.debian.org/Self-Signed_Certificate on their wiki] and includes general information on configuring Apache for SSL.<br />
If you purchase a vendor certificate you will normally receive instructions for installing it.<br />
<br />
A basic Apache SSL configuration can be summarised as:<br />
<br />
Listen 443<br />
NameVirtualHost *:443<br />
<VirtualHost *:443><br />
SSLEngine On<br />
SSLCertificateFile /path/to/your/certificate.crt<br />
SSLCertificateKeyFile /path/to/your/certificate.key<br />
...<br />
</VirtualHost><br />
<br />
== See also ==<br />
<br />
* [http://httpd.apache.org/ The Apache HTTP Server Project homepage]<br />
* [http://en.wikipedia.org/wiki/Apache_HTTP_Server Wikipedia article on the Apache HTTP Server]<br />
* [http://httpd.apache.org/docs/2.0/misc/perf-tuning.html Apache Performance Tuning article at the official homepage]<br />
* [https://els.earlham.edu/cayaraa/weblog/1468.html Making Moodle work with SSL]<br />
* [http://www.krufix.de/ Using the same Moodle twice in local network and Internet via SSL-Proxy] (in German)<br />
<br />
[[pl:Apache]]<br />
[[ja:Apache]]<br />
[[de:Apache]]<br />
[[es:Apache]]</div>Leonstrhttps://docs.moodle.org/310/en/index.php?title=Administration_via_command_line&diff=140564Administration via command line2021-07-19T20:14:28Z<p>Leonstr: /* Scheduled tasks */ changed schedule_task.php to admin/cli/scheduled_task.php to reflect MDL-63580</p>
<hr />
<div>{{Installing Moodle}}<br />
==Running CLI scripts==<br />
If you have shell access to your web server, you may find various CLI (command line interface) scripts useful during Moodle administration. Core admin CLI tools are located in the <code>admin/cli/*</code> folder. Other plugins provide their CLI functionality via scripts in their own cli folder. For example, the enrol_db sync script is located in <code>enrol/db/cli/</code>.<br />
<br />
To avoid problems with access control, you should run them as the owner of the web server process. It is especially important for CLI installation and upgrade as they create new files in moodledata directory and the web server has to have write access to them. In Linux distributions, the user that runs the web server is usually apache or wwrun or httpd or something similar. As a root, you will probably want to execute Moodle CLI scripts like this:<br />
<br />
$ cd /path/to/your/moodle/dir<br />
$ sudo -u apache /usr/bin/php admin/cli/somescript.php --params<br />
<br />
Most of the scripts accept common --help (or -h) parameter to display the full usage information, for example:<br />
<br />
$ sudo -u apache /usr/bin/php admin/cli/install.php --help<br />
<br />
{{Note|These scripts are supposed to be run under the identity of the web server user. Examples on this page use the <tt>apache</tt> user for illustration. The particular value depends on your OS distribution and local set-up. Typical values may be <tt>apache</tt>, <tt>www-data</tt> or <tt>httpd</tt>.}}<br />
<br />
== Upgrading ==<br />
<br />
Moodle can be upgraded from the command line. As with the installation script, there is either interactive or non-interactive mode of the upgrade. The script itself does not put the site into the maintenance mode, you have to do it on your own. Also, the script does not backup any data (if you read this page, you probably have some own scripts to backup your moodledata and the database, right?)<br />
<br />
$ sudo -u apache /usr/bin/php admin/cli/upgrade.php<br />
<br />
Upgrading via command line is a very comfortable way of Moodle upgrade if you use Git checkout of the Moodle source code (see [[Git for Administrators]]). See the following procedure how to upgrade your site within several seconds to the most recent version while preserving your eventual local customizations tracked in git repository:<br />
<br />
$ cd /var/www/sites/moodle/htdocs/<br />
$ sudo -u apache /usr/bin/php admin/cli/maintenance.php --enable<br />
$ git pull<br />
$ sudo -u apache /usr/bin/php admin/cli/upgrade.php<br />
$ sudo -u apache /usr/bin/php admin/cli/maintenance.php --disable<br />
<br />
== Installation ==<br />
<br />
There are two modes of installing Moodle from the command line. In interactive mode, the install script asks you for all data needed to properly set up new Moodle site. In non-interactive mode, you must provide all required data as the script parameters and then the new site is installed silently. The parameters can be passed in the interactive mode, too. The provided values are then used as the default values during the interactive session.<br />
<br />
$ sudo -u apache /usr/bin/php admin/cli/install.php --lang=cs<br />
<br />
If your arguments contain some specials characters for Linux based systems, don't forget to ''escape'' them with a backslash. For example, if you want to create an admin with ''pa$sword'' as password you should wrote ''pa\$sword'' instead!<br />
<br />
If required, the database install may be skipped, with just config.php populated.<br />
<br />
$ sudo -u apache /usr/bin/php admin/cli/install.php --skip-database<br />
<br />
== Maintenance mode ==<br />
<br />
To switch your site into the maintenance mode via CLI, you can use<br />
<br />
$ sudo -u apache /usr/bin/php admin/cli/maintenance.php --enable<br />
<br />
To turn maintenance mode off, execute the same script with the --disable parameter:<br />
<br />
$ sudo -u apache /usr/bin/php admin/cli/maintenance.php --disable<br />
<br />
If you don't want to enable maintenance mode immediately, but show a countdown to your users, execute the same script with the --enablelater parameter and the number of minutes which the countdown should run:<br />
<br />
$ sudo -u apache /usr/bin/php admin/cli/maintenance.php --enablelater=10<br />
<br />
This script will also create and remove the climaintenance.html file for "Offline" mode.<br />
<br />
== Offline mode ==<br />
<br />
In some situations, you may want to switch your Moodle site into offline mode so that it is not accessible via the web but you can not stop the web server completely (typically because there are other web pages and applications running there). If a file called <code>climaintenance.html</code> exists in the root folder of moodledata directory, Moodle will automatically display the contents of that file instead of any other page.<br />
<br />
$ cd /var/www/sites/moodle/moodledata/<br />
$ echo '&lt;h1&gt;Sorry, maintenance in progress&lt;/h1&gt;' &gt; climaintenance.html<br />
<br />
You can prepare a nice formatted HTML page to inform your users about the server being down and keep in the moodledata directory under a name like <code>climaintenance.off</code> and rename it to the <code>climaintenance.html</code> if needed.<br />
<br />
== Custom site defaults ==<br />
<br />
During the install and upgrade via CLI, Moodle sets the administration variables to the default values. You can use different defaults. See MDL-17850 for details. Shortly, all you need to do is to add a file <code>local/defaults.php</code> into your Moodle installation. The format of the file is like<br />
<br />
<code php><br />
<?php<br />
$defaults['pluginname']['settingname'] = 'settingvalue'; // for plugins<br />
$defaults['moodle']['settingname'] = 'settingvalue'; // for core settings<br />
</code><br />
<br />
These defaults are used during install, upgrade and are also displayed as defaults on Site administration pages.<br />
<br />
== Reset user password ==<br />
<br />
If you happen to forget your admin password (or you want to set a password for any other user on the site), you can use reset_password.php script. The script sets the correctly salted password for the given user.<br />
<br />
$ sudo -u apache /usr/bin/php admin/cli/reset_password.php<br />
<br />
==Converting InnoDB tables to Barracuda==<br />
<br />
Sites using MySQL with database tables using Antelope as the file format are recommended to convert the tables to the Barracuda file format.<br />
<br />
This is because tables using Antelope as the file format cannot handle more than 10 text columns. This file formats only supports ''compact'' and ''redundant'' row formats for backward compatibility reasons. This may cause a problem on larger sites when restoring a course, in which case the following error will be displayed: <br />
<br />
Row size too large (>8126). Changing some columns to TEXT or BLOB or using ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED may help.<br />
<br />
Barracuda is the newest innoDB file format. In addition to supporting ''compact'' and ''redundant'' row formats, Barracuda also supports ''compressed'' and ''dynamic'' row formats. <br />
<br />
However, converting tables to Barracuda is only recommended, and not required, since not all MySQL users are affected. (It may only be a problem for larger sites.)<br />
<br />
===Tool for converting tables===<br />
<br />
A command line tool is included in Moodle for converting tables to Barracuda.<br />
<br />
To view tables requiring conversion, use the list option:<br />
<br />
$ php admin/cli/mysql_compressed_rows.php --list<br />
<br />
Here is an example output:<br />
<br />
mdl_data Compact (needs fixing) <br />
mdl_data_fields Compact (needs fixing)<br />
mdl_enrol_paypal Compact (needs fixing)<br />
<br />
To proceed with the conversion, run the command using the fix option:<br />
<br />
$ php admin/cli/mysql_compressed_rows.php --fix<br />
<br />
Successful table conversion will be reported in the output, for example:<br />
<br />
mdl_data ... Compressed<br />
mdl_data_fields ... Compressed<br />
mdl_enrol_paypal ... Compressed<br />
<br />
Please note that the commands must be executed on your moodle directory. Once tables are fixed, the warning message will no longer be displayed.<br />
<br />
For further information on InnoDB file formats see the [http://dev.mysql.com/doc/innodb/1.1/en/glossary.html#glos_antelope MySQL InnoDB glossary - Antelope] and the [http://dev.mysql.com/doc/innodb/1.1/en/glossary.html#glos_barracuda MySQL InnoDB glossary - Barracuda].<br />
<br />
If you get errors due to having insufficient privileges to run these commands (this is quite likely) then the easiest solution is to generate the required SQL commands using,<br />
<br />
$ php admin/cli/mysql_compressed_rows.php --showsql<br />
<br />
You can then copy the generated SQL into your mysql client running as the 'root' user.<br />
<br />
==Converting to the new character set and collation==<br />
<br />
$ php admin/cli/mysql_collation.php --collation=utf8mb4_unicode_ci<br />
<br />
== Running cron via command line ==<br />
<br />
In versions 1.x, you could execute admin/cron.php either from command line or via the web. Since Moodle 2.0, only admin/cli/cron.php script can be run via command line.<br />
<br />
== Scheduled tasks ==<br />
<br />
Scheduled tasks are automatically run by the cron script, but the specific tasks which run on each cron iteration are determined by the scheduled tasks configuration. It is possible to override the scheduled tasks configuration and run a single scheduled task immediately using the admin/cli/scheduled_task.php script. <br />
<br />
This script accepts the following arguments:<br />
<br />
--list - list all the known scheduled tasks. The tasks are listed by the class name used to run the task. This class name is required as the argument to the next option in order to run a specific task immediately.<br />
<br />
--execute=<task> - Runs a single scheduled task immediately - regardless of scheduling settings. This will even run disabled tasks. Tasks will still use locking to prevent concurrent execution of the same task - even on clusters. The format of the <task> argument must be the same as returned by the --list option above.<br />
<br />
--showsql - Shows sql queries before they are execute<br />
<br />
--showdebugging - Shows developer debugging info<br />
<br />
'''Note:''' You must escape the "\" with an extra \ when using the --execute command. Take the following for example:<br />
<br />
<pre>php admin/cli/scheduled_task.php --list</pre><br />
<br />
will return something like:<br />
<br />
<pre><br />
== List of scheduled tasks (http://yourserver.com/moodle) ==<br />
\enrol_imsenterprise\task\cron_task 10 * * * * * ASAP<br />
\logstore_legacy\task\cleanup_task * 5 * * * * ASAP<br />
\logstore_standard\task\cleanup_task * 4 * * * * Wednesday, November 12, 2014, 4:35 AM<br />
\mod_forum\task\cron_task * * * * * * ASAP<br />
\core\task\automated_backup_task 50 * * * * * ASAP<br />
<br />
...<br />
</pre><br />
<br />
To run the first task in that list, you would execute<br />
<br />
php admin/cli/scheduled_task.php --execute='\enrol_imsenterprise\task\cron_task'<br />
<br />
Be aware of the single quotes. Without them, you would need to use double backlashes to avoid escaping by the shell.<br />
<br />
==Database transfer==<br />
<br />
A command line script for [[Database transfer]] may be found in ''admin/tool/dbtransfer/cli/migrate.php''.<br />
<br />
==Purge caches==<br />
<br />
You can purge caches using this script:<br />
<br />
php admin/cli/purge_caches.php<br />
<br />
==Kill all sessions==<br />
If needed for administrative reasons, you can kill all user sessions using this script:<br />
<br />
php admin/cli/kill_all_sessions.php<br />
<br />
As a result, all users will be logged out from Moodle.<br />
<br />
==Backup and restore of large courses==<br />
<br />
See Backup via CLI in [[Course backup]] and Restore via CLI in [[Course restore]] (new in 3.10 onwards).<br />
<br />
==Fix course / module sequences==<br />
<br />
In rare cases (such as after upgrading from a very old version of Moodle), the course / section / module sequence data can be out of sync. This can cause various problems for affected courses, such as sections not appearing, backups failing, pages not displaying etc. There is a specific check to check for errors caused by this problem, and to fix the data in the database if they are found. To run this script please use the command below:<br />
<br />
php admin/cli/fix_course_sequence.php -c=* --fix<br />
<br />
This will check every course in Moodle and report which ones had errors and were fixed.<br />
<br />
==Fix orphaned question categories==<br />
<br />
When a quiz is created, a new question category for the quiz is automatically created. In versions of Moodle prior to 2.9.1, if the quiz is deleted, the question category and any questions in the category remain in database. These orphaned question categories may be fixed by running the admin/cli/fix_orphaned_question_categories.php script with the --fix option.<br />
<br />
==Search and replace text==<br />
<br />
This script can be used to search and replace text throughout the whole database. Use carefully and backup first always. More info in [[Search and replace tool]].<br />
<br />
php admin/tool/replace/cli/replace.php --search=//oldsitehost --replace=//newsitehost<br />
<br />
==Build theme CSS cache==<br />
<br />
If Moodle is not running in theme designer mode it will keep a copy of the compiled CSS on local disk and serve that to the browser when it requests a page. If there isn't a copy on local disk then a copy will be built the first time a page within Moodle is requested. <br />
<br />
With this script you can pre-compile the cached CSS files for themes within Moodle to avoid having a user wait for the theme to compile during the first page request.<br />
<br />
php admin/cli/build_theme_css.php --themes=boost<br />
<br />
==Get and set configuration values==<br />
<br />
Displays the current value of the given setting, or set the given setting to the specified value.<br />
<br />
$ php admin/cli/cfg.php [--component=<componentname>] [--json] [--shell-arg]<br />
$ php admin/cli/cfg.php --name=<configname> [--component=<componentname>] [--shell-arg] [--no-eol]<br />
$ php admin/cli/cfg.php --name=<configname> [--component=<componentname>] --set=<value><br />
$ php admin/cli/cfg.php --name=<configname> [--component=<componentname>] --unset<br />
$ php admin/cli/cfg.php [--help|-h]<br />
<br />
Examples:<br />
$ php admin/cli/cfg.php --name=langmenu<br />
will display the value of ''Display language menu'' in ''Site administration > Language > Language settings'' (0 for ''No'' or 1 for ''Yes'').<br />
$ php cfg.php --name=maxsizetodownload --component=folder<br />
will display the value of ''Maximum folder download size (MB)'' accessible from ''Site administration > Plugins > Activity modules > Folder''.<br />
$ php admin/cli/cfg.php --name=langmenu --set=0<br />
will disable the ''Language menu''.<br />
<br />
==See also==<br />
<br />
* MDL-35736 - Manage plugins via command line<br />
* MDL-36237 - Resort course list via CLI<br />
* [http://moosh-online.com/ MOOSH] - MOOdle SHell. It is a commandline tool that will allow you to perform most common Moodle tasks.<br />
<br />
[[fr:Administration en ligne de commande]]<br />
[[de:Administration über Kommandozeile]]<br />
[[es:Administración por línea de comando]]<br />
[[it:Amministrazione via linea di comando]]<br />
[[ja:コマンドライン経由の管理]]</div>Leonstrhttps://docs.moodle.org/310/en/index.php?title=Performance_recommendations&diff=140563Performance recommendations2021-07-19T15:23:35Z<p>Leonstr: /* X-Sendfile */ Changed <code> to <syntaxhighlight> as line wrapping was wrong</p>
<hr />
<div>{{Performance}}<br />
Moodle can be made to perform very well, at small usage levels or scaling up to many thousands of users. The factors involved in performance are basically the same as for any PHP-based database-driven system. When trying to optimize your server, try to focus on the factor which will make the most difference to the user. For example, if you have relatively more users browsing than accessing the database, look to improve the webserver performance.<br />
<br />
<br />
==Obtain a baseline benchmark==<br />
<br />
Before attempting any optimization, you should obtain a baseline benchmark of the component of the system you are trying to improve. For Linux try [http://lbs.sourceforge.net/ LBS] and for Windows use the Performance Monitor. Once you have quantitative data about how your system is performing currently, you'll be able to determine if the change you have made has had any real impact.<br />
<br />
The overall aim of adjustments to improve performance is to use RAM (cacheing) and to reduce disk-based activity. It is especially important to try to eliminate swap file usage as much as you can. If your system starts swapping, this is a sign that you need more RAM. <br />
<br />
The '''optimization order preference''' is usually: primary storage (more RAM), secondary storage (faster hard disks/improved hard disk configuration), processor (more and faster).<br />
<br />
It can be interesting to install and use the [https://moodle.org/plugins/report_benchmark Benchmark plugin] in order to find the bottlenecks of your system that specifically affect Moodle.<br />
<br />
==Scalability==<br />
<br />
Moodle's design (with clear separation of application layers) allows for strongly scalable setups. (Please check the list of [[Large installations|large Moodle installations]].)<br />
<br />
Large sites usually separate the web server and database onto separate servers, although for smaller installations this is typically not necessary.<br />
<br />
It is possible to load-balance a Moodle installation, for example by using more than one webserver. The separate webservers should query the same database and refer to the same filestore and cache areas (see [[Caching]]), but otherwise the separation of the application layers is complete enough to make this kind of clustering feasible. Similarly, the database could be a cluster of servers (e.g. a MySQL cluster), but this is not an easy task and you should seek expert support, e.g. from a Moodle Partner.<br />
<br />
On very large, load-balanced, systems the performance of the shared components become critical. It's important that your shared file areas are properly tuned and that you use an effective cache (Redis is highly recommended). A good understanding of these areas of system administration should be considered a minimum requirement. <br />
<br />
===Server cluster===<br />
<br />
Using Moodle forum discussions:<br />
<br />
*[http://moodle.org/mod/forum/discuss.php?d=57202 Moodle clustering]<br />
*[http://moodle.org/mod/forum/discuss.php?d=44470 Software load balancing]<br />
*[http://moodle.org/mod/forum/discuss.php?d=49986 TCP load balancing]<br />
*[http://moodle.org/mod/forum/discuss.php?d=88214 Installation for 3000 simultaneous users]<br />
<br />
==Hardware configuration==<br />
'''Note''': The fastest and most effective change that you can make to improve performance is to '''increase the amount of RAM on your web server''' - get as much as possible (e.g. 4GB or more). Increasing primary memory will reduce the need for processes to swap to disk and will enable your server to handle more users.<br />
* Better performance is gained by obtaining the best '''processor capability''' you can, i.e. dual or dual core processors. A modern BIOS should allow you to enable hyperthreading, but check if this makes a difference to the overall performance of the processors by using a [http://en.wikipedia.org/wiki/Super_PI CPU benchmarking tool].<br />
* If you can afford them, use '''SCSI hard disks''' instead of SATA drives. SATA drives will increase your system's CPU utilization, whereas SCSI drives have their own integrated processors and come into their own when you have multiple drives. If you must have SATA drives, check that your motherboard and the drives themselves support NCQ (Native Command Queuing).<br />
* Purchase hard disks with a '''low seek time'''. This will improve the overall speed of your system, especially when accessing Moodle's reports.<br />
* Size your '''swap file''' correctly. The general advice is to set it to 4 x physical RAM.<br />
* Use a '''RAID disk system'''. Although there are many different RAID configurations you can create, the following generally works best:<br />
** install a hardware RAID controller (if you can)<br />
** the operating system and swap drive on one set of disks configured as RAID-1.<br />
** Moodle, Web server and Database server on another set of disks configured as RAID-5.<br />
* If your 'moodledata' area is going to be on relatively slow storage (e.g. NFS mount on to a NAS device) you will have performance issues with the default cache configuration (which writes to this storage). See the page on [[Caching]] and choose an alternative. Redis is recommended. Using [https://en.wikipedia.org/wiki/GlusterFS GlusterFS] / [https://en.wikipedia.org/wiki/OCFS2 OCFS2] / [https://en.wikipedia.org/wiki/GFS2 GFS2] on a [https://en.wikipedia.org/wiki/Storage_Area_Network SAN] device and [https://en.wikipedia.org/wiki/Fibre_Channel Fiber Channel] could improve performance (See more info on the Moodle [https://moodle.org/mod/forum/discuss.php?d=214680#p1123124 forum thread], [https://moodle.org/mod/forum/discuss.php?d=310501#p1242382 NFS performance tuing] )<br />
* Use '''gigabit ethernet''' for improved latency and throughput. This is especially important when you have your webserver and database server separated out on different hosts.<br />
* Check the settings on your '''network card'''. You may get an improvement in performance by increasing the use of buffers and transmit/receive descriptors (balance this with processor and memory overheads) and off-loading TCP checksum calculation onto the card instead of the OS.<br />
* Read this [http://moodle.org/mod/forum/discuss.php?d=68579 Case Study] on a server stress test with 300 users. <br />
* See this [http://elearning.sgu.ac.jp/doc/PT/ accompanying report] on network traffic and server loads.<br />
* Also see this SFSU presentation at Educause (using VMWare): [http://www.educause.edu/Resources/AnOpenSourceLMSforaMissionCrit/162843]<br />
<br />
==Operating System==<br />
* You can use [http://en.wikipedia.org/wiki/Linux Linux](recommended), Unix-based, Windows or Mac OS X for the server '''operating system'''. *nix operating systems generally require less memory than Mac OS X or Windows servers for doing the same task as the server is configured with just a shell interface. Additionally Linux does not have licensing fees attached, but can have a big learning curve if you're used to another operating system. If you have a large number of processors running SMP, you may also want to consider using a highly tuned OS such as [http://en.wikipedia.org/wiki/Solaris_Operating_Environment Solaris].<br />
* Check your own OS and '''vendor specific instructions''' for optimization steps.<br />
** For Linux look at the [http://linuxperf.sourceforge.net/ Linux Performance Team] site. <br />
** For Linux investigate the hdparm command, e.g. hdparm -m16 -d1 can be used to enable read/write on multiple sectors and DMA. Mount disks with the [https://moodle.org/mod/forum/discuss.php?d=310501#p1242382 "async" and "noatime"] options.<br />
** For Windows set the sever to be optimized for network applications (Control Panel, Network Connections, LAN connection, Properties, File & Printer Sharing for Microsoft Networks, Properties, Optimization). You can also search the [http://technet.microsoft.com/ Microsoft TechNet site] for optimization documents.<br />
<br />
==Web server performance==<br />
<br />
Installing [http://www.mozilla.com/en-US/ Firefox] and the [https://addons.mozilla.org/en-US/firefox/addon/1843 firebug] extension will allow you to watch the time it takes for each page component to load. Also, the [https://addons.mozilla.org/en-US/firefox/addon/5369 Yslow] extension will evaluate your page against Yahoo's [http://www.skrenta.com/2007/05/14_rules_for_fast_web_pages_by_1.html 14 rules], full text [http://developer.yahoo.com/performance/rules.html Best Practices for Speeding Up Your Web Site], <strike>([http://video.yahoo.com/video/play?vid=1040890 video])</strike> for fast loading websites.<br />
<br />
===PHP performance===<br />
* PHP contains a built-in accelerator. Make sure it is enabled. <br />
* Improvements in read/write performance can be improved by putting the cached PHP pages on a [[TMPFS]] filesystem - but remember that you'll lose the cache contents when there is a power failure or the server is rebooted.<br />
* Performance of PHP is better when installed as an '''Apache/IIS6 ISAPI module''' (rather than a CGI). IIS 7.0/7.5 (Windows Server 2008/R2) users should choose a FastCGI installation for best performance.<br />
* Also check the '''memory_limit''' in php.ini. The default value for the memory_limit directive is 128M. On some sites, it may need to be larger - especially for some backup operations. <br />
* Also see [[PHP_settings_by_Moodle_version]]<br />
* Use [http://blog.bitnami.com/2014/06/performance-enhacements-for-apache-and.html PHP-FPM] (with apache).<br />
<br />
===Install HowTo===<br />
==== APC ====<br />
* [http://2bits.com/articles/installing-php-apc-gnulinux-centos-5.html APC on CentOS 5.x (linux)]<br />
* [http://fplanque.com/dev/linux/install-apc-php-cache-debian-lenny APC on Debian (linux)]<br />
==== eAccelerator ====<br />
* [http://noveckg.blogspot.com/2010/02/installing-eaccelerator-cache-for-php.html Installing eAccelerator on CentOS 5.x (linux)]<br />
* [https://docs.moodle.org/en/Installing_eAccelerator_In_Ubuntu_Server/ Installing eAccelerator on Ubuntu Server (linux)]<br />
==== MemCached ====<br />
Memcached server (daemon)<br />
* [https://www.tecmint.com/install-memcached-on-centos-7/ Installing Memcached on CentOS 7.x (linux)] (as of php 7.x, only memcached is available)<br />
* [https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-memcached-on-centos-7 How To Install and Secure Memcached on CentOS 7]<br />
* [https://wiki.zimbra.com/wiki/Blocking_Memcached_Attack#Iptables_rules_for_Redhat_based_servers Iptables rules for Redhat based servers]<br />
Memcached PHP 7.1 extension <br />
* [https://dl.iuscommunity.org/pub/ius/stable/CentOS/7/x86_64/repoview/php71u-pecl-memcached.html php71u-pecl-memcached] from IUS CentOS 7.x repository.<br />
<br />
===Apache performance===<br />
* If you are using Apache on a Windows server, use the build from [http://www.apachelounge.com Apache Lounge] which is reported to have [http://moodle.org/mod/forum/discuss.php?d=93358 performance and stability improvements] compared to the official Apache download. Note that this is an unofficial build, so may not keep up with official releases.<br />
* Set the '''MaxRequestWorkers''' directive correctly ('''MaxClients''' before Apache 2.4). Use this formula to help (which uses 80% of available memory to leave room for spare):<br />
MaxRequestWorkers = Total available memory * 80% / Max memory usage of apache process<br />
:Memory usage of apache process is usually 10MB but Moodle can easily use up to 100MB per process, so a general rule of thumb is to divide your available memory in megabytes by 100 to get a conservative setting for MaxClients. You are quite likely to find yourself lowering the MaxRequestWorkers from its default of 150 on a Moodle server. To get a more accurate estimate read the value from the shell command:<br />
#ps -ylC httpd --sort:rss<br />
<br />
:If you need to increase the value of '''MaxRequestWorkers''' beyond 256, you will also need to set the '''ServerLimit''' directive. <br />
<br />
:'''Warning''': Do not be tempted to set the value of MaxRequestWorkers higher than your available memory as your server will consume more RAM than available and start to swap to disk. <br />
* Consider reducing the '''number of modules''' that Apache loads in the httpd.conf file to the minumum necessary to reduce the memory needed. <br />
* Use the '''latest version of Apache''' - Apache 2 has an improved memory model which reduces memory usage further.<br />
* For Unix/Linux systems, consider lowering '''MaxConnectionsPerChild''' ('''MaxRequestsPerChild''' before Apache 2.4) in httpd.conf to as low as 20-30 (if you set it any lower the overhead of forking begins to outweigh the benefits). <br />
* For a heavily loaded server, consider setting '''KeepAlive Off''' (do this only if your Moodle pages do not contain links to resources or uploaded images) or lowering the '''KeepAliveTimeout''' to between 2 and 5. The default is 15 (seconds) - the higher the value the more server processes will be kept waiting for possibly idle connections. A more accurate value for KeepAliveTimeout is obtained by observing how long it takes your users to download a page. After altering any of the KeepAlive variables, monitor your CPU utilization as there may be an additional overhead in initiating more worker processes/threads.<br />
* As an alternative to using KeepAlive Off, consider setting-up a '''Reverse Proxy server''' infront of the Moodle server to cache HTML files with images. You can then return Apache to using keep-alives on the Moodle server.<br />
* If you do not use a .htaccess file, set the '''AllowOverride''' variable to AllowOverride None to prevent .htaccess lookups.<br />
* Set '''DirectoryIndex''' correctly so as to avoid content-negotiation. Here's an example from a production server:<br />
DirectoryIndex index.php index.html index.htm<br />
* Unless you are doing development work on the server, set '''ExtendedStatus Off''' and disable mod_info as well as mod_status.<br />
* Leave '''HostnameLookups Off''' (as default) to reduce DNS latency.<br />
* Consider reducing the value of '''TimeOut''' to between 30 to 60 (seconds). <br />
* For the '''Options directive''', avoid Options Multiviews as this performs a directory scan. To reduce disk I/O further use<br />
Options -Indexes FollowSymLinks<br />
<br />
* Compression reduces response times by reducing the size of the HTTP response<br />
# Install and enable mod_deflate - refer to documentation or man pages<br />
# Add this code to the virtual server config file within the <directory> section for the root directory (or within the .htaccess file if AllowOverrides is On):<br />
<ifModule mod_deflate.c><br />
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/x-js text/javascript text/css application/javascript<br />
</ifmodule><br />
* Use Apache [http://blog.bitnami.com/2014/06/performance-enhacements-for-apache-and.html event] [http://httpd.apache.org/docs/current/mpm.html MPM] (and not the default Prefork or Worker)<br />
<br />
===IIS performance===<br />
All alter this location in the registry:<br />
HKLM\SYSTEM\CurrentControlSet\Services\Inetinfo\Parameters\<br />
* The equivalent to KeepAliveTimeout is '''ListenBackLog''' (IIS - registry location is HKLM\ SYSTEM\ CurrentControlSet\ Services\ Inetinfo\ Parameters). Set this to between 2 to 5.<br />
*Change the '''MemCacheSize''' value to adjust the amount of memory (Mb) that IIS will use for its file cache (50% of available memory by default).<br />
*Change the '''MaxCachedFileSize''' to adjust the maximum size of a file cached in the file cache in bytes. Default is 262,144 (256K).<br />
*Create a new DWORD called '''ObjectCacheTTL''' to change the length of time (in milliseconds) that objects in the cache are held in memory. Default is 30,000 milliseconds (30 seconds).<br />
<br />
===Lighttpd, NginX and Cherokee performance===<br />
You can increase server performance by using a '''light-weight''' webserver like [http://www.lighttpd.net/ lighttpd], [http://nginx.net/ nginx] or [http://www.cherokee-project.com/ cherokee] in combination with PHP in FastCGI-mode. Lighttpd was originally created as a proof-of-concept[http://www.lighttpd.net/story] to address the [http://www.kegel.com/c10k.html C10k problem] and while primarily recommended for memory-limited servers, its design origins and asynchronous-IO model make it a suitable and proven[http://blog.lighttpd.net/articles/2006/12/28/lighttpd-powers-5-alexa-top-250-sites] alternative HTTP server for high-load websites and web apps, including Moodle. See the [[lighttpd | MoodleDocs Lighttpd page]] for additional information, configuration example and links.<br />
<br />
Alternatively, both [http://www.lighttpd.net/ lighttpd] and [http://nginx.net/ nginx] are capable of performing as a load-balancer and/or reverse-proxy to alleviate load on back-end servers[http://www.linuxjournal.com/article/10108], providing benefit without requiring an actual software change on existing servers.<br />
<br />
Do note that these are likely to be the least tested server environments of all particularly if you are using advanced features such as web services and/or Moodle Networking. They are probably best considered for heavily used Moodle sites with relatively simple configurations.<br />
<br />
===X-Sendfile===<br />
<br />
X-Sendfile modules improve performance when sending large files from Moodle. It is recommended to configure your web server and Moodle to use this feature if available.<br />
<br />
Configure web server:<br />
* Apache - https://tn123.org/mod_xsendfile/<br />
* Lighttpd - http://redmine.lighttpd.net/projects/lighttpd/wiki/X-LIGHTTPD-send-file<br />
* Nginx - http://wiki.nginx.org/XSendfile<br />
<br />
Enable support in config.php (see config-dist.php):<br />
<syntaxhighlight lang="php"><br />
// $CFG->xsendfile = 'X-Sendfile'; // Apache {@see https://tn123.org/mod_xsendfile/}<br />
// $CFG->xsendfile = 'X-LIGHTTPD-send-file'; // Lighttpd {@see http://redmine.lighttpd.net/projects/lighttpd/wiki/X-LIGHTTPD-send-file}<br />
// $CFG->xsendfile = 'X-Accel-Redirect'; // Nginx {@see http://wiki.nginx.org/XSendfile}<br />
</syntaxhighlight><br />
<br />
Configure file location prefixes if your server implementation requires it:<br />
<syntaxhighlight lang="php"><br />
// $CFG->xsendfilealiases = array(<br />
// '/dataroot/' => $CFG->dataroot,<br />
// '/cachedir/' => '/var/www/moodle/cache', // for custom $CFG->cachedir locations<br />
// '/localcachedir/' => '/var/local/cache', // for custom $CFG->localcachedir locations<br />
// '/tempdir/' => '/var/www/moodle/temp', // for custom $CFG->tempdir locations<br />
// '/filedir' => '/var/www/moodle/filedir', // for custom $CFG->filedir locations<br />
// );<br />
</syntaxhighlight><br />
<br />
== Cron performance ==<br />
<br />
Cron is a very important part of the overall performance of moodle as many asynchronous processes are offloaded to cron, so it needs to be running and have enough through put to handle the work being given to it by the front ends.<br />
<br />
See [[Cron_with_Unix_or_Linux#High_performance_cron_tasks]]<br />
<br />
==Database performance==<br />
<br />
===MySQL performance===<br />
<br />
The '''number one thing''' you can do to improve MySQL performance is to read, understand and implement the recommendations in the [https://dev.mysql.com/doc/refman/5.7/en/innodb-buffer-pool.html Innodb Buffer Pool] article.<br />
<br />
The [https://dev.mysql.com/doc/refman/5.7/en/innodb-buffer-pool-resize.html buffer pool size] can safely be changed while your server is running, as long as your server has enough memory (RAM) to accommodate the value you set. On a machine that is dedicated to MySQL, you can safely set this value to 80% of available memory.<br />
<br />
Consider setting [https://dev.mysql.com/doc/refman/5.7/en/innodb-parameters.html#sysvar_innodb_buffer_pool_instances innodb_buffer_pool_instances] to the number of cores, vCPUs, or chips you have available. Adjust this value in accordance with the recommendations in the [https://dev.mysql.com/doc/refman/5.7/en/innodb-buffer-pool-resize.html MySQL documentation].<br />
<br />
The following are MySQL specific settings which can be adjusted for better performance in your my.cnf (my.ini in Windows). The file contains a list of settings and their values. To see the current values use these commands<br />
SHOW STATUS;<br />
SHOW VARIABLES; <br />
'''Important''': You must make backups of your database before attempting to change any MySQL server configuration. After any change to the my.cnf, restart mysqld.<br />
<br />
If you are able, the [http://mysqltuner.pl/ MySQLTuner] tool can be run against your MySQL server and will calculate appropriate configuration values for most of the following settings based on your current load, status and variables automatically.<br />
<br />
* Enable the '''query cache''' with <br />
query_cache_type = 1. <br />
For most Moodle installs, set the following:<br />
query_cache_size = 36M <br />
query_cache_min_res_unit = 2K. <br />
The query cache will improve performance if you are doing few updates on the database. <br />
* Set the '''table cache''' correctly. For Moodle 1.6 set <br />
table_cache = 256 #(table_open_cache in MySQL > 5.1.2)<br />
(min), and for Moodle 1.7 set <br />
table_cache = 512 #(table_open_cache in MySQL > 5.1.2)<br />
(min). The table cache is used by all threads (connections), so monitor the value of opened_tables to further adjust - if opened_tables > 3 * table_cache(table_open_cache in MySQL > 5.1.2) then increase table_cache upto your OS limit. Note also that the figure for table_cache will also change depending on the number of modules and plugins you have installed. Find the number for your server by executing the mysql statement below. Look at the number returned and set table_cache to this value.<br />
mysql>SELECT COUNT(table_name) FROM information_schema.tables WHERE table_schema='yourmoodledbname';<br />
* Set the '''thread cache''' correctly. Adjust the value so that your thread cache utilization is as close to 100% as possible by this formula:<br />
thread cache utilization (%) = (threads_created / connections) * 100<br />
* The '''key buffer''' can improve the access speed to Moodle's SELECT queries. The correct size depends on the size of the index files (.myi) and in Moodle 1.6 or later (without any additional modules and plugins), the recommendation for this value is key_buffer_size = 32M. Ideally you want the database to be reading once from the disk for every 100 requests so monitor that the value is suitable for your install by adjusting the value of key_buffer_size so that the following formulas are true:<br />
key_read / key_read_requests < 0.01<br />
key_write / key_write_requests <= 1.0<br />
* Set the '''maximum number of connections''' so that your users will not see a "Too many connections" message. Be careful that this may have an impact on the total memory used. MySQL connections usually last for milliseconds, so it is unusual even for a heavily loaded server for this value to be over 200.<br />
* Manage '''high burst activity'''. If your Moodle install uses a lot of quizzes and you are experiencing performance problems (check by monitoring the value of threads_connected - it should not be rising) consider increasing the value of back_log.<br />
* '''Optimize your tables weekly and after upgrading Moodle'''. It is good practice to also optimize your tables after performing a large data deletion exercise, e.g. at the end of your semester or academic year. This will ensure that index files are up to date. Backup your database first and then use:<br />
mysql>CHECK TABLE mdl_tablename;<br />
mysql>OPTIMIZE TABLE mdl_tablename;<br />
:The common tables in Moodle to check are mdl_course_sections, mdl_forum_posts, mdl_log and mdl_sessions (if using dbsessions). Any errors need to be corrected using REPAIR TABLE (see the [http://dev.mysql.com/doc/refman/5.0/en/repair-table.html MySQL manual] and this [http://moodle.org/mod/forum/discuss.php?d=58208#p279638 forum script]).<br />
* '''Maintain the key distribution'''. Every month or so it is a good idea to stop the mysql server and run these myisamchk commands.<br />
#myisamchk -a -S /pathtomysql/data/moodledir/*.MYI<br />
:'''Warning''': You must stop the mysql database process (mysqld) before running any myisamchk command. If you do not, you risk data loss.<br />
* Reduce the number of '''temporary tables saved to disk'''. Check this with the created_tmp_disk_tables value. If this is relatively large (>5%) increase tmp_table_size until you see a reduction. Note that this will have an impact on RAM usage.<br />
<br />
===PostgreSQL performance===<br />
<br />
There are some good papers around on tuning PostgreSQL (like [http://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server this one]), and Moodle's case does not seem to be different to the general case.<br />
<br />
The first thing to recognise is that if you really need to worry about tuning you should be using a separate machine for the database server. If you are not using a separate machine then the answers to many performance questions are substantially muddied by the memory requirements of the rest of the application.<br />
<br />
You should probably '''enable autovacuum''', unless you know what you are doing. Many e-learning sites have predictable periods of low use, so disabling autovacuum and running a specific vacuum at those times can be a good option. Or perhaps leave autovacuum running but do a full vacuum weekly in a quiet period.<br />
<br />
Set '''shared_buffers''' to something reasonable. For versions up to 8.1 my testing has shown that peak performance is almost always obtained with buffers < 10000, so if you are using such a version, and have more than 512M of RAM just set shared_buffers to 10,000 (8MB).<br />
<br />
The buffer management had a big overhaul in 8.2 and "reasonable" is now a much larger number. I have not conducted performance tests with 8.2, but the recommendations from others are generally that you should now scale shared_buffers much more with memory and may continue to reap benefits even up to values like 100,000 (80MB). Consider using 1-2% of system RAM.<br />
<br />
PostgreSQL will also assume that the operating system is caching its files, so setting '''effective_cache_size''' to a reasonable value is also a good idea. A reasonable value will usually be (total RAM - RAM in use by programs). If you are running Linux and leave the system running for a day or two you can look at 'free' and under the 'cached' column you will see what it currently is. Consider taking that number (which is kB) and dividing it by 10 (i.e. allow 20% for other programs cache needs and then divide by 8 to get pages). If you are not using a dedicated database server you will need to decrease that value to account for usage by other programs.<br />
<br />
Some other useful parameters that can have positive effects, and the values I would typically set them to on a machine with 4G RAM, are:<br />
<br />
work_mem = 10240<br />
<br />
That's 10M of RAM to use instead of on-disk sorting and so forth. That can give a big speed increase, but it is per connection and 200 connections * 10M is 2G, so it can theoretically chew up a lot of RAM.<br />
<br />
maintenance_work_mem = 163840<br />
<br />
That's 160M of RAM which will be used by (e.g.) VACUUM, index rebuild, cluster and so forth. This should only be used periodically and should be freed when those processes exit, so I believe it is well worth while.<br />
<br />
wal_buffers = 64<br />
<br />
These buffers are used for the write-ahead log, and there have been a number of reports on the PostgreSQL mailing lists of improvement from this level of increase.<br />
<br />
This is a little out of date now (version 8.0) but still worth a read: http://www.powerpostgresql.com/Docs<br />
<br />
And there is lots of good stuff here as well: http://www.varlena.com/GeneralBits/Tidbits/index.php<br />
<br />
''Based on Andrew McMillan's post at [http://moodle.org/mod/forum/discuss.php?d=68558 Tuning PostgreSQL] forum thread.''<br />
<br />
* Splitting '''mdl_log''' to several tables and using a VIEW with UNION to read them as one. (See Tim Hunt [https://moodle.org/mod/forum/discuss.php?d=243531#p1104165 explanation] on the Moodle forums)<br />
<br />
===Other database performance links===<br />
* Consider using a '''distributed cacheing system''' like [http://en.wikipedia.org/wiki/Memcached memcached] but note that memcached does not have any security features so it should be used behind a firewall.<br />
* Consider using PostgreSQL. See [http://moodle.org/mod/forum/discuss.php?d=49195 how to migrate from MySQL to PostgreSQL] (forum discussion).<br />
* [http://dev.mysql.com/doc/refman/5.0/en/server-parameters.html General advice on tuning MySQL parameters] (advice from the MySQL manual)<br />
* [http://www.mysqlperformanceblog.com/2007/11/01/innodb-performance-optimization-basics/ InnoDB performance optimization] taken from the [http://www.mysqlperformanceblog.com/ MySQL performance blog] site.<br />
<br />
==Performance of different Moodle modules==<br />
<br />
Moodle's activity modules, filters, and other plugins can be activated/deactivated. If necessary, you may wish to deactivate some features (such as chat) if not required - but this isn't necessary. Some notes on the performance of certain modules:<br />
<br />
* The '''Chat''' module is [http://moodle.org/mod/forum/discuss.php?d=37979&parent=175079 said] to be a hog in terms of frequent HTTP requests to the main server. This can be reduced by setting the module to use ''Streamed'' updates, or, if you're using a Unix-based webserver, by running the chat in daemon mode. When using the Chat module use the configuration settings to tune for your expected load. Pay particular attention to the ''chat_old_ping'' and ''chat_refresh'' parameters as these can have greatest impact on server load.<br />
* The Moodle '''Cron''' task is triggered by calling the script ''cron.php''. If this is called over HTTP (e.g. using wget or curl) it can take a large amount of memory on large installations. If it is called by directly invoking the php command (e.g. ''php -f /path/to/moodle/directory/admin/cli/cron.php'') efficiency can be much improved.<br />
* The '''Recent activities''' block is consuming too many resources if you have huge number of records <code>mdl_log</code>. This is being tested to optimize the SQL query.<br />
* The '''Quiz''' module is known to stretch database performance. However, it has been getting better in recent versions, and we don't know of any good, up-to-date performance measurements. (Here is a [http://moodle.org/mod/forum/discuss.php?d=68579 case study from 2007 with 300 quiz users].). The following suggestions were described by [https://moodle.org/user/view.php?id=94615&course=5 Al Rachels] in [https://moodle.org/mod/forum/discuss.php?d=347126 this forum thread]:<br />
** make sure both Moodle, and the operating system, are installed on a [https://en.wikipedia.org/wiki/Solid-state_drive solid state drive]<br />
** upgrade to and use [https://docs.moodle.org/dev/Moodle_and_PHP7 PHP 7]<br />
** run MySQLTuner and implement its recommendations<br />
<br />
See [[Performance settings]] for more information on performance-related Moodle settings.<br />
<br />
==See also==<br />
<br />
*Using Moodle: [http://moodle.org/mod/forum/view.php?f=94 Hardware and Performance] forum<br />
*[http://opensourceelearning.blogspot.be/2012/10/why-your-moodle-site-is-slow-five.html Why Your Moodle Site is Slow: Five Simple Settings] blog post from Jonathan Moore <br />
*I teach with Moodle perfomance testing: http://www.iteachwithmoodle.com/2012/11/17/moodle-2-4-beta-performance-test-comparison-with-moodle-2-3/<br />
*[http://jfilip.ca/2013/08/20/moodle-2-4-5-vs-2-5-1-performance-and-muc-apc-cache-store/ Moodle 2.4.5 vs 2.5.2 performance and MUC APC cahe store]<br />
*[http://jfilip.ca/2013/09/25/moodle-performance-testing-2-4-6-vs-2-5-2-vs-2-6dev/ Moodle performance testing 2.4.6 vs 2.5.2 vs 2.6dev]<br />
*[http://jfilip.ca/2013/09/24/moodle-performance-analysis-revisted-now-with-mariadb/ Moodle performance analysis revisited (now with MariaDB)]<br />
*[http://tjhunt.blogspot.ca/2013/05/performance-testing-moodle.html Tim Hunt's blog (May 2, 2013) on performance testing Moodle]<br />
*[http://newrelic.com/ New Relic, Application Performance Monitoring]<br />
*[http://blog.bitnami.com/2014/06/performance-enhacements-for-apache-and.html Performance enhacements for Apache and PHP (Apache Event MPM and PHP-FPM)]<br />
*[https://scholarlms.net/performance-recommendations/ Performance recommendations]<br />
*[https://enovation.ie/moodle-performance-investigation-using-performance-info/ Moodle performance investigation – using performance info ]<br />
<br />
There have been a lot of discussions on moodle.org about performance, here are some of the more interesting and (potentially) useful ones:<br />
<br />
* [http://moodle.org/mod/forum/discuss.php?d=83057 Performance woes!]<br />
* [http://moodle.org/mod/forum/discuss.php?d=57028 Performance perspectives - a little script]<br />
* [http://moodle.org/mod/forum/discuss.php?d=88927 Comments on planned server hardware]<br />
* [http://moodle.org/mod/forum/discuss.php?d=102978#p461624 Moodle performance in a pil by Martin Langhoff]<br />
* [https://moodle.org/mod/forum/discuss.php?d=240391#unread Advice on optimising php/db code in moodle2+]<br />
* [https://moodle.org/mod/forum/discuss.php?d=243531 Moodle 2.5 performance testing at the OU]<br />
* [https://moodle.org/mod/forum/discuss.php?d=273602 100 active users limit with 4vCPU]<br />
* [https://moodle.org/mod/forum/discuss.php?d=336603#p1356423 Performance Tip ... shared...]<br />
<br />
[[es:Recomendaciones sobre desempeño]]<br />
[[fr:Recommandations_de_performance]]<br />
[[ja:パフォーマンス]]<br />
[[de:Geschwindigkeitsempfehlungen]]</div>Leonstrhttps://docs.moodle.org/310/en/index.php?title=OPcache&diff=140562OPcache2021-07-19T14:50:58Z<p>Leonstr: /* Configuration */ Changed <code> to <syntaxhighlight> as line wrapping was wrong following wiki upgrade on 2021-07-14</p>
<hr />
<div>{{Environment}}<br />
<br />
The standard OPcache extension is strongly recommended; since Moodle 2.6, it is the only solution officially supported by PHP developers. The benefits are increased performance and significantly lower memory usage. However, opcode caching extensions (including OPcache, eAccelerator and APC) aren't compatible with servers configured to use some common types of high-security PHP handlers such as suPHP (the default on WHM / cPanel Linux servers).<br />
<br />
[[File:Opcache_error.png|800px]]<br />
<br />
==Installation==<br />
<br />
The OPcache extension is distributed as part of PHP 5.5 and later. It is available also for older stable PHP releases from PECL under the original name ZendOPcache. To check if the extension is loaded and enabled look at [[PHP#Displaying_phpinfo_in_Moodle|the PHP info page]] under the '''Zend OPcache''' heading.<br />
<br />
===Linux, macOS and other Unix-like platforms===<br />
<br />
You may need to install a specific package, e.g. on CentOS, Fedora or Red Hat: '''dnf install php-opcache'''. If necessary add the following to '''php.ini''' (package installers may do this automatically):<br />
<code ini><br />
zend_extension=/full/path/to/opcache.so <br />
</code><br />
<br />
===Microsoft Windows===<br />
<br />
The extension '''php_opcache.dll''' is included in the '''ext''' folder in the [https://windows.php.net/download PHP for Windows binary downloads].<br />
To enable it add the following to '''php.ini''':<br />
<br />
<code ini><br />
zend_extension=php_opcache.dll<br />
</code><br />
<br />
==Configuration==<br />
<br />
'''php.ini''' settings:<br />
<br />
<syntaxhighlight lang="ini"><br />
[opcache]<br />
opcache.enable = 1<br />
opcache.memory_consumption = 128<br />
opcache.max_accelerated_files = 10000<br />
opcache.revalidate_freq = 60<br />
<br />
; Required for Moodle<br />
opcache.use_cwd = 1<br />
opcache.validate_timestamps = 1<br />
opcache.save_comments = 1<br />
opcache.enable_file_override = 0<br />
<br />
; If something does not work in Moodle<br />
;opcache.revalidate_path = 1 ; May fix problems with include paths<br />
;opcache.mmap_base = 0x20000000 ; (Windows only) fix OPcache crashes with event id 487<br />
<br />
; Experimental for Moodle 2.6 and later<br />
;opcache.fast_shutdown = 1<br />
;opcache.enable_cli = 1 ; Speeds up CLI cron<br />
;opcache.load_comments = 0 ; May lower memory use, might not be compatible with add-ons and other apps.<br />
</syntaxhighlight><br />
<br />
; memory_consumption<br />
From: [http://blog.jpauli.tech/2015-03-05-opcache-html/ PHP's OPCache extension review]<br />
*''The size of the memory segment can be told using the opcache.memory_consumption INI setting (Megabytes). Size it big, don't hesitate to give space. Never ever run out of shared memory space, if you do, you will lock your processes, we'll get back to that later.''<br />
<br />
*''Size the shared memory segment according to your needs, don't forget that a production server dedicated to PHP processes may bundle several dozens of Gigabytes of memory, just for PHP. Having a 1Gb shared memory segment (or more) is not uncommon, it will depend on your needs, but if you use a modern application stack, aka framework based, with lots of dependencies etc... , then use at least 1Gb of shared memory.''<br />
<br />
Having that in mind, set opcache.memory_consumption to a value high enough to avoid filling it up (as long as your RAM usage allows you to), and then monitor the OPCache to adjust that value to its optimal size. As the total size of the PHP files in a standard Moodle 3.6 is almost 90MB, setting this value higher than that can be a good idea. Take into account that the PHP files of the plugins and those on the MoodleData folder (language pack files...) also count, so these values can be different on each installation. If you have several instances of Moodle you should multiply that value by the number of instances.<br />
<br />
Tip: If using Linux, you can know the total size of the PHP files of a folder using this command:<br />
<code ini><br />
find ./ -type f -name "*.php" -printf "%s\n" | gawk -M '{t+=$1}END{print t}' | numfmt --to=iec<br />
</code><br />
<br />
; max_accelerated_files<br />
From: [http://php.net/manual/en/opcache.configuration.php#ini.opcache.max-accelerated-files php.net max-accelerated-files]<br />
*''The maximum number of keys (and therefore scripts) in the OPcache hash table. The actual value used will be the first number in the set of prime numbers { 223, 463, 983, 1979, 3907, 7963, 16229, 32531, 65407, 130987 } that is greater than or equal to the configured value. The minimum value is 200. The maximum value is 100000 in PHP < 5.5.6, and 1000000 in later versions.''<br />
<br />
As Moodle 3.6 contains almost 10.000 php files it is recommended above that opcache.max_accelerated_files should be set to 10000 to accommodate this (16229 will actually be used as per the explanation above). If you have several instances of Moodle you should multiply that value by the number of instances.<br />
<br />
If many additional plugins are installed so that your total PHP files exceed 16229 then the next most suitable value for max_accelerated_files should be used.<br />
Tip: If using Linux, you can know the total PHP files of your Moodle using this command:<br />
<code ini><br />
find ./ -type f | grep -E ".*\.php$" | sed -e 's/.*\(\.[a-zA-Z0-9]*\)$/\1/' | sort | uniq -c | sort -n<br />
</code><br />
<br />
==Opcache management plugin==<br />
[[File:Opcache_management_message.png|400px]]<br />
<br />
You may consider installing the additional [https://moodle.org/plugins/tool_opcache Opcache management] - Moodle plugin which adds a PHP Opcache management GUI to Moodle site administration, a CLI tool to reset PHP Opcache and a Nagios check for PHP Opcache.<br />
<br />
[[File:Opcache management status.png|800px]]<br />
<br />
==See also==<br />
* [http://pecl.php.net/package/ZendOpcache PECL ZendOPcache]<br />
<br />
Forum discussions:<br />
* [https://moodle.org/mod/forum/discuss.php?d=244133 OPcache: Memory Usage = 100% (is this good or bad?)]<br />
* [https://moodle.org/mod/forum/discuss.php?d=245885 OPCode cache]<br />
<br />
<br />
<br />
[[Category:Environment]]<br />
[[Category:Installation]]<br />
[[Category:Performance]]<br />
<br />
[[es:OPcache]]</div>Leonstrhttps://docs.moodle.org/310/en/index.php?title=Step-by-step_Installation_Guide_for_Ubuntu&diff=140464Step-by-step Installation Guide for Ubuntu2021-06-12T12:37:27Z<p>Leonstr: /* Suggestions: Enable Zend OpCache/Change Document Root */ Change OPcache link from Moodle 2.6 to current version</p>
<hr />
<div>{{Installing Moodle}}<br />
{{Note|This document is about installing Moodle 3.9 in an Ubuntu 20.04 server with PHP 7.4.}}<br />
<br />
==Before you begin==<br />
It is a good idea to write down the passwords (and usernames) you will need to use for Ubuntu and Moodle:<br />
* The Ubuntu root password<br />
* The MySQL username and password that Moodle will use<br />
* The Moodle main admin username and password<br />
* An additional admin Moodle username and password<br />
<br />
== Step 1: Install Ubuntu ==<br />
<br />
===Why we prefer Ubuntu server over Ubuntu desktop===<br />
* Most IT professionals prefer to use a Command Line Interface (CLI) server, because it is safer and less prone to hacking.<br />
* Amateur users might find it easier to use a graphical (desktop) interface.<br />
* If you will only be using your Moodle server for local, experimental purposes, you might prefer to install the desktop (64 bits preferred) version of Ubuntu.<br />
* If you install a CLI only server and later regret it, you can easily add a graphical desktop:<br />
{{Note| Even though it is not recommended by most experts, you could install a Graphical User Interface (desktop) by issuing the command 'sudo tasksel' or 'sudo apt install ubuntu-desktop' to [https://help.ubuntu.com/community/ServerGUI install 'Ubuntu desktop']. BUT USE WITH CAUTION: The GUI may not appear as expected, and may prevent user from getting even the CLI. Try it at test machine first.}}<br />
<br />
===Procedure===<br />
*Ubuntu has a well known issue with its automatic updates filling up the /boot directory until automated updates start to fail and automated removal of old kernel files from /boot is impossible. Because of this you should consider installing Ubuntu with a /boot directory of around 5Gb and putting some automated clean up in place. More info can be found here - [https://help.ubuntu.com/community/RemoveOldKernels]<br />
<br />
*You can use either VI (lightweight editor) or VIM (heavyweight editor), however, if you wish to use VIM you will need to install it<br />
<pre>sudo apt-get install vim</pre><br />
<br />
*VI or VIM Commands<br /><br />
To edit a file press "Insert" Key<br /><br />
To finish editing press "Esc" Key<br /><br />
To write the file press ":w"<br /><br />
To Exit the editor press ":q"<br /><br />
You can also write and quit ":wq"<br />
<br />
*In Ubuntu, the standard user, the account you created during the install, does not have rights to install/write to many of the directories. In the below tutorial we will be using the term "sudo" which stands for "super user do" before most of the commands.<br />
<br />
== Step 2: Install Apache/MySQL/PHP ==<br />
{{Note| Moodle 3.0.1 [https://docs.moodle.org/dev/Moodle_3.0.1_release_notes introduced support for PHP 7.0 and we will be using PHP 7.4 in this tutorial]}}<br />
Open up Terminal and install the following;<br />
<br />
Adding the php7 ppa:<br />
<br />
sudo add-apt-repository ppa:ondrej/php<br />
sudo apt-get update<br />
<br />
<pre>sudo apt install apache2 mysql-client mysql-server php libapache2-mod-php</pre> <br />
<br />
'''Run 'sudo mysql_secure_installation' to set the root password for mysql - please, please my dear friends, WRITE IT DOWN and spare yourself some grief, you will need it in step 6.'''<br />
<br />
== Step 3: Install Additional Software ==<br />
<br />
<pre>sudo apt install graphviz aspell ghostscript clamav php7.4-pspell php7.4-curl php7.4-gd php7.4-intl php7.4-mysql php7.4-xml php7.4-xmlrpc php7.4-ldap php7.4-zip php7.4-soap php7.4-mbstring</pre><br />
<br />
Restart Apache so that the modules are loaded correctly<br />
<br />
<pre>sudo service apache2 restart</pre><br />
<br />
We will be using [[Git]] to install/update the Moodle Core Application<br />
<br />
<pre>sudo apt install git</pre><br />
<br />
== Step 4: Download Moodle ==<br />
<br />
Setup your local repository and download Moodle, We will use /opt for this installation.<br />
<br />
*[[Git]] is what is called a "version control system". By using [[Git|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. <br />
<br />
<pre>cd /opt</pre><br />
<br />
Download the Moodle Code and Index<br />
<br />
<pre>sudo git clone git://git.moodle.org/moodle.git</pre><br />
<br />
Change directory into the downloaded Moodle folder<br />
<br />
<pre>cd moodle</pre><br /><br />
<br />
Retrieve a list of each branch available<br />
<br />
<pre>sudo git branch -a</pre><br />
<br />
Tell [[Git|git]] which branch to track or use<br />
<br />
<pre>sudo git branch --track MOODLE_39_STABLE origin/MOODLE_39_STABLE</pre><br />
<br />
Finally, Check out the Moodle version specified<br />
<br />
<pre>sudo git checkout MOODLE_39_STABLE</pre><br />
<br />
== Step 5: Copy local repository to /var/www/html/ ==<br />
<br />
<pre>sudo cp -R /opt/moodle /var/www/html/</pre><br /><br />
<pre>sudo mkdir /var/moodledata</pre><br /><br />
<pre>sudo chown -R www-data /var/moodledata</pre><br /><br />
<pre>sudo chmod -R 777 /var/moodledata</pre><br /><br />
<pre>sudo chmod -R 0755 /var/www/html/moodle</pre><br />
<br /><br />
* Explanation:<br />
<br /><br />
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|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.<br />
<br />
== Step 6: Setup MySQL Server ==<br />
<br />
First we need to change the default storage engine to innodb and change the default file format to Barracuda, this is a new setting compared to previous versions. You also need to set innodb_file_per_table in order for Barracuda to work properly. Ref: https://dev.mysql.com/doc/refman/5.7/en/innodb-compression-usage.html<br />
<br />
*You should not need to make innodb the default storage engine anymore, the latest version of Moodle will select it automatically during install. It is always a good idea to make it default anyway. You do however need to set the default file format!<br />
<br />
*If you chose to use VIM instead please substitute vi for vim<br />
<br />
<pre>sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf</pre><br />
<br />
Scroll down to the [mysqld] section and under Basic Settings add the following line under the last statement. if you want to add you have to press the "insert" button on your keyboard. this is usually above the "delete" button. this allows you to add some text.<br />
<br />
For MySQL Ver 8.0, the three settings below are not needed. <br />
<br />
<pre>default_storage_engine = innodb</pre><br /><br />
<pre>innodb_file_per_table = 1</pre><br /><br />
<pre>innodb_file_format = Barracuda</pre><br />
<br />
Note: If you use newer versions of MariaDB in Ubuntu 20.04 these changes in config file would arise and error (mysql unknown variable 'innodb_file_format=barracuda'), so comment or dont make these changes , these values are get by default.innodb_file_format was deprecated in MariaDB 10.2 and removed in MariaDB.<br />
<br />
In order to save my.cnf using the editor, press the Esc (Escape) key, type the following in sequence which will save :w then close the editor :q<br />
<br />
<pre>:w</pre><br /><br />
<pre>:q</pre><br />
<br />
Restart MySQL Server for changes to take affect<br />
<br />
<pre>sudo service mysql restart</pre><br />
<br />
Now we need to create the Moodle database and the Moodle MySQL User with the correct permissions<br />
<br />
Use the password you created in step 1<br />
<pre>sudo mysql -u root -p</pre><br /><br />
mysql><pre>CREATE DATABASE moodle DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;</pre><br />
<br />
{{Note| Use 'utf8mb4' for full range (4-byte) support of UTF-8, including Emoji ('utf8' only supports 3-byte). You will be compliant by Moodle admin page if you don't use 'utf8mb4' here.}}<br />
<br />
Where it says "moodledude" and "passwordformoodledude" you should change to the username and password of your choosing.<br />
mysql><pre>create user 'moodledude'@'localhost' IDENTIFIED BY 'passwordformoodledude';</pre><br /><br />
mysql><pre>GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,CREATE TEMPORARY TABLES,DROP,INDEX,ALTER ON moodle.* TO 'moodledude'@'localhost';</pre><br /><br />
mysql><pre>quit;</pre><br />
<br />
Note - If you are using MySQL 5.6+ and when you issue the create user and get an error about the password hash you need to adjust the password to use the hash value<br />
<br />
You can get this by following the below<br />
<br />
mysql><pre>SELECT password('passwordformoodledude');</pre><br /><br />
<br />
This will print the hash of the password like *AD51BAFB2GD003D3480BCED0DH81AB0BG1712535, you will want to use this in the IDENTIFIED BY ' part<br />
<br />
== Step 7: Complete Setup ==<br />
<br />
*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:<br />
<br />
<pre>sudo chmod -R 777 /var/www/html/moodle</pre><br />
<br />
After you have ran the installer and you have moodle setup, you NEED to revert permissions so that it is no longer writable using the below command.<br />
<br />
<pre>sudo chmod -R 0755 /var/www/html/moodle</pre><br />
<br />
Open your browser and go to http://IP.ADDRESS.OF.SERVER/moodle <br />
<br />
Follow the prompts:<br />
<br />
===Change the path for moodledata===<br />
<br />
/var/moodledata<br />
<br />
===Database Type===<br />
<br />
Choose: mysqli<br />
<br />
=== Database Settings ===<br />
<br />
Host server: localhost<br />
<br />
Database: moodle<br />
<br />
User: moodledude (the user you created when setting up the database)<br />
<br />
Password: passwordformoodledude (the password for the user you created)<br />
<br />
Tables Prefix: mdl_<br />
<br />
=== Environment Checks ===<br />
<br />
This will indicate if any elements required to run moodle haven't been installed.<br />
<br />
=== Next next next... ===<br />
follow prompts and confirm installation<br />
<br />
===Create a Site Administrator Account ===<br />
Create your moodle user account which will have site administrator permissions.<br />
<br />
The password you select has to meet certain security requirements.<br />
<br />
===Installation Complete ===<br />
Congrats! You can now start using Moodle!<br />
<br />
===Don't Forget===<br />
If you made the webroot writable, revert permissions<br />
<br />
<pre>sudo chmod -R 0755 /var/www/html/moodle</pre><br />
<br />
== System Paths After Install==<br />
After installing Moodle you should set the system paths, this will provide better performance VS not setting them. Each entry in Moodle will have it's explanation.<br />
<br />
Navigate, on the moodle webpage, to Site Administration > Server > System Paths<br />
<br />
Input the following;<br />
<br />
Path to du: /usr/bin/du<br />
<br />
Path to apsell: /usr/bin/aspell<br />
<br />
Path to dot: /usr/bin/dot<br />
<br />
Save Changes<br />
<br />
<br />
*Optional if you do not already have an AntiVirus Solution<br />
<br />
We also installed ClamAV in Step 3 so we need to set the path in Moodle<br />
<br />
1st Create the Quarantine Directory<br />
<pre>sudo mkdir /var/quarantine</pre><br />
Change Ownership<br />
<pre>sudo chown -R www-data /var/quarantine</pre><br />
<br />
Navigate to Site Administration > Plugins > Antivirus plugins > Manage antivirus plugins<br />
<br />
Enable ClamAV antivirus<br />
<br />
Click on Settings<br />
<br />
Set the proper settings<br />
<br />
Save changes<br />
<br />
In previous Moodle branches: <br />
Check "Use ClamAV on uploaded files"<br />
ClamAV Path : /usr/bin/clamscan<br />
Quarantine Directory : /var/quarantine<br />
<br />
Save Changes<br />
<br />
== Suggestions: Enable Zend OpCache/Change Document Root==<br />
<br />
*Since we have installed Ubuntu Server 20.04LTS, we can use the built-in PHP OPcache.<br />
<br />
Add [[OPcache#Configuration|the recommended OPcache settings]] to your 05-opcache.ini file. Again, substitute vi with vim and remember to use the correct key sequences from the introduction.<br />
<br />
<pre>sudo vi /etc/php7/apache2/conf.d/05-opcache.ini</pre><br />
<br />
NOTE: In Ubuntu 16.04 opcache.ini is located in:<br />
<br />
<pre>/etc/php/7.0/mods-available/opcache.ini</pre><br />
<br />
Restart Apache for changes to take affect.<br />
<br />
<pre>sudo service apache2 restart</pre><br />
<br />
That's it for the Zend OpCache!<br />
<br />
You can also install a GUI to view the status of your Zend OpCache, not recommended on production servers.<br />
<br />
<pre>cd /var/www/html/moodle/</pre><br />
<br />
Download the PHP Script to your Moodle directory, you should also add this file to /opt/moodle/.git/info/exclude file so it does not get removed when upgrading your installation.<br />
<br />
<pre>sudo wget https://github.com/rlerdorf/opcache-status/blob/master/opcache.php</pre><br />
<br />
Visit http://ip.address.of.server/moodle/opcache.php<br />
<br />
If you do not want your end users to type http://yourserver/moodle and just want them to navigate to http://youserver you will need to edit the site configuration for Apache which will tell Apache to use the /var/www/html/moodle as the root directory and not /var/www/html<br />
<br />
Open up the Apache sites config and change the document root<br />
<br />
<pre>sudo vi /etc/apache2/sites-available/000-default.conf</pre><br />
<br />
On the line where DocumentRoot is;<br />
<br />
<br>Change From: DocumentRoot /var/www/html<br><br />
<br>Change To: DocumentRoot /var/www/html/moodle<br><br />
<br />
<pre>:w</pre><br />
<pre>:q</pre><br />
<br />
Restart Apache for changes to take affect.<br />
<br />
<pre>sudo service apache2 restart</pre><br />
<br />
Important note!<br />
<br />
If you have already installed Moodle then you should make the below changes.<br />
<br />
== Editing config.php for moodle ==<br />
<br />
In the installation instructions, one of the suggested settings for 'webroot' is 'localhost'. This is fine if all you want to do is some local testing of your new Moodle installation. If, however, you want to view your new installation from another machine on the same local area network, or view your site on the Internet, you will have to change this setting:<br />
<br />
For local testing, 'localhost' is fine for the webroot ($CFG->wwwroot in config.php).<br />
If you want to test your site from other machines on the same local area network (LAN), then you will have to use the private ip address of the serving machine, (e.g. 192.168.1.2/moodle) or the network name of the serving computer (e.g. network_name_of_serving_machine/moodle) as the web root. Depending on your LAN setup, it may be better to use the network name of the computer rather than its (private) ip address, because the ip address can and will change from time to time. If you don't want to use the network name, then you will have to speak to your network administrator and have them assign a permanent ip address to the serving machine.<br />
Finally, if you want to test your new installation across the internet, you will have to use either a domain name or a permanent (public) ip address/moodle as your web root. To handle both types of access, see masquerading.<br />
<br />
<br />
Edit config.php for Moodle<br />
<br />
cd /var/www/html/moodle<br />
sudo vim config.php<br />
<br />
Hit the "insert" button on your keyboard, make then changes you need to make. Then press "escape" and type the following in to quit and to save changes (excluding quotation marks): ":wq"<br />
<br />
Under $CFG->wwwroot change to http://ip.address.of.server instead of http://ip.address.of.server/moodle<br />
<br />
<br />
==Hosting several Moodle branches in one Ubuntu server==<br />
* This is very useful for the language pack maintainers to test translations in several Moodle branches.<br />
* It is also very useful for developers to test their plugins in different Moodle branches.<br />
* Just create a folder for each instance inside the web folder and that would be enough. <br />
* To access the sites you only need to add the folder to localhost URL: http://localhost/moodle31<br />
* You can have an instance for each version from 1.9 to 3.1 <br />
<br />
* You do need a separate data folder for each instance and a separate database (You can use phpmyadmin to set your database, but that's not necessary), add each instance in its own folder, and carry on as above. You can also host another service (eg, Mahara) in it's separate folder.<br />
<br />
===Example 1===<br />
*So, one example folder tree on one Linux laptop (an actual server would be more) may look something like:<br />
<br />
var<br />
--www<br />
----maharadata<br />
----moodlecleandata<br />
----moodlestabledata<br />
----moodlemasterdata<br />
----moodletestingdata<br />
----uswmoodledata<br />
----html<br />
------mahara<br />
------moodleclean<br />
------moodlestable<br />
------moodlemaster<br />
------moodletesting<br />
------uswmoodle<br />
<br />
===Example 2===<br />
* Have several sandboxed Moodles on a single (CentOS X) server all of different versions .. only the ones that are supported for security fixes and above - 2.7,2.8,2.9,3.0, and now a 3.1. Pretty much 'stock' Moodles with only occasional addons, etc. for testing.<br />
* All have their separate code and data directories as well as their separate DB's.<br />
<br />
* Hint: install and maintain them all with [[Git_for_Administrators|git]] ... even if you don't prefer/like command line, that is by far the most efficient way to update and/or upgrade a site.<br />
<br />
/var/www/html/moodle27/version.php:$release = '2.7.14 (Build: 20160509)'<br />
/var/www/html/moodle28/version.php:$release = '2.8.12 (Build: 20160509)'<br />
/var/www/html/moodle29/version.php:$release = '2.9.6+ (Build: 20160520)'<br />
/var/www/html/moodle30/version.php:$release = '3.0.4+ (Build: 20160603)'<br />
/var/www/html/moodle31/version.php:$release = '3.1+ (Build: 20160603)'<br />
<br />
* The git -b command locks a site into the version provided with the rest of the git command ... for example, installing the 3.1, which is a long term support version, installed with git -b option. Don't plan on upgrading nor testing upgrades with that one.<br />
<br />
git clone -b MOODLE_31_STABLE git://git.moodle.org/moodle.git moodle31<br />
<br />
* All the other moodles I have on that server have been installed via git <br />
<br />
git clone git://git.moodle.org/moodle.git [nameofdir]<br />
<br />
* then from nameofdir<br />
<br />
git branch --track MOODLE_2#_STABLE origin/MOODLE_2#_STABLE<br />
git checkout MOODLE_2#_STABLE<br />
<br />
* 2# is the version number.<br />
<br />
* That allows one to march that moodle upwards ... higher branch(es). So one can test an upgrade (as opposed to an 'update').<br />
<br />
* This second method 'gits' more code and backups will range in the 5+ Meg range due to all the older version git stuff The 3.1 much less (restricted to 3.1 branch):<br />
<br />
* 545M ./moodle296-code-20160604145012.tar<br />
<br />
* 193M ./moodle31+-code-2016060883737.tar<br />
<br />
==See also==<br />
*[[Installation on Ubuntu using Git]]<br />
<br />
[[es:Guia de instalacion paso-a-paso para Ubuntu 16.04]]</div>Leonstrhttps://docs.moodle.org/310/en/index.php?title=Activity_completion_report&diff=140463Activity completion report2021-06-11T08:08:57Z<p>Leonstr: /* Key */ Improve table style</p>
<hr />
<div>{{Course reports}}<br />
Activity completion info can be viewed by managers, teachers and non-editing teachers (and any other users with the capability [[Capabilities/report/progress:view|report/progress:view]]) by clicking the gear icon top right and selecting "More > Reports > Activity completion" (with the Boost theme) or from ''Course administration > Reports > Activity completion'' with non-Boost themes.<br />
<br />
Teachers can mark activities complete on behalf of students by clicking into the relevant completion boxes. This requires the capability [[Capabilities/moodle/course:overridecompletion|Override activity completion status]] which is enabled for editing and non-editing teachers by default.<br />
<br />
[[File:TAC.png]]<br />
<br />
=== Key ===<br />
<br />
{|class="wikitable"<br />
!colspan="3" style="text-align:left"|Automatic versus manual completion<br />
|-<br />
|[[File:completion-auto-n.svg|16x16px|Dashed line box]]<br />
|Box with dashed line<br />
|Activity is completed automatically. For example: a quiz with ''Completion tracking'' set to "Show activity as complete when conditions are met".<br />
|-<br />
|[[File:completion-manual-n.svg|16x16px|Solid line box]]<br />
|Box with solid line<br />
|Activity is completed manually by learner. For example: a file with ''Completion tracking'' set to "Students can manually mark the activity as completed".<br />
|-<br />
!colspan="3" style="text-align:left"|Completion status<br />
|-<br />
|[[File:completion-auto-n.svg|16x16px|Dashed line box]] [[File:completion-manual-n.svg|16x16px|Solid line box]]<br />
|Empty box<br />
|Activity not complete.<br />
|-<br />
|[[File:completion-auto-y.svg|16x16px|Dashed line box, blue tick]] [[File:completion-manual-y.svg|16x16px|Solid line box, blue tick]]<br />
|Blue tick<br />
|Activity completed and no passing grade applies. For example: passing grade does not apply to this activity type, or passing grade has not been set as part of the activity's completion criteria.<br />
|-<br />
|[[File:completion-auto-pass.svg|16x16px|Dashed line box, green tick]]<br />
|Green tick<br />
|Completed, activity has passing grade which was achieved.<br />
|-<br />
|[[File:completion-auto-fail.svg|16x16px|Dashed line box, red cross]]<br />
|Red cross<br />
|Activity not completed and completion not possible. For example: all quiz attempts have been used without achieving the passing grade.<br />
|-<br />
!colspan="3" style="text-align:left"|Override completion status<br />
|-<br />
|[[File:completion-auto-y-override.svg|16x16px|Dashed red line box, blue tick]] [[File:completion-manual-y-override.svg|16x16px|Solid red line box, blue tick]] [[File:completion-manual-n-override.svg|16x16px|Solid red line box, empty]]<br />
|Box with red line<br />
|Completion status has been manually set by teacher, manager or site administrator.<br />
|}<br />
<br />
[[Category: Completion]]<br />
<br />
[[es:Reporte de finalización de actividad]]</div>Leonstrhttps://docs.moodle.org/310/en/index.php?title=File:completion-manual-n-override.svg&diff=140462File:completion-manual-n-override.svg2021-06-10T14:48:07Z<p>Leonstr: </p>
<hr />
<div></div>Leonstrhttps://docs.moodle.org/310/en/index.php?title=File:completion-manual-y-override.svg&diff=140461File:completion-manual-y-override.svg2021-06-10T14:47:48Z<p>Leonstr: </p>
<hr />
<div></div>Leonstrhttps://docs.moodle.org/310/en/index.php?title=File:completion-auto-y-override.svg&diff=140460File:completion-auto-y-override.svg2021-06-10T14:47:23Z<p>Leonstr: </p>
<hr />
<div></div>Leonstrhttps://docs.moodle.org/310/en/index.php?title=Activity_completion_report&diff=140459Activity completion report2021-06-10T14:46:49Z<p>Leonstr: Added key listing report's icons and their meanings</p>
<hr />
<div>{{Course reports}}<br />
Activity completion info can be viewed by managers, teachers and non-editing teachers (and any other users with the capability [[Capabilities/report/progress:view|report/progress:view]]) by clicking the gear icon top right and selecting "More > Reports > Activity completion" (with the Boost theme) or from ''Course administration > Reports > Activity completion'' with non-Boost themes.<br />
<br />
Teachers can mark activities complete on behalf of students by clicking into the relevant completion boxes. This requires the capability [[Capabilities/moodle/course:overridecompletion|Override activity completion status]] which is enabled for editing and non-editing teachers by default.<br />
<br />
[[File:TAC.png]]<br />
<br />
=== Key ===<br />
<br />
{|<br />
!colspan="3" style="text-align:left"|Automatic versus manual completion<br />
|-<br />
|[[File:completion-auto-n.svg|16x16px|Dashed line box]]<br />
|Box with dashed line<br />
|Activity is completed automatically. For example: a quiz with ''Completion tracking'' set to "Show activity as complete when conditions are met".<br />
|-<br />
|[[File:completion-manual-n.svg|16x16px|Solid line box]]<br />
|Box with solid line<br />
|Activity is completed manually by learner. For example: a file with ''Completion tracking'' set to "Students can manually mark the activity as completed".<br />
|-<br />
!colspan="3" style="text-align:left"|Completion status<br />
|-<br />
|[[File:completion-auto-n.svg|16x16px|Dashed line box]] [[File:completion-manual-n.svg|16x16px|Solid line box]]<br />
|Empty box<br />
|Activity not complete.<br />
|-<br />
|[[File:completion-auto-y.svg|16x16px|Dashed line box, blue tick]] [[File:completion-manual-y.svg|16x16px|Solid line box, blue tick]]<br />
|Blue tick<br />
|Activity completed and no passing grade applies. For example: passing grade does not apply to this activity type, or passing grade has not been set as part of the activity's completion criteria.<br />
|-<br />
|[[File:completion-auto-pass.svg|16x16px|Dashed line box, green tick]]<br />
|Green tick<br />
|Completed, activity has passing grade which was achieved.<br />
|-<br />
|[[File:completion-auto-fail.svg|16x16px|Dashed line box, red cross]]<br />
|Red cross<br />
|Activity not completed and completion not possible. For example: all quiz attempts have been used without achieving the passing grade.<br />
|-<br />
!colspan="3" style="text-align:left"|Override completion status<br />
|-<br />
|[[File:completion-auto-y-override.svg|16x16px|Dashed red line box, blue tick]] [[File:completion-manual-y-override.svg|16x16px|Solid red line box, blue tick]] [[File:completion-manual-n-override.svg|16x16px|Solid red line box, empty]]<br />
|Box with red line<br />
|Completion status has been manually set by teacher, manager or site administrator.<br />
|}<br />
<br />
[[Category: Completion]]<br />
<br />
[[es:Reporte de finalización de actividad]]</div>Leonstrhttps://docs.moodle.org/310/en/index.php?title=Performance_recommendations&diff=140449Performance recommendations2021-05-30T17:42:21Z<p>Leonstr: /* X-Sendfile */ Spelling correction</p>
<hr />
<div>{{Performance}}<br />
Moodle can be made to perform very well, at small usage levels or scaling up to many thousands of users. The factors involved in performance are basically the same as for any PHP-based database-driven system. When trying to optimize your server, try to focus on the factor which will make the most difference to the user. For example, if you have relatively more users browsing than accessing the database, look to improve the webserver performance.<br />
<br />
<br />
==Obtain a baseline benchmark==<br />
<br />
Before attempting any optimization, you should obtain a baseline benchmark of the component of the system you are trying to improve. For Linux try [http://lbs.sourceforge.net/ LBS] and for Windows use the Performance Monitor. Once you have quantitative data about how your system is performing currently, you'll be able to determine if the change you have made has had any real impact.<br />
<br />
The overall aim of adjustments to improve performance is to use RAM (cacheing) and to reduce disk-based activity. It is especially important to try to eliminate swap file usage as much as you can. If your system starts swapping, this is a sign that you need more RAM. <br />
<br />
The '''optimization order preference''' is usually: primary storage (more RAM), secondary storage (faster hard disks/improved hard disk configuration), processor (more and faster).<br />
<br />
It can be interesting to install and use the [https://moodle.org/plugins/report_benchmark Benchmark plugin] in order to find the bottlenecks of your system that specifically affect Moodle.<br />
<br />
==Scalability==<br />
<br />
Moodle's design (with clear separation of application layers) allows for strongly scalable setups. (Please check the list of [[Large installations|large Moodle installations]].)<br />
<br />
Large sites usually separate the web server and database onto separate servers, although for smaller installations this is typically not necessary.<br />
<br />
It is possible to load-balance a Moodle installation, for example by using more than one webserver. The separate webservers should query the same database and refer to the same filestore and cache areas (see [[Caching]]), but otherwise the separation of the application layers is complete enough to make this kind of clustering feasible. Similarly, the database could be a cluster of servers (e.g. a MySQL cluster), but this is not an easy task and you should seek expert support, e.g. from a Moodle Partner.<br />
<br />
On very large, load-balanced, systems the performance of the shared components become critical. It's important that your shared file areas are properly tuned and that you use an effective cache (Redis is highly recommended). A good understanding of these areas of system administration should be considered a minimum requirement. <br />
<br />
===Server cluster===<br />
<br />
Using Moodle forum discussions:<br />
<br />
*[http://moodle.org/mod/forum/discuss.php?d=57202 Moodle clustering]<br />
*[http://moodle.org/mod/forum/discuss.php?d=44470 Software load balancing]<br />
*[http://moodle.org/mod/forum/discuss.php?d=49986 TCP load balancing]<br />
*[http://moodle.org/mod/forum/discuss.php?d=88214 Installation for 3000 simultaneous users]<br />
<br />
==Hardware configuration==<br />
'''Note''': The fastest and most effective change that you can make to improve performance is to '''increase the amount of RAM on your web server''' - get as much as possible (e.g. 4GB or more). Increasing primary memory will reduce the need for processes to swap to disk and will enable your server to handle more users.<br />
* Better performance is gained by obtaining the best '''processor capability''' you can, i.e. dual or dual core processors. A modern BIOS should allow you to enable hyperthreading, but check if this makes a difference to the overall performance of the processors by using a [http://en.wikipedia.org/wiki/Super_PI CPU benchmarking tool].<br />
* If you can afford them, use '''SCSI hard disks''' instead of SATA drives. SATA drives will increase your system's CPU utilization, whereas SCSI drives have their own integrated processors and come into their own when you have multiple drives. If you must have SATA drives, check that your motherboard and the drives themselves support NCQ (Native Command Queuing).<br />
* Purchase hard disks with a '''low seek time'''. This will improve the overall speed of your system, especially when accessing Moodle's reports.<br />
* Size your '''swap file''' correctly. The general advice is to set it to 4 x physical RAM.<br />
* Use a '''RAID disk system'''. Although there are many different RAID configurations you can create, the following generally works best:<br />
** install a hardware RAID controller (if you can)<br />
** the operating system and swap drive on one set of disks configured as RAID-1.<br />
** Moodle, Web server and Database server on another set of disks configured as RAID-5.<br />
* If your 'moodledata' area is going to be on relatively slow storage (e.g. NFS mount on to a NAS device) you will have performance issues with the default cache configuration (which writes to this storage). See the page on [[Caching]] and choose an alternative. Redis is recommended. Using [https://en.wikipedia.org/wiki/GlusterFS GlusterFS] / [https://en.wikipedia.org/wiki/OCFS2 OCFS2] / [https://en.wikipedia.org/wiki/GFS2 GFS2] on a [https://en.wikipedia.org/wiki/Storage_Area_Network SAN] device and [https://en.wikipedia.org/wiki/Fibre_Channel Fiber Channel] could improve performance (See more info on the Moodle [https://moodle.org/mod/forum/discuss.php?d=214680#p1123124 forum thread], [https://moodle.org/mod/forum/discuss.php?d=310501#p1242382 NFS performance tuing] )<br />
* Use '''gigabit ethernet''' for improved latency and throughput. This is especially important when you have your webserver and database server separated out on different hosts.<br />
* Check the settings on your '''network card'''. You may get an improvement in performance by increasing the use of buffers and transmit/receive descriptors (balance this with processor and memory overheads) and off-loading TCP checksum calculation onto the card instead of the OS.<br />
* Read this [http://moodle.org/mod/forum/discuss.php?d=68579 Case Study] on a server stress test with 300 users. <br />
* See this [http://elearning.sgu.ac.jp/doc/PT/ accompanying report] on network traffic and server loads.<br />
* Also see this SFSU presentation at Educause (using VMWare): [http://www.educause.edu/Resources/AnOpenSourceLMSforaMissionCrit/162843]<br />
<br />
==Operating System==<br />
* You can use [http://en.wikipedia.org/wiki/Linux Linux](recommended), Unix-based, Windows or Mac OS X for the server '''operating system'''. *nix operating systems generally require less memory than Mac OS X or Windows servers for doing the same task as the server is configured with just a shell interface. Additionally Linux does not have licensing fees attached, but can have a big learning curve if you're used to another operating system. If you have a large number of processors running SMP, you may also want to consider using a highly tuned OS such as [http://en.wikipedia.org/wiki/Solaris_Operating_Environment Solaris].<br />
* Check your own OS and '''vendor specific instructions''' for optimization steps.<br />
** For Linux look at the [http://linuxperf.sourceforge.net/ Linux Performance Team] site. <br />
** For Linux investigate the hdparm command, e.g. hdparm -m16 -d1 can be used to enable read/write on multiple sectors and DMA. Mount disks with the [https://moodle.org/mod/forum/discuss.php?d=310501#p1242382 "async" and "noatime"] options.<br />
** For Windows set the sever to be optimized for network applications (Control Panel, Network Connections, LAN connection, Properties, File & Printer Sharing for Microsoft Networks, Properties, Optimization). You can also search the [http://technet.microsoft.com/ Microsoft TechNet site] for optimization documents.<br />
<br />
==Web server performance==<br />
<br />
Installing [http://www.mozilla.com/en-US/ Firefox] and the [https://addons.mozilla.org/en-US/firefox/addon/1843 firebug] extension will allow you to watch the time it takes for each page component to load. Also, the [https://addons.mozilla.org/en-US/firefox/addon/5369 Yslow] extension will evaluate your page against Yahoo's [http://www.skrenta.com/2007/05/14_rules_for_fast_web_pages_by_1.html 14 rules], full text [http://developer.yahoo.com/performance/rules.html Best Practices for Speeding Up Your Web Site], <strike>([http://video.yahoo.com/video/play?vid=1040890 video])</strike> for fast loading websites.<br />
<br />
===PHP performance===<br />
* PHP contains a built-in accelerator. Make sure it is enabled. <br />
* Improvements in read/write performance can be improved by putting the cached PHP pages on a [[TMPFS]] filesystem - but remember that you'll lose the cache contents when there is a power failure or the server is rebooted.<br />
* Performance of PHP is better when installed as an '''Apache/IIS6 ISAPI module''' (rather than a CGI). IIS 7.0/7.5 (Windows Server 2008/R2) users should choose a FastCGI installation for best performance.<br />
* Also check the '''memory_limit''' in php.ini. The default value for the memory_limit directive is 128M. On some sites, it may need to be larger - especially for some backup operations. <br />
* Also see [[PHP_settings_by_Moodle_version]]<br />
* Use [http://blog.bitnami.com/2014/06/performance-enhacements-for-apache-and.html PHP-FPM] (with apache).<br />
<br />
===Install HowTo===<br />
==== APC ====<br />
* [http://2bits.com/articles/installing-php-apc-gnulinux-centos-5.html APC on CentOS 5.x (linux)]<br />
* [http://fplanque.com/dev/linux/install-apc-php-cache-debian-lenny APC on Debian (linux)]<br />
==== eAccelerator ====<br />
* [http://noveckg.blogspot.com/2010/02/installing-eaccelerator-cache-for-php.html Installing eAccelerator on CentOS 5.x (linux)]<br />
* [https://docs.moodle.org/en/Installing_eAccelerator_In_Ubuntu_Server/ Installing eAccelerator on Ubuntu Server (linux)]<br />
==== MemCached ====<br />
Memcached server (daemon)<br />
* [https://www.tecmint.com/install-memcached-on-centos-7/ Installing Memcached on CentOS 7.x (linux)] (as of php 7.x, only memcached is available)<br />
* [https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-memcached-on-centos-7 How To Install and Secure Memcached on CentOS 7]<br />
* [https://wiki.zimbra.com/wiki/Blocking_Memcached_Attack#Iptables_rules_for_Redhat_based_servers Iptables rules for Redhat based servers]<br />
Memcached PHP 7.1 extension <br />
* [https://dl.iuscommunity.org/pub/ius/stable/CentOS/7/x86_64/repoview/php71u-pecl-memcached.html php71u-pecl-memcached] from IUS CentOS 7.x repository.<br />
<br />
===Apache performance===<br />
* If you are using Apache on a Windows server, use the build from [http://www.apachelounge.com Apache Lounge] which is reported to have [http://moodle.org/mod/forum/discuss.php?d=93358 performance and stability improvements] compared to the official Apache download. Note that this is an unofficial build, so may not keep up with official releases.<br />
* Set the '''MaxRequestWorkers''' directive correctly ('''MaxClients''' before Apache 2.4). Use this formula to help (which uses 80% of available memory to leave room for spare):<br />
MaxRequestWorkers = Total available memory * 80% / Max memory usage of apache process<br />
:Memory usage of apache process is usually 10MB but Moodle can easily use up to 100MB per process, so a general rule of thumb is to divide your available memory in megabytes by 100 to get a conservative setting for MaxClients. You are quite likely to find yourself lowering the MaxRequestWorkers from its default of 150 on a Moodle server. To get a more accurate estimate read the value from the shell command:<br />
#ps -ylC httpd --sort:rss<br />
<br />
:If you need to increase the value of '''MaxRequestWorkers''' beyond 256, you will also need to set the '''ServerLimit''' directive. <br />
<br />
:'''Warning''': Do not be tempted to set the value of MaxRequestWorkers higher than your available memory as your server will consume more RAM than available and start to swap to disk. <br />
* Consider reducing the '''number of modules''' that Apache loads in the httpd.conf file to the minumum necessary to reduce the memory needed. <br />
* Use the '''latest version of Apache''' - Apache 2 has an improved memory model which reduces memory usage further.<br />
* For Unix/Linux systems, consider lowering '''MaxConnectionsPerChild''' ('''MaxRequestsPerChild''' before Apache 2.4) in httpd.conf to as low as 20-30 (if you set it any lower the overhead of forking begins to outweigh the benefits). <br />
* For a heavily loaded server, consider setting '''KeepAlive Off''' (do this only if your Moodle pages do not contain links to resources or uploaded images) or lowering the '''KeepAliveTimeout''' to between 2 and 5. The default is 15 (seconds) - the higher the value the more server processes will be kept waiting for possibly idle connections. A more accurate value for KeepAliveTimeout is obtained by observing how long it takes your users to download a page. After altering any of the KeepAlive variables, monitor your CPU utilization as there may be an additional overhead in initiating more worker processes/threads.<br />
* As an alternative to using KeepAlive Off, consider setting-up a '''Reverse Proxy server''' infront of the Moodle server to cache HTML files with images. You can then return Apache to using keep-alives on the Moodle server.<br />
* If you do not use a .htaccess file, set the '''AllowOverride''' variable to AllowOverride None to prevent .htaccess lookups.<br />
* Set '''DirectoryIndex''' correctly so as to avoid content-negotiation. Here's an example from a production server:<br />
DirectoryIndex index.php index.html index.htm<br />
* Unless you are doing development work on the server, set '''ExtendedStatus Off''' and disable mod_info as well as mod_status.<br />
* Leave '''HostnameLookups Off''' (as default) to reduce DNS latency.<br />
* Consider reducing the value of '''TimeOut''' to between 30 to 60 (seconds). <br />
* For the '''Options directive''', avoid Options Multiviews as this performs a directory scan. To reduce disk I/O further use<br />
Options -Indexes FollowSymLinks<br />
<br />
* Compression reduces response times by reducing the size of the HTTP response<br />
# Install and enable mod_deflate - refer to documentation or man pages<br />
# Add this code to the virtual server config file within the <directory> section for the root directory (or within the .htaccess file if AllowOverrides is On):<br />
<ifModule mod_deflate.c><br />
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/x-js text/javascript text/css application/javascript<br />
</ifmodule><br />
* Use Apache [http://blog.bitnami.com/2014/06/performance-enhacements-for-apache-and.html event] [http://httpd.apache.org/docs/current/mpm.html MPM] (and not the default Prefork or Worker)<br />
<br />
===IIS performance===<br />
All alter this location in the registry:<br />
HKLM\SYSTEM\CurrentControlSet\Services\Inetinfo\Parameters\<br />
* The equivalent to KeepAliveTimeout is '''ListenBackLog''' (IIS - registry location is HKLM\ SYSTEM\ CurrentControlSet\ Services\ Inetinfo\ Parameters). Set this to between 2 to 5.<br />
*Change the '''MemCacheSize''' value to adjust the amount of memory (Mb) that IIS will use for its file cache (50% of available memory by default).<br />
*Change the '''MaxCachedFileSize''' to adjust the maximum size of a file cached in the file cache in bytes. Default is 262,144 (256K).<br />
*Create a new DWORD called '''ObjectCacheTTL''' to change the length of time (in milliseconds) that objects in the cache are held in memory. Default is 30,000 milliseconds (30 seconds).<br />
<br />
===Lighttpd, NginX and Cherokee performance===<br />
You can increase server performance by using a '''light-weight''' webserver like [http://www.lighttpd.net/ lighttpd], [http://nginx.net/ nginx] or [http://www.cherokee-project.com/ cherokee] in combination with PHP in FastCGI-mode. Lighttpd was originally created as a proof-of-concept[http://www.lighttpd.net/story] to address the [http://www.kegel.com/c10k.html C10k problem] and while primarily recommended for memory-limited servers, its design origins and asynchronous-IO model make it a suitable and proven[http://blog.lighttpd.net/articles/2006/12/28/lighttpd-powers-5-alexa-top-250-sites] alternative HTTP server for high-load websites and web apps, including Moodle. See the [[lighttpd | MoodleDocs Lighttpd page]] for additional information, configuration example and links.<br />
<br />
Alternatively, both [http://www.lighttpd.net/ lighttpd] and [http://nginx.net/ nginx] are capable of performing as a load-balancer and/or reverse-proxy to alleviate load on back-end servers[http://www.linuxjournal.com/article/10108], providing benefit without requiring an actual software change on existing servers.<br />
<br />
Do note that these are likely to be the least tested server environments of all particularly if you are using advanced features such as web services and/or Moodle Networking. They are probably best considered for heavily used Moodle sites with relatively simple configurations.<br />
<br />
===X-Sendfile===<br />
<br />
X-Sendfile modules improve performance when sending large files from Moodle. It is recommended to configure your web server and Moodle to use this feature if available.<br />
<br />
Configure web server:<br />
* Apache - https://tn123.org/mod_xsendfile/<br />
* Lighttpd - http://redmine.lighttpd.net/projects/lighttpd/wiki/X-LIGHTTPD-send-file<br />
* Nginx - http://wiki.nginx.org/XSendfile<br />
<br />
Enable support in config.php (see config-dist.php):<br />
<code php><br />
// $CFG->xsendfile = 'X-Sendfile'; // Apache {@see https://tn123.org/mod_xsendfile/}<br />
// $CFG->xsendfile = 'X-LIGHTTPD-send-file'; // Lighttpd {@see http://redmine.lighttpd.net/projects/lighttpd/wiki/X-LIGHTTPD-send-file}<br />
// $CFG->xsendfile = 'X-Accel-Redirect'; // Nginx {@see http://wiki.nginx.org/XSendfile}<br />
</code><br />
<br />
Configure file location prefixes if your server implementation requires it:<br />
<code php><br />
// $CFG->xsendfilealiases = array(<br />
// '/dataroot/' => $CFG->dataroot,<br />
// '/cachedir/' => '/var/www/moodle/cache', // for custom $CFG->cachedir locations<br />
// '/localcachedir/' => '/var/local/cache', // for custom $CFG->localcachedir locations<br />
// '/tempdir/' => '/var/www/moodle/temp', // for custom $CFG->tempdir locations<br />
// '/filedir' => '/var/www/moodle/filedir', // for custom $CFG->filedir locations<br />
// );<br />
</code><br />
<br />
== Cron performance ==<br />
<br />
Cron is a very important part of the overall performance of moodle as many asynchronous processes are offloaded to cron, so it needs to be running and have enough through put to handle the work being given to it by the front ends.<br />
<br />
See [[Cron_with_Unix_or_Linux#High_performance_cron_tasks]]<br />
<br />
==Database performance==<br />
<br />
===MySQL performance===<br />
<br />
The '''number one thing''' you can do to improve MySQL performance is to read, understand and implement the recommendations in the [https://dev.mysql.com/doc/refman/5.7/en/innodb-buffer-pool.html Innodb Buffer Pool] article.<br />
<br />
The [https://dev.mysql.com/doc/refman/5.7/en/innodb-buffer-pool-resize.html buffer pool size] can safely be changed while your server is running, as long as your server has enough memory (RAM) to accommodate the value you set. On a machine that is dedicated to MySQL, you can safely set this value to 80% of available memory.<br />
<br />
Consider setting [https://dev.mysql.com/doc/refman/5.7/en/innodb-parameters.html#sysvar_innodb_buffer_pool_instances innodb_buffer_pool_instances] to the number of cores, vCPUs, or chips you have available. Adjust this value in accordance with the recommendations in the [https://dev.mysql.com/doc/refman/5.7/en/innodb-buffer-pool-resize.html MySQL documentation].<br />
<br />
The following are MySQL specific settings which can be adjusted for better performance in your my.cnf (my.ini in Windows). The file contains a list of settings and their values. To see the current values use these commands<br />
SHOW STATUS;<br />
SHOW VARIABLES; <br />
'''Important''': You must make backups of your database before attempting to change any MySQL server configuration. After any change to the my.cnf, restart mysqld.<br />
<br />
If you are able, the [http://mysqltuner.pl/ MySQLTuner] tool can be run against your MySQL server and will calculate appropriate configuration values for most of the following settings based on your current load, status and variables automatically.<br />
<br />
* Enable the '''query cache''' with <br />
query_cache_type = 1. <br />
For most Moodle installs, set the following:<br />
query_cache_size = 36M <br />
query_cache_min_res_unit = 2K. <br />
The query cache will improve performance if you are doing few updates on the database. <br />
* Set the '''table cache''' correctly. For Moodle 1.6 set <br />
table_cache = 256 #(table_open_cache in MySQL > 5.1.2)<br />
(min), and for Moodle 1.7 set <br />
table_cache = 512 #(table_open_cache in MySQL > 5.1.2)<br />
(min). The table cache is used by all threads (connections), so monitor the value of opened_tables to further adjust - if opened_tables > 3 * table_cache(table_open_cache in MySQL > 5.1.2) then increase table_cache upto your OS limit. Note also that the figure for table_cache will also change depending on the number of modules and plugins you have installed. Find the number for your server by executing the mysql statement below. Look at the number returned and set table_cache to this value.<br />
mysql>SELECT COUNT(table_name) FROM information_schema.tables WHERE table_schema='yourmoodledbname';<br />
* Set the '''thread cache''' correctly. Adjust the value so that your thread cache utilization is as close to 100% as possible by this formula:<br />
thread cache utilization (%) = (threads_created / connections) * 100<br />
* The '''key buffer''' can improve the access speed to Moodle's SELECT queries. The correct size depends on the size of the index files (.myi) and in Moodle 1.6 or later (without any additional modules and plugins), the recommendation for this value is key_buffer_size = 32M. Ideally you want the database to be reading once from the disk for every 100 requests so monitor that the value is suitable for your install by adjusting the value of key_buffer_size so that the following formulas are true:<br />
key_read / key_read_requests < 0.01<br />
key_write / key_write_requests <= 1.0<br />
* Set the '''maximum number of connections''' so that your users will not see a "Too many connections" message. Be careful that this may have an impact on the total memory used. MySQL connections usually last for milliseconds, so it is unusual even for a heavily loaded server for this value to be over 200.<br />
* Manage '''high burst activity'''. If your Moodle install uses a lot of quizzes and you are experiencing performance problems (check by monitoring the value of threads_connected - it should not be rising) consider increasing the value of back_log.<br />
* '''Optimize your tables weekly and after upgrading Moodle'''. It is good practice to also optimize your tables after performing a large data deletion exercise, e.g. at the end of your semester or academic year. This will ensure that index files are up to date. Backup your database first and then use:<br />
mysql>CHECK TABLE mdl_tablename;<br />
mysql>OPTIMIZE TABLE mdl_tablename;<br />
:The common tables in Moodle to check are mdl_course_sections, mdl_forum_posts, mdl_log and mdl_sessions (if using dbsessions). Any errors need to be corrected using REPAIR TABLE (see the [http://dev.mysql.com/doc/refman/5.0/en/repair-table.html MySQL manual] and this [http://moodle.org/mod/forum/discuss.php?d=58208#p279638 forum script]).<br />
* '''Maintain the key distribution'''. Every month or so it is a good idea to stop the mysql server and run these myisamchk commands.<br />
#myisamchk -a -S /pathtomysql/data/moodledir/*.MYI<br />
:'''Warning''': You must stop the mysql database process (mysqld) before running any myisamchk command. If you do not, you risk data loss.<br />
* Reduce the number of '''temporary tables saved to disk'''. Check this with the created_tmp_disk_tables value. If this is relatively large (>5%) increase tmp_table_size until you see a reduction. Note that this will have an impact on RAM usage.<br />
<br />
===PostgreSQL performance===<br />
<br />
There are some good papers around on tuning PostgreSQL (like [http://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server this one]), and Moodle's case does not seem to be different to the general case.<br />
<br />
The first thing to recognise is that if you really need to worry about tuning you should be using a separate machine for the database server. If you are not using a separate machine then the answers to many performance questions are substantially muddied by the memory requirements of the rest of the application.<br />
<br />
You should probably '''enable autovacuum''', unless you know what you are doing. Many e-learning sites have predictable periods of low use, so disabling autovacuum and running a specific vacuum at those times can be a good option. Or perhaps leave autovacuum running but do a full vacuum weekly in a quiet period.<br />
<br />
Set '''shared_buffers''' to something reasonable. For versions up to 8.1 my testing has shown that peak performance is almost always obtained with buffers < 10000, so if you are using such a version, and have more than 512M of RAM just set shared_buffers to 10,000 (8MB).<br />
<br />
The buffer management had a big overhaul in 8.2 and "reasonable" is now a much larger number. I have not conducted performance tests with 8.2, but the recommendations from others are generally that you should now scale shared_buffers much more with memory and may continue to reap benefits even up to values like 100,000 (80MB). Consider using 1-2% of system RAM.<br />
<br />
PostgreSQL will also assume that the operating system is caching its files, so setting '''effective_cache_size''' to a reasonable value is also a good idea. A reasonable value will usually be (total RAM - RAM in use by programs). If you are running Linux and leave the system running for a day or two you can look at 'free' and under the 'cached' column you will see what it currently is. Consider taking that number (which is kB) and dividing it by 10 (i.e. allow 20% for other programs cache needs and then divide by 8 to get pages). If you are not using a dedicated database server you will need to decrease that value to account for usage by other programs.<br />
<br />
Some other useful parameters that can have positive effects, and the values I would typically set them to on a machine with 4G RAM, are:<br />
<br />
work_mem = 10240<br />
<br />
That's 10M of RAM to use instead of on-disk sorting and so forth. That can give a big speed increase, but it is per connection and 200 connections * 10M is 2G, so it can theoretically chew up a lot of RAM.<br />
<br />
maintenance_work_mem = 163840<br />
<br />
That's 160M of RAM which will be used by (e.g.) VACUUM, index rebuild, cluster and so forth. This should only be used periodically and should be freed when those processes exit, so I believe it is well worth while.<br />
<br />
wal_buffers = 64<br />
<br />
These buffers are used for the write-ahead log, and there have been a number of reports on the PostgreSQL mailing lists of improvement from this level of increase.<br />
<br />
This is a little out of date now (version 8.0) but still worth a read: http://www.powerpostgresql.com/Docs<br />
<br />
And there is lots of good stuff here as well: http://www.varlena.com/GeneralBits/Tidbits/index.php<br />
<br />
''Based on Andrew McMillan's post at [http://moodle.org/mod/forum/discuss.php?d=68558 Tuning PostgreSQL] forum thread.''<br />
<br />
* Splitting '''mdl_log''' to several tables and using a VIEW with UNION to read them as one. (See Tim Hunt [https://moodle.org/mod/forum/discuss.php?d=243531#p1104165 explanation] on the Moodle forums)<br />
<br />
===Other database performance links===<br />
* Consider using a '''distributed cacheing system''' like [http://en.wikipedia.org/wiki/Memcached memcached] but note that memcached does not have any security features so it should be used behind a firewall.<br />
* Consider using PostgreSQL. See [http://moodle.org/mod/forum/discuss.php?d=49195 how to migrate from MySQL to PostgreSQL] (forum discussion).<br />
* [http://dev.mysql.com/doc/refman/5.0/en/server-parameters.html General advice on tuning MySQL parameters] (advice from the MySQL manual)<br />
* [http://www.mysqlperformanceblog.com/2007/11/01/innodb-performance-optimization-basics/ InnoDB performance optimization] taken from the [http://www.mysqlperformanceblog.com/ MySQL performance blog] site.<br />
<br />
==Performance of different Moodle modules==<br />
<br />
Moodle's activity modules, filters, and other plugins can be activated/deactivated. If necessary, you may wish to deactivate some features (such as chat) if not required - but this isn't necessary. Some notes on the performance of certain modules:<br />
<br />
* The '''Chat''' module is [http://moodle.org/mod/forum/discuss.php?d=37979&parent=175079 said] to be a hog in terms of frequent HTTP requests to the main server. This can be reduced by setting the module to use ''Streamed'' updates, or, if you're using a Unix-based webserver, by running the chat in daemon mode. When using the Chat module use the configuration settings to tune for your expected load. Pay particular attention to the ''chat_old_ping'' and ''chat_refresh'' parameters as these can have greatest impact on server load.<br />
* The Moodle '''Cron''' task is triggered by calling the script ''cron.php''. If this is called over HTTP (e.g. using wget or curl) it can take a large amount of memory on large installations. If it is called by directly invoking the php command (e.g. ''php -f /path/to/moodle/directory/admin/cli/cron.php'') efficiency can be much improved.<br />
* The '''Recent activities''' block is consuming too many resources if you have huge number of records <code>mdl_log</code>. This is being tested to optimize the SQL query.<br />
* The '''Quiz''' module is known to stretch database performance. However, it has been getting better in recent versions, and we don't know of any good, up-to-date performance measurements. (Here is a [http://moodle.org/mod/forum/discuss.php?d=68579 case study from 2007 with 300 quiz users].). The following suggestions were described by [https://moodle.org/user/view.php?id=94615&course=5 Al Rachels] in [https://moodle.org/mod/forum/discuss.php?d=347126 this forum thread]:<br />
** make sure both Moodle, and the operating system, are installed on a [https://en.wikipedia.org/wiki/Solid-state_drive solid state drive]<br />
** upgrade to and use [https://docs.moodle.org/dev/Moodle_and_PHP7 PHP 7]<br />
** run MySQLTuner and implement its recommendations<br />
<br />
See [[Performance settings]] for more information on performance-related Moodle settings.<br />
<br />
==See also==<br />
<br />
*Using Moodle: [http://moodle.org/mod/forum/view.php?f=94 Hardware and Performance] forum<br />
*[http://opensourceelearning.blogspot.be/2012/10/why-your-moodle-site-is-slow-five.html Why Your Moodle Site is Slow: Five Simple Settings] blog post from Jonathan Moore <br />
*I teach with Moodle perfomance testing: http://www.iteachwithmoodle.com/2012/11/17/moodle-2-4-beta-performance-test-comparison-with-moodle-2-3/<br />
*[http://jfilip.ca/2013/08/20/moodle-2-4-5-vs-2-5-1-performance-and-muc-apc-cache-store/ Moodle 2.4.5 vs 2.5.2 performance and MUC APC cahe store]<br />
*[http://jfilip.ca/2013/09/25/moodle-performance-testing-2-4-6-vs-2-5-2-vs-2-6dev/ Moodle performance testing 2.4.6 vs 2.5.2 vs 2.6dev]<br />
*[http://jfilip.ca/2013/09/24/moodle-performance-analysis-revisted-now-with-mariadb/ Moodle performance analysis revisited (now with MariaDB)]<br />
*[http://tjhunt.blogspot.ca/2013/05/performance-testing-moodle.html Tim Hunt's blog (May 2, 2013) on performance testing Moodle]<br />
*[http://newrelic.com/ New Relic, Application Performance Monitoring]<br />
*[http://blog.bitnami.com/2014/06/performance-enhacements-for-apache-and.html Performance enhacements for Apache and PHP (Apache Event MPM and PHP-FPM)]<br />
*[https://scholarlms.net/performance-recommendations/ Performance recommendations]<br />
*[https://enovation.ie/moodle-performance-investigation-using-performance-info/ Moodle performance investigation – using performance info ]<br />
<br />
There have been a lot of discussions on moodle.org about performance, here are some of the more interesting and (potentially) useful ones:<br />
<br />
* [http://moodle.org/mod/forum/discuss.php?d=83057 Performance woes!]<br />
* [http://moodle.org/mod/forum/discuss.php?d=57028 Performance perspectives - a little script]<br />
* [http://moodle.org/mod/forum/discuss.php?d=88927 Comments on planned server hardware]<br />
* [http://moodle.org/mod/forum/discuss.php?d=102978#p461624 Moodle performance in a pil by Martin Langhoff]<br />
* [https://moodle.org/mod/forum/discuss.php?d=240391#unread Advice on optimising php/db code in moodle2+]<br />
* [https://moodle.org/mod/forum/discuss.php?d=243531 Moodle 2.5 performance testing at the OU]<br />
* [https://moodle.org/mod/forum/discuss.php?d=273602 100 active users limit with 4vCPU]<br />
* [https://moodle.org/mod/forum/discuss.php?d=336603#p1356423 Performance Tip ... shared...]<br />
<br />
[[es:Recomendaciones sobre desempeño]]<br />
[[fr:Recommandations_de_performance]]<br />
[[ja:パフォーマンス]]<br />
[[de:Geschwindigkeitsempfehlungen]]</div>Leonstrhttps://docs.moodle.org/310/en/index.php?title=Talk:Arguments_in_favour_of_PostgreSQL&diff=140379Talk:Arguments in favour of PostgreSQL2021-05-11T08:54:57Z<p>Leonstr: Added 'Delete this page?'</p>
<hr />
<div>The link called "Installing Postgres on Ubuntu(Debian)" takes you to a page that does not even mention Postgres. The link should either be fixed, the title should be updated or the link should be removed.<br />
<br />
The linked page used to have a paragraph about PostgreSQL in the Documentation for Moodle 2.0. I have provisionally changed the link, but it would be very convenient that someone knowlegeable updates the page at https://docs.moodle.org/310/en/Step-by-step_Installation_Guide_for_Ubuntu. [[User:German Valero|German Valero]] ([[User talk:German Valero|talk]])<br />
<br />
== Delete this page? ==<br />
<br />
Despite its title this page reads like someone with an axe to grind listing deficiencies in MySQL circa 2005, rather than presenting arguments in favour of PostgreSQL. I think this kind of page is more suited to a blog post or forum post and not Moodle Docs, so I think this page should be deleted. See also: forum thread [https://moodle.org/mod/forum/discuss.php?d=421937 Arguments in favour of PostgreSQL]. [[User:Leon Stringer|Leon Stringer]] ([[User talk:Leon Stringer|talk]]) 08:54, 11 May 2021 (UTC)</div>Leonstrhttps://docs.moodle.org/310/en/index.php?title=URL_resource_settings&diff=140216URL resource settings2021-04-21T10:08:46Z<p>Leonstr: /* URL variables */ Revised definition of "base URL"</p>
<hr />
<div>{{URL}}<br />
This page explores in more detail the settings for the URL resource once you have added it to your course and also covers the Site administration settings.<br />
<br />
==General==<br />
Give the URL a name and a description if required, checking the box if you want the description to display on the course page.<br />
<br />
In External tool, type the full web address of your URL or click the Choose a link button for more options.<br />
<br />
==Appearance==<br />
;Display<br />
* ''Automatic'' - Make the best guess at what should happen (probably what is wanted 99% of the time).<br />
* ''Embed'' - Show the Moodle page with heading, blocks and footer. Show the title/description of the item and display the file directly in the page as well<br />
* ''Open'' - No Moodle heading, blocks, footer or description - just show the file in the web browser (e.g. shows image, PDF, flash animation, taking up the whole browser window)<br />
* ''In pop-up'' - Same as 'Open', but opens a new browser window to show this file (without the Moodle heading, blocks, etc) - this browser window also does not have all the menus in it. If you select this one, then you can specify the pop-up width and height.<br />
<br />
You can also have 'in frame' or 'New window' but these must be enabled by the administrator. If you don't see an option, ask the administrator to enable it in ''Site administration >Plugins >Activity modules >URL.''<br />
==URL variables==<br />
<br />
This section allows you to pass internal information as part of the URL.<br />
<br />
This is useful if the URL is actually an interactive web page that takes parameters, and you want to pass something like the name of the current user, for example.<br />
<br />
Another use is to create stable links that updates in each iteration of the course, for example:<br />
<br />
if you want to link to the student's user report, then you add the base URL to the External URL field, and then in the URL variables section, add 'id' to the first field and select 'id' from under the site heading, and then save changes. The result is a URL that always points to the student's user report.<br />
<br />
The "base URL" is the fixed part of the URL that the variables will be appended to. For example https://moodle.example.com/report/outline/user.php or https://moodle.example.com/report/outline/user.php?mode=complete could both have a user ID and course ID appended (for example course=4&id=36).<br />
<br />
A further use includes displaying all forums in a site, by using the base URL then adding add 'id' to the first field and selecting 'id' from under the site heading. Another use makes use of mailto:email@address. URL variables could then include the subject parameter followed by the 'Site full name'. E.g. if you wanted to email a teacher who taught multiple courses, if a student clicked the URL then the email would automatically fill the subject field, which would help the teacher to identify which course the student was in.<br />
<br />
==Other settings==<br />
Depending on what is enabled for your site and course, you may also need to explore [[Common module settings]], [[Restrict access| Restrict access]], [[Activity completion]], [[Tags]] and [[Competencies]]<br />
<br />
==Drag and Drop a URL==<br />
If an administrator has enabled the experimental feature drag and drop upload of text/links in ''Settings > Site administration > Development > Experimental > [[Experimental settings]]'', a link can be dragged into a section of the course and given a name, as shown in the images below.<br />
<br />
{|<br />
| [[File:dragURL.png|thumb|Adding a URL using drag and drop]]<br />
|}<br />
<br />
==URL module capabilities==<br />
<br />
* [[Capabilities/mod/url:view|View URL resource]]<br />
* [[Capabilities/mod/url:addinstance|Add a new URL resource]]<br />
<br />
==Site administration settings==<br />
<br />
The URL resource has additional settings which may be changed by an administrator in ''Administration > Site administration > Plugins > Activity modules > URL''.<br />
<br />
===Frame height===<br />
<br />
Here you can specify the height of the top frame (containing the navigation) if you choose the "in frame" display option. Note:If your theme has a large header then the height should be increased to prevent horizontal and vertical scrollbars.<br />
<br />
===Password===<br />
<br />
Here you can add a password that will connect your users to a secure site. [http://moodle.org/mod/forum/discuss.php?d=189842#p826416 See this forum post] for more details.<br />
<br />
===Include role names in parameters===<br />
<br />
===Available display options===<br />
<br />
This setting allows you to add different ways the resource may be displayed on the course page. There are a number of defaults but you can add or change them here. Other display options are:<br />
* ''In frame'' - show the Moodle heading and the file description, with the file displayed in a resizeable area below <br />
* ''New window'' - very much like 'in pop-up', but the new window is a full browser window, with menus and address bar, etc.<br />
[[File:Display.gif]]<br />
<br />
===Default values for activity settings===<br />
<br />
Here you can set the defaults for this resource. <br />
<br />
===See also===<br />
Form discussions:<br />
* [https://moodle.org/mod/forum/discuss.php?d=389552#p1570270 URL Resource - adding a URL Variable]<br />
<br />
<br />
<br />
[[de:Link/URL konfigurieren]]<br />
[[fr:Paramètres de l'URL]]<br />
[[es:Configuraciones del recurso URL]]</div>Leonstrhttps://docs.moodle.org/310/en/index.php?title=Activity_report&diff=140215Activity report2021-04-21T09:45:58Z<p>Leonstr: /* Individual activity reports */ Added where to find 'Show activity reports'</p>
<hr />
<div>{{Course reports}}<br />
==Course activity reports==<br />
[[Image:courseactivityreport.png|thumb|Course activity report]]<br />
<br />
A course activity report, showing the number of views for each activity and resource (and any related blog entries), can be viewed by managers, teachers and non-editing teachers (and any other users with the capability [[Capabilities/report/outline:view|report/outline:view]]) in ''Administration > Course administration > Reports > Activity report''.<br />
<br />
An activity report for the front page is available for administrators and managers in ''Administration > Front page settings>Reports > Activity report''.<br />
<br />
The length of time that the activity report covers is determined by the loglifetime setting in ''Administration > Site administration > Courses > Backups > General backup defaults''.<br />
<br />
An activity report is computed from the course's start date (in the [[Course settings|course settings]]).<br />
<br />
==Individual activity reports==<br />
<br />
If activity reports are enabled for a course in the course settings (''Show activity reports'' under ''Appearance''), each course participant can access reports of their contributions, such as forum posts or assignment submissions, logs and a statistics report.<br />
<br />
<br><br><br><br><br><br><span id="complete-report">.</span><br />
<br />
==Complete Report==<br />
<br />
The Complete report helps instructors to view a detailed list of an individual student's last log and activity in the Activities and resources in your Moodle course, including detailed contribution to any of the various types of course activities. The activities and resources are displayed in the same order as they are on the main course page. it might resemble a student's portfolio at a specific course.<br />
<br />
[[{{ns:file}}:screencapture-school-demo-moodle-net-report-outline-user-php-1513359209412.png|400px|thumb|left|Complete report (user full activity and contribution in a course)<br />
]]<br />
<br />
[[de:Aktivitätenbericht]]<br />
[[es:Reporte de actividad]]<br />
[[eu:Jardueraren_txostena]]<br />
[[fr:Rapport d'activité]]</div>Leonstrhttps://docs.moodle.org/310/en/index.php?title=Site_backup&diff=140182Site backup2021-04-16T11:38:46Z<p>Leonstr: /* Database */ Added --default-character-set: MariaDB ≥ 10.3.11 defaults to utf8mb4, others default to utf8</p>
<hr />
<div>{{Backup}}<br />
A site backup allows a site administrator to save everything associated with a moodle site. These backups can be restored to bring a site back to the point in time when the backup was made. <br />
<br />
Performing regular backups are highly recommended to reduce the amount of lost information in the event of a problem on the site and to speed the overall recovery process.<br />
<br />
== What needs to be backed up? ==<br />
<br />
A Moodle system comprises three parts:<br />
# The data stored in the database (For example, a MySQL database)<br />
# The uploaded files (For example, site and course files uploaded via Moodle located in moodledata)<br />
# The '''Moodle code''' (For example, everything in server/htdocs/moodle)<br />
You can confirm where all these things are located in a Moodle installation by checking the '''[[Configuration file|config.php]]''' file. <br />
<br />
:# '''$CFG->dbname''' shows the database name<br />
:# '''$CFG->prefix''' shows the the database table name prefix<br />
:# '''$CFG->dataroot''' controls where the ''uploaded files'' are stored; and<br />
:# '''$CFG->wwwroot''' points to where the ''code'' is stored.<br />
<br />
;Tip <br />
Generally speaking, the database ("dbname and prefix") and the uploaded files (dataroot) are the two most important to copy on a regular basis. These contain information that will change most often. <br />
<br />
The Moodle code (wwwroot) is less important as a frequent backup, since it will only change when the the actual code is changed through upgrades, addins and code tweaks. You can always get a copy of the standard Moodle code from http://download.moodle.org so you only have to backup the parts you added or changed yourself.<br />
<br />
== Creating a backup of your Moodle site ==<br />
<br />
=== Database ===<br />
<br />
The right way to back up your database depends on which database system you are using. The instructions below are one way to back up a MySQL database. Another option would be to use a tool like phpMyAdmin to manually make a backup. The documentation for your database will give more options.<br />
<br />
There are many ways to do such backups. Here is an outline of a little script you can run on Unix to backup the database (it works well to have such a script run daily via a cron task):<br />
<br />
cd /my/backup/directory<br />
mv moodle-database.sql.gz moodle-database-old.sql.gz<br />
mysqldump --default-character-set=utf8mb4 -h example.com -u myusername --password=mypassword -C -Q -e --create-options mydatabasename > moodle-database.sql<br />
gzip moodle-database.sql<br />
<br />
Also consider using an option to help ensure that the backup is consistent (e.g. avoid the data changing half-way through the backup), e.g. for MySQL/MariaDB and mysqldump try [https://dev.mysql.com/doc/refman/5.7/en/mysqldump.html#option_mysqldump_single-transaction --single-transaction].<br />
<br />
==== Character encoding ====<br />
Make sure that a database backup uses the correct character encoding. In most databases, use [[UTF-8]].<br />
<br />
When dumping the entire Moodle database, check for possible character encoding issues. In some instances, backups created with [http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html mysqldump] or [http://www.phpmyadmin.net phpMyAdmin] may not properly encode all of the data. This will result in non-readable characters when the database is restored. <br />
<br />
:''Tip'': One solution is to use MySQL Administrator 1.1 or another tool that will force a UTF-8 dump of the data.<br />
<br />
==== Tools for database backups ====<br />
<br />
; phpMyAdmin<br />
: [http://www.phpmyadmin.net phpMyAdmin] is the tool of choice with most web hosting providers.<br />
<br />
; MySQLDumper<br />
: [https://sourceforge.net/projects/mysqldumper/ MySQLDumper] is a backup script for MySQL databases, written in PHP and Perl. MySQLDumper uses a proprietary technique to avoid execution interruption when running PHP scripts (the max. execution time is usually set to 30 seconds). MySQLDumper also cares for the encoding problems mentioned above. It also works with compressed files and allows setting up regular cron jobs for updating and updating to a remote FTP site.<br />
<br />
; AutoMySQLBackup<br />
: [https://github.com/sixhop/AutoMySQLBackup AutoMySQLBackup] is a backup script for MySQL databases, written in PHP. AutoMySQLBackup will create Daily, Weekly and Monthly backups of one or more of your MySQL databases from one or more of your MySQL servers. Features include email notification, compression and encryption, configurable backup rotation, incremental database backups, and more.<br />
<br />
=== Uploaded files (moodledata) ===<br />
Through the Moodle interface, users can upload or create files and folders. These are located in a directory, often called "moodledata". Since they are just files and folders, there are many different ways to backup or copy moodledata. <br />
<br />
* For example, using a file transfer program, copy the entire moodledata directory to a different area, drive or computer. Example of file transfer programs include: FTP, WinSP, wget, rsync.<br />
<br />
* You might use a compression program to create compact files (tar, zip. 7z, XZ, BZIP2, GZIP, and WIM are a few file formats) of the entire directory. This can be done before or after file transfers.<br />
<br />
; Tips <br />
* Typically not all moodledata files change between regular/periodic backups. A new Administrator might want to look into [http://en.wikipedia.org/wiki/Incremental_backup incremental or other efficient backups] procedures. <br />
* Depending upon the operating environment there are many tools for backing up server files and ways of backing up moodledata. See [[Tools_for_backing_up_server_files]] for tips on using rsync, FTP or Wget.<br />
<br />
=== Moodle code ===<br />
Backing up the Moodle code, will be similar to backing up moodledata. See [[Tools for backing up server files]].<br />
<br />
;Tip<br />
It is always a good idea to have several backup copies of your Moodle code files. While you can always download a fresh base copy of the Moodle code from http://download.moodle.org, you might have customized that code. It is a good idea to create a separate backup of your Moodle code before you customize the code. This includes installing [[Contributed code]], [[Themes]] and upgrading.<br />
<br />
== See also ==<br />
* [https://www.youtube.com/watch?v=k5rwTy3sNh0 Screencast: How to back up a Moodle site] (thanks to Bruce Chambr)<br />
*[[Site restore]] Now that you have a backup, how to restore it<br />
* [[Moodle migration]] - move a Moodle site to a different server<br />
* Using Moodle [http://moodle.org/mod/forum/discuss.php?d=140949 Site DatabaseBackup Using phpMyAdmin] forum discussion<br />
* [[Site Backup for Low-tech Users]]<br />
<br />
[[de:Sicherung der Moodle-Installation]]<br />
[[ja:サイトバックアップ]]<br />
[[es:Copia de seguridad del sitio]]<br />
[[fr:Sauvegarde de site]]</div>Leonstrhttps://docs.moodle.org/310/en/index.php?title=Scheduled_tasks&diff=139863Scheduled tasks2021-03-12T13:21:51Z<p>Leonstr: /* Managing scheduled tasks */ Changed \ to / in paths, URL to HTTPS</p>
<hr />
<div>{{Server settings}}<br />
==Managing scheduled tasks==<br />
An administrator can schedule routine tasks very precisely from ''Administration > Site administration > Server > Scheduled tasks.''<br />
<br />
Note that you still need to run the [[Cron|cron scripts]] (admin/cli/cron.php or https://yoursite/admin/cron.php) at regular intervals. It is recommended that the cron is run every minute.<br />
{|<br />
|-<br />
|[[File:scheduledtasks1.png|thumb|Scheduled tasks]]<br />
|[[File:scheduledtasks2.png|thumb|Editing a scheduled task]]<br />
|}<br />
<br />
Clicking the edit icon allows the administrator to specify the minute/hour/day/month or day of the week the task is to be run. It is also possible to reset the task to its default setting or disable it completely.<br />
<br />
The column 'Next run' provides information on whether a plugin or a task is disabled (as well as the date that a task will next run).<br />
<br />
==Format for scheduling tasks==<br />
<br />
When typing into the fields, the format is the same as for Unix cron. Examples are as follows and are according to which field you are editing:<br />
<br />
* is every minute, hour, day, month<br />
*/2 is every two minutes, every two hours or every second day<br />
2-10 is every minute between two and ten past the hour or every hour between 2 and 10 am <br />
0 is every Sunday<br />
1 is every Monday or every January<br />
2,5 is the second and 5th of the month, or February and May, or Tuesday and Friday.<br />
<br />
==Fail delay==<br />
<br />
If you're trying to debug a cron task, you may notice the Fail Delay becomes populated with a number. This is the time in seconds the cron will delay running the task. To sidestep this problem for development purposes, take a look at the Scheduled Tasks section here: [[Administration_via_command_line#Scheduled_tasks]].<br />
<br />
==Running individual tasks==<br />
<br />
To be able to run individual scheduled tasks via 'Run now' links on the scheduled tasks page, 'Allow 'Run now' for scheduled tasks' (tool_task | enablerunnow) in Site administration / Security / Site security settings should be enabled AND 'Path to PHP CLI' (pathtophp) in Site administration / Server / System paths should be set.<br />
<br />
[[File:examplescheduledtasks.png]]<br />
<br />
==Tasks running now==<br />
{{New features}}<br />
Currently running tasks may be viewed from Site administration > Server > Tasks >Tasks running now<br />
[[File:TasksRunningNow.png|600px|center]]<br />
<br />
==Launching a task from CLI==<br />
You can also launch individual task from Command Line Interface (see [[Administration_via_command_line#Scheduled_tasks|Administration via command line]]).<br />
<br />
[[es:Trabajos agendados]]<br />
[[de:Geplante Vorgänge]]<br />
[[fr:Tâches programmées]]</div>Leonstrhttps://docs.moodle.org/310/en/index.php?title=External_database_authentication&diff=139862External database authentication2021-03-12T13:11:04Z<p>Leonstr: /* Automatic Synchronisation */ auth/db/cli/sync_users.php has been deprecated since Moodle 3.3 (MDL-57913)</p>
<hr />
<div>{{Authentication}}<br />
Location: '' Site administration > Plugins > Authentication > External database''<br />
<br />
<br />
This method uses an external database table to check whether a given username (which must be varchar) and password is valid. If the user does not currently exist in Moodle a new account will be created and their information copied from the external database. <br />
<br />
== Field mappings ==<br />
<br />
This is done by mapping fields at the bottom of the database authentication page. Each data field in the user profile has a text field next to it. Enter the name of the column in the external database that maps to the profile data field.<br />
<br />
'''Update Local''' - Specifies that the external data will be entered into the local field in question<br />
* On Creation - specifies that this will only happen on the original login when the account is created for the first time.<br />
* On Every Login - specifies that changes in the external data will be updated on the local Moodle field in question the next time the user logs in again.<br />
<br />
'''Update External''' - Specifies just the opposite, meaning changes in the local Moodle field in question will update the corresponding field in the external database<br />
* Never - Specifies this is disabled<br />
* On Update - Enables this to happen if a change is made locally (additional configuration is probably required)<br />
<br />
'''Lock Value''' - Only determines whether the local user can make a change in the Moodle field and does not affect the two settings above.<br />
* Unlocked - A user can make changes locally in the Moodle field (assumably even if it contradicts the external database the next login would change it again if Update Local is set<br />
* Locked - A user can never make changes<br />
* Unlocked if empty - A user can only make changes if the field is not populated already from the external database (this would seem to indicate a user could only enter something into this field once and could not change it after saving)<br />
<br />
== Automatic Synchronisation ==<br />
<br />
The above method adds new users only when they log in. If you want user accounts to be created in Moodle independent of actual logins, you must enable the auth_db ''Synchronise users task'' (\auth_db\task\sync_users) on the [[Scheduled tasks]] page. By default this runs once a day, adjust the schedule to run this more frequently if required.<br />
<br />
If you have custom profile fields on your site, these can also be synced with this scheduled task.<br />
<br />
==Additional Notes==<br />
<br />
It is now possible to use Salted Crypt passwords for the password format with external database authentication from the Password format setting:<br />
[[File:dbsaltedcrypt.png|thumb|300px|center]]<br />
<br />
<br />
* Plain text password matching is now always case sensitive<br />
* sha1/md5 hash comparisons are now enforced case insensitive (as underlying they are hexadecimal values)<br />
<br />
* Some of the things that apply to [[Upload users]] apply to the External database, but not all of the fields in the [[Upload users]] are available for the External Database authentication. The only available fields are the fields listed in the data mapping section of the admin page for the External Database connection.<br />
* Note that for MySQL databases moodle will store date custom profile fields in a bigint field (as a unix timestamp). Using a timestamp or datetime field will not work<br />
==See also==<br />
<br />
*[[External database enrolment]]<br />
<br />
[[de:Externe Datenbank]]<br />
[[fr:Authentification par base de données externe]]<br />
[[ja:外部データベース認証]]<br />
[[es:Autenticación con BasedeDatos externa]]</div>Leonstrhttps://docs.moodle.org/310/en/index.php?title=Template:Authentication&diff=139860Template:Authentication2021-03-10T21:21:38Z<p>Leonstr: Added OAuth 2, core since Moodle 3.3</p>
<hr />
<div><div class="navtrail">[[Main page]] ► [[Managing a Moodle site]] ► [[Authentication]] ► [[{{PAGENAME}}]]</div><br />
<div class="sideblock right" style="width: 14em;"> <br />
<div class="header">[[Authentication]]</div> <br />
<div class="content"><br />
*[[Managing authentication]]<br />
*[[Manual accounts]]<br />
*[[No login]]<br />
*[[Email-based self-registration]]<br />
*[[CAS server (SSO) authentication|CAS server (SSO)]]<br />
*[[External database authentication|External database]]<br />
*[[LDAP authentication|LDAP]]<br />
*[[LTI]]<br />
*[[MNet]]<br />
*[[No authentication]]<br />
*[[Shibboleth]]<br />
*[[OAuth 2 authentication|OAuth 2]]<br />
*[[Authentication FAQ]]<br />
</div><br />
</div><br />
<br />
<includeonly>[[Category:Authentication]]</includeonly><br />
<noinclude>This template will categorize articles that include it into [[:Category:Authentication]].</noinclude></div>Leonstrhttps://docs.moodle.org/310/en/index.php?title=Authentication&diff=139859Authentication2021-03-10T21:20:07Z<p>Leonstr: /* Authentication plugins */ Added OAuth 2, core since Moodle 3.3</p>
<hr />
<div>{{Managing a Moodle site}}<br />
Authentication is the process of allowing a user to log in to a Moodle site with a username and password.<br />
<br />
==Authentication plugins==<br />
<br />
Moodle provides a number of ways of [[Managing authentication|managing authentication]], called ''authentication plugins''. <br />
<br />
Standard authentication plugins are:<br />
<br />
*[[Manual accounts]] - accounts created manually by an administrator<br />
*[[No login]] - suspend particular user account<br />
*[[Email-based self-registration]] - for enabling users to create their own accounts<br />
*[[CAS server (SSO)]] - account details are located on an external CAS server<br />
*[[External database authentication|External database]] - account details are located on an external database<br />
*[[LDAP authentication|LDAP server]] - account details are located on an external LDAP server<br />
*[[LTI]] - works with the [[Publish as LTI tool]] enrolment method to connect courses and activities<br />
*[[MNet|Moodle Network authentication]] - how different Moodle sites can connect and authenticate users<br />
*[[No authentication]] - for testing purposes or if the Moodle site is not available on the Internet. Do NOT use on public servers!<br />
*[[Shibboleth]] - account details are located on an external Shibboleth server<br />
*[[OAuth 2 authentication|OAuth 2]] - authenticate with an OAuth 2 service<br />
* Web services authentication<br />
<br />
There are also many [https://moodle.org/plugins/?q=type:auth additional authentication plugins in the Moodle plugins directory].<br />
<br />
==See also==<br />
<br />
*[[Authentication FAQ]]<br />
<br />
[[Category:Authentication]]<br />
<br />
[[de:Authentifizierung]]<br />
[[es:Autenticación]]<br />
[[eu:Erabiltzaileen_autentifikazioa]]<br />
[[fr:Authentification]]<br />
[[it:Autenticazione]]<br />
[[ja:認証]]</div>Leonstrhttps://docs.moodle.org/310/en/index.php?title=Groups&diff=139415Groups2021-01-22T18:08:35Z<p>Leonstr: /* Creating a group */ selecting -> select</p>
<hr />
<div>{{Grouping users}}<br />
==Why use groups?==<br />
*You are a teacher in a course where you have several classes and you want to filter your activities and gradebook so you only see one class at a time.<br />
*You are a teacher sharing a course with other teachers and you want to filter your activities and gradebook so you don’t see the students from your colleagues’ classes.<br />
*You want to allocate a particular activity, resource or topic section to just one class or set of users and you don’t want others to see it.<br />
<br />
{{MediaPlayer | url = https://youtu.be/Gaq1M9-ETtQ | desc = How to add groups to courses}}<br />
<br />
*This [https://youtu.be/pKAFWItexUY screencast about using groups] also highlights the benefits of using groups.<br />
<br />
==Group levels==<br />
[[File:groupmodecourse.png|thumb|Groups settings in course settings]]<br />
A group or grouping can be used on two levels:<br />
<br />
*Course level - The group mode defined at the course level is the default mode for all activities defined within that course. To use groups you need first to set a group mode in ''Administration > Course administration > Edit settings.''<br />
<br />
*Activity level - Each activity that supports groups can also have its own group mode defined. If the course setting "Force group mode" is set to "Yes" then the option to define the group mode for individual activities is not available. If it is set to "No", then the teacher may change the group mode:<br />
<br />
===Group modes===<br />
<br />
There are three group modes <br />
<br />
*No groups - There are no sub groups, everyone is part of one big community<br />
*Separate groups - Each group can only see their own group, others are invisible.<br />
*Visible groups - Each group works in their own group, but can also see other groups. (The other groups' work is read-only.)<br />
<br />
For example, enabling either separate or visible groups on an assignment drop-box enables staff to filter the student submissions to see only those from a particular tutor group. With visible groups, students can see which other groups are doing the same activities as they are; with separate groups, they do not know which other groups are doing the same activities.<br />
<br />
Using groups with discussion forums allow teachers to restrict interaction between students. Separate groups mean only students in the same group can see and participate in discussions within a particular forum. Visible groups allow students to see other group's discussions, but only participate in their own group's discussions.<br />
<br />
'''Note:''' Where visible groups are used or the participant can access all groups, the user's own group is shown first, followed by other groups:<br />
<br />
[[File:mygroupsfirst.png]]<br />
<br />
==Creating a group==<br />
# Click the ''Create group'' button:<br />
## (using the Boost theme) select ''Participants'' from the navigation drawer, click the ''⚙'' (actions menu) on the right, then ''Groups''.<br />
## (using the Classic theme) ''Administration > Course administration > Users > Groups''<br />
#Add a group name and optional description (displayed above the list of group members on the participants page), [[Enrolment key|enrolment key]] and picture (displayed on the participants page and next to forum posts)<br />
#Tick the box Enable group messaging if you wish to enage in group conversations. You will then be able to send group messages from the messaging drawer. See [[Messaging]] for more information.<br />
#Click the 'Save changes' button<br />
#Select the group to which you want to add participants, then click the 'Add/remove users button<br />
# In the "Potential members" list, select the users you want to add to the group. Multiple users may be selected using the Crtl key.<br />
# Click the Add button to add the users to the group<br />
<br />
An optional group ID number (an advanced setting) may be added for matching the group against external systems. Group ID numbers are not displayed anywhere on the site. Within a course, all group ID numbers must be unique. Thus it's not possible to create a group with a duplicate group ID number.<br />
<br />
Note: In Moodle 3.8, a default group icon is displayed in forum posts when there is no group picture set (MDL-67959). A workaround to the problem is to hide the picture in the group settings.<br />
<br />
==Auto-create groups==<br />
[[File:autocreategroups.png|thumb|Auto-create groups]]<br />
Groups may be created automatically via the 'Auto-create groups' button in ''Administration > Course administration > Users > Groups''. To see all the settings, click the ''Expand all'' link top right.<br />
<br />
===General===<br />
A '''naming scheme''' can be created automatically. # is replaced by sequential numbers, and @ by letters. For example: <br />
*''Group @'' will create group with a naming scheme Group A, Group B, Group C . . .<br />
*''Group #'' will create group with a naming scheme Group 1, Group 2, Group 3 . . .<br />
<br />
You can specify if you would like to create <br />
*x number of Groups or <br />
*each group contain x number of students<br />
<br />
=== Prevent last small group ===<br />
<br />
When selecting '''Members per group''', depending on the number of users in the course, the last group can end up with significantly fewer members than expected. You can select '''Prevent last small group''' to avoid the situation. If the last group would be smaller than 70% of the expected size, it will not be created. Instead, Moodle will allocate additional members to existing groups rather then create a new group with few members.<br />
<br />
Example 1:<br />
:You have a course with 80 students and you let auto-create groups with 30 members per group. There would be just 20 students in the third group which is 66% out of expected 30. Moodle will auto-create only two groups with 40 students in each.<br />
<br />
Example 2: <br />
:You have a course with 81 students and you let auto-create groups with 30 members per group. Moodle will create three groups with 30, 30 and 21 members respectively because 21 is 70% out of expected 30.<br />
<br />
Hint: If you need to customize the 70% ratio used in these calculations on your site, ask your administrator to set the constant `AUTOGROUP_MIN_RATIO` in the main config.php.<br />
<br />
define('AUTOGROUP_MIN_RATIO', 0.95); // Means the smallest group will have at least 95% of the expected size.<br />
<br />
===Group members===<br />
''Select members from ...'' allows you to choose from roles assigned within the course, available cohorts, groups or groupings.<br />
'''Specify''' and '''Group/Member count''' work together. <br />
<br />
The setting 'Select members from cohort' lists all cohorts which users enrolled on the current course are part of. The number in brackets is the number of users enrolled on the course in that cohort.<br />
<br />
The 'Ignore users in groups' checkbox should be ticked to only select group members from users that are NOT already in a group in the course.<br />
<br />
The 'Include only active enrolments' checkbox provides the option to choose whether to include suspended users in groups. The checkbox is only displayed to users with the [[Capabilities/moodle/course:viewsuspendedusers|capability to view suspended users]].<br />
<br />
===Grouping===<br />
<br />
'''Create in grouping''' and '''Grouping name''' allows you to create a new grouping and allocate the new auto-created groups to be created to it. <br />
<br />
Prior to creating the groups, you can view the groups.<br />
<br />
==Restricting an activity, resource or course topic to a particular group==<br />
[[File:group restriction.png|frame|Restricting an activity to a particular group]]<br />
To be able to restrict an activity, resource or course topic to a group, [[Restrict access]] must be enabled. This will result in a 'Restrict access' section in the activity, resource or topic settings and a group restriction can then be added.<br />
<br />
==Groups and enrol plugins==<br />
<br />
Where groups are created automatically with enrol plugins such as IMS Enterprise, members cannot be unenrolled manually via the groups screen inside a course. This has to be done from the plugin. Additionally, when group members are owned by a plugin like this, there is information below their name on the groups screen. <br />
<br />
==Groups overview==<br />
<br />
A overview of groups and groupings is available via the Overview tab in ''Administration > Course administration > Users > Groups''.<br />
<br />
The table may be filtered to display particular [[Groupings|groupings]] or groups and it will also display students who are not in a group.<br />
<br />
==Groups capabilities==<br />
<br />
*[[Capabilities/moodle/course:managegroups|Manage groups]]<br />
*[[Capabilities/moodle/site:accessallgroups|Access all groups]]<br />
*[[Capabilities/moodle/calendar:managegroupentries|Manage group calendar entries]]<br />
<br />
==See also==<br />
<br />
* [[Upload users]] - for importing users into groups<br />
* [[Enrolment key]]<br />
* [https://moodle.org/plugins/local_autogroup Autogroup additionalplugin] - A local plugin which automatically assigns enrolled users on a course into groups dependant upon information within their user profile. (Now with custom profile field support - called User Info Field in settings.) This plugin will create, update, and delete groups automatically to match the users on your course.<br />
<br />
[[de:Gruppen]]<br />
[[fr:Groupes]]<br />
[[ja:グループ]]<br />
[[es:Grupos]]</div>Leonstrhttps://docs.moodle.org/310/en/index.php?title=Groups&diff=139414Groups2021-01-22T18:06:59Z<p>Leonstr: /* Creating a group */ List the Boost theme first as it's the default</p>
<hr />
<div>{{Grouping users}}<br />
==Why use groups?==<br />
*You are a teacher in a course where you have several classes and you want to filter your activities and gradebook so you only see one class at a time.<br />
*You are a teacher sharing a course with other teachers and you want to filter your activities and gradebook so you don’t see the students from your colleagues’ classes.<br />
*You want to allocate a particular activity, resource or topic section to just one class or set of users and you don’t want others to see it.<br />
<br />
{{MediaPlayer | url = https://youtu.be/Gaq1M9-ETtQ | desc = How to add groups to courses}}<br />
<br />
*This [https://youtu.be/pKAFWItexUY screencast about using groups] also highlights the benefits of using groups.<br />
<br />
==Group levels==<br />
[[File:groupmodecourse.png|thumb|Groups settings in course settings]]<br />
A group or grouping can be used on two levels:<br />
<br />
*Course level - The group mode defined at the course level is the default mode for all activities defined within that course. To use groups you need first to set a group mode in ''Administration > Course administration > Edit settings.''<br />
<br />
*Activity level - Each activity that supports groups can also have its own group mode defined. If the course setting "Force group mode" is set to "Yes" then the option to define the group mode for individual activities is not available. If it is set to "No", then the teacher may change the group mode:<br />
<br />
===Group modes===<br />
<br />
There are three group modes <br />
<br />
*No groups - There are no sub groups, everyone is part of one big community<br />
*Separate groups - Each group can only see their own group, others are invisible.<br />
*Visible groups - Each group works in their own group, but can also see other groups. (The other groups' work is read-only.)<br />
<br />
For example, enabling either separate or visible groups on an assignment drop-box enables staff to filter the student submissions to see only those from a particular tutor group. With visible groups, students can see which other groups are doing the same activities as they are; with separate groups, they do not know which other groups are doing the same activities.<br />
<br />
Using groups with discussion forums allow teachers to restrict interaction between students. Separate groups mean only students in the same group can see and participate in discussions within a particular forum. Visible groups allow students to see other group's discussions, but only participate in their own group's discussions.<br />
<br />
'''Note:''' Where visible groups are used or the participant can access all groups, the user's own group is shown first, followed by other groups:<br />
<br />
[[File:mygroupsfirst.png]]<br />
<br />
==Creating a group==<br />
# Click the ''Create group'' button:<br />
## (using the Boost theme) selecting ''Participants'' from the navigation drawer, click the ''⚙'' (actions menu) on the right, then ''Groups''.<br />
## (using the Classic theme) ''Administration > Course administration > Users > Groups''<br />
#Add a group name and optional description (displayed above the list of group members on the participants page), [[Enrolment key|enrolment key]] and picture (displayed on the participants page and next to forum posts)<br />
#Tick the box Enable group messaging if you wish to enage in group conversations. You will then be able to send group messages from the messaging drawer. See [[Messaging]] for more information.<br />
#Click the 'Save changes' button<br />
#Select the group to which you want to add participants, then click the 'Add/remove users button<br />
# In the "Potential members" list, select the users you want to add to the group. Multiple users may be selected using the Crtl key.<br />
# Click the Add button to add the users to the group<br />
<br />
An optional group ID number (an advanced setting) may be added for matching the group against external systems. Group ID numbers are not displayed anywhere on the site. Within a course, all group ID numbers must be unique. Thus it's not possible to create a group with a duplicate group ID number.<br />
<br />
Note: In Moodle 3.8, a default group icon is displayed in forum posts when there is no group picture set (MDL-67959). A workaround to the problem is to hide the picture in the group settings.<br />
<br />
==Auto-create groups==<br />
[[File:autocreategroups.png|thumb|Auto-create groups]]<br />
Groups may be created automatically via the 'Auto-create groups' button in ''Administration > Course administration > Users > Groups''. To see all the settings, click the ''Expand all'' link top right.<br />
<br />
===General===<br />
A '''naming scheme''' can be created automatically. # is replaced by sequential numbers, and @ by letters. For example: <br />
*''Group @'' will create group with a naming scheme Group A, Group B, Group C . . .<br />
*''Group #'' will create group with a naming scheme Group 1, Group 2, Group 3 . . .<br />
<br />
You can specify if you would like to create <br />
*x number of Groups or <br />
*each group contain x number of students<br />
<br />
=== Prevent last small group ===<br />
<br />
When selecting '''Members per group''', depending on the number of users in the course, the last group can end up with significantly fewer members than expected. You can select '''Prevent last small group''' to avoid the situation. If the last group would be smaller than 70% of the expected size, it will not be created. Instead, Moodle will allocate additional members to existing groups rather then create a new group with few members.<br />
<br />
Example 1:<br />
:You have a course with 80 students and you let auto-create groups with 30 members per group. There would be just 20 students in the third group which is 66% out of expected 30. Moodle will auto-create only two groups with 40 students in each.<br />
<br />
Example 2: <br />
:You have a course with 81 students and you let auto-create groups with 30 members per group. Moodle will create three groups with 30, 30 and 21 members respectively because 21 is 70% out of expected 30.<br />
<br />
Hint: If you need to customize the 70% ratio used in these calculations on your site, ask your administrator to set the constant `AUTOGROUP_MIN_RATIO` in the main config.php.<br />
<br />
define('AUTOGROUP_MIN_RATIO', 0.95); // Means the smallest group will have at least 95% of the expected size.<br />
<br />
===Group members===<br />
''Select members from ...'' allows you to choose from roles assigned within the course, available cohorts, groups or groupings.<br />
'''Specify''' and '''Group/Member count''' work together. <br />
<br />
The setting 'Select members from cohort' lists all cohorts which users enrolled on the current course are part of. The number in brackets is the number of users enrolled on the course in that cohort.<br />
<br />
The 'Ignore users in groups' checkbox should be ticked to only select group members from users that are NOT already in a group in the course.<br />
<br />
The 'Include only active enrolments' checkbox provides the option to choose whether to include suspended users in groups. The checkbox is only displayed to users with the [[Capabilities/moodle/course:viewsuspendedusers|capability to view suspended users]].<br />
<br />
===Grouping===<br />
<br />
'''Create in grouping''' and '''Grouping name''' allows you to create a new grouping and allocate the new auto-created groups to be created to it. <br />
<br />
Prior to creating the groups, you can view the groups.<br />
<br />
==Restricting an activity, resource or course topic to a particular group==<br />
[[File:group restriction.png|frame|Restricting an activity to a particular group]]<br />
To be able to restrict an activity, resource or course topic to a group, [[Restrict access]] must be enabled. This will result in a 'Restrict access' section in the activity, resource or topic settings and a group restriction can then be added.<br />
<br />
==Groups and enrol plugins==<br />
<br />
Where groups are created automatically with enrol plugins such as IMS Enterprise, members cannot be unenrolled manually via the groups screen inside a course. This has to be done from the plugin. Additionally, when group members are owned by a plugin like this, there is information below their name on the groups screen. <br />
<br />
==Groups overview==<br />
<br />
A overview of groups and groupings is available via the Overview tab in ''Administration > Course administration > Users > Groups''.<br />
<br />
The table may be filtered to display particular [[Groupings|groupings]] or groups and it will also display students who are not in a group.<br />
<br />
==Groups capabilities==<br />
<br />
*[[Capabilities/moodle/course:managegroups|Manage groups]]<br />
*[[Capabilities/moodle/site:accessallgroups|Access all groups]]<br />
*[[Capabilities/moodle/calendar:managegroupentries|Manage group calendar entries]]<br />
<br />
==See also==<br />
<br />
* [[Upload users]] - for importing users into groups<br />
* [[Enrolment key]]<br />
* [https://moodle.org/plugins/local_autogroup Autogroup additionalplugin] - A local plugin which automatically assigns enrolled users on a course into groups dependant upon information within their user profile. (Now with custom profile field support - called User Info Field in settings.) This plugin will create, update, and delete groups automatically to match the users on your course.<br />
<br />
[[de:Gruppen]]<br />
[[fr:Groupes]]<br />
[[ja:グループ]]<br />
[[es:Grupos]]</div>Leonstrhttps://docs.moodle.org/310/en/index.php?title=Restrict_access_settings&diff=139198Restrict access settings2020-12-24T11:52:33Z<p>Leonstr: /* Enabling the use of restrict access sitewide */ 'Enable conditional access' changed to '... restricted access' in Moodle 2.8</p>
<hr />
<div>{{Restrict access}}<br />
==Enabling the use of restrict access sitewide==<br />
<br />
To use the restrict access feature, it must be enabled by an administrator by checking the "Enable restricted access" box in ''Administration > Site administration > Advanced features''. A restrict access section will then appear for teachers on the Activity settings screen, with an 'Add restriction' button. This section applies to all activities and resources, and is the second to last section in each activities settings area, above [[Activity completion]] (if it has been turned on).<br />
<br />
== Enabling or disabling specific restrictions==<br />
<br />
In ''Site administration > Plugins > Availability restrictions > Manage restrictions'' you can enable or disable (Hide/Show)any of the individual restriction types for use throughout the site.<br />
<br />
[[File:manageavailabilityrestrictions_m30.png|500px]]<br />
<br />
==Restricting activity access==<br />
<br />
In the settings of each activity there is a Restrict Access section. To get to this, click 'Edit' alongside the activity you want to restrict and then choose 'Edit Settings', or add a new activity, which will bring you to the settings page.<br />
<br />
In the 'Restrict Access' section of the activity settings page, click the 'Add restriction' button. A choice of conditions appears:<br />
<br />
[[File:add restriction popup.png|400px]]<br />
<br />
Restriction can be based upon [[Activity completion]], date, grade, the group or grouping the students are in or even user profile fields. The 'Restriction set' button also allows for more complex criteria requiring nested conditions.<br />
<br />
===Activity completion===<br />
See [[Activity completion]]. Note that this button only appears if you have Activity completion enabled by the administrator in your site, and it is enabled in your course in ''Course administration > Edit settings > Completion tracking''.<br />
<br />
Instead of selecting a specific activity or resources, access may be restricted to "Previous activity with completion".<br />
<br />
===Date===<br />
Access can be restricted from or until a certain date and time.<br />
<br />
[[File:availabilityrestrictionbydatefromuntil_m30.png|500px]]<br />
<br />
===Grade===<br />
You can specify a condition on any grade in the course: the full course grade, the grade for any activity, or a custom grade that you create manually. You can enter either a minimum value (at least percentage), a maximum value (less than percentage), both, or neither. The activity will only appear if the student has a value for the specified grade, and if it falls within any specified number range. You can add more than one grade condition. All conditions must be met in order for the activity to appear.<br />
<br />
* The range numbers can be fractional (with up to five decimal places) if necessary.<br />
* Be careful with the maximum value; if the maximum is 7, a student who scores exactly 7 will not see the activity. You could set it to 7.01 if you really wanted to include 7.<br />
* If creating several different activities that appear according to grade ranges, use the same number for the maximum of one activity, and the minimum of the next. For example, you might create one activity with a maximum of 7 and another with a minimum of 7. The first would appear to everyone scoring between 0 and 6.99999, and the second would appear to everyone scoring 7.00000 to 10. This guarantees that everyone with a grade will see one or other.To remove a grade condition, set the assessment name to 'none' and remove the range number values<br />
* If you want to use a condition for students with blank grades then you can add a grade restriction and select the activity you want to use as a restriction. Do not select a checkbox for either the greater than or less than criteria. This will require the student to have a grade. This means students with blank grades do not meet that criterion.<br />
<br />
===Group and groupings===<br />
If groups or groupings are used in the course, it is possible to restrict the activity to a certain group or grouping. If they are turned off for this course and not available, these options will not be present for use as an restriction.<br />
<br />
[[File:grouprestrict.png|300px]]<br />
<br />
'''NOTE''': This button only appears if you have groups '''enabled''' in your course.<br />
<br />
===User profile===<br />
<br />
Access can be restricted using one of the following user fields:<br />
<br />
* Address - This is the value in the 'address' column<br />
* AIM ID - This is the value in the 'aim' column<br />
* City/town - This is the value in the 'city' column<br />
* Country - This is the two letter country code, NOT the name of the country.<br />
* Department - This is the value in the 'department' column<br />
* Email Address - This is the value in the 'email' column<br />
* First name - This is the value in the 'firstname' column<br />
* ICQ number - This is the value in the 'icq' column<br />
* ID number - This is the value in the 'idnumber' column<br />
* Institution - This is the value in the 'institution' column<br />
* Mobile phone - This is the value in the 'phone2' column<br />
* MSN ID - This is the value in the 'msn' column<br />
* Phone - This is the value in the 'phone1' column<br />
* Skype ID - This is the value in the 'skype' column<br />
* Surname - This is the value in the 'lastname' column<br />
* Web page - This is the value in the 'url' column<br />
* Yahoo ID - This is the value in the 'yahoo' column<br />
<br />
===Restriction set===<br />
This allows you to add a set of complex restrictions to apply complex logic. See [[Using restrict access]] for an example.<br />
<br />
==Hiding the conditions==<br />
*If the eye is SHUT then students who do not meet that part of the condition will not see the activity at all.<br />
*If the eye is OPEN the students who do not meet that part of the condition will see the activity but it will be greyed out and have information about why they can't access it yet.<br />
<br />
The shut eye takes precedence. For example, you could have 2 conditions, one based on date (with eye shut) and one based on completing a previous activity (with eye open). That way, the activity will not appear at all until the date; then it will appear, but tell you that you need to complete the other activity; then when you complete the other activity you can access it.<br />
<br />
For OR and NOT AND type conditions, you only get a single eye icon instead of one for each condition<br />
<br />
[[File:daterestrict1.png]]<br />
<br />
==ALL or ANY Conditions==<br />
Further restrictions may be added by clicking the 'Add restriction' button again, and it is possible to specify that ALL the conditions or ANY of the conditions are required before the activity is made available. Thus, it is possible to use 'Or' as well as 'And' conditions. See [[Using Conditional activities]] for an example.<br />
<br />
{|<br />
|[[File:AND.png|thumb|400px|'and' condition]]<br />
|[[File:OR.png|thumb|400px|'or' condition]]<br />
|}<br />
<br />
==Restricting whole course section access==<br />
<br />
It is possible to restrict access to activities and resources within a whole course section by specifying the conditions in the settings for that particular section. Do this by editing the section settings in ''Topic menu > Edit topic > Restrict access''.<br />
<br />
[[File:sectiontopicrestrictaccess_m30.png|500px]]<br />
<br />
[[es:Configuraciones de actividades condicionales]]<br />
[[de:Einstellungen_zu_Voraussetzungen]]</div>Leonstrhttps://docs.moodle.org/310/en/index.php?title=RecordRTC&diff=139179RecordRTC2020-12-17T13:33:31Z<p>Leonstr: /* How do I get it? */ Tidy up as atto_recordrtc now in core</p>
<hr />
<div>{{Infobox plugin<br />
|type = Editors<br />
|entry = https://moodle.org/plugins/tinymce_recordrtc<br />
|maintainer = [[User:Jesus Federico|Jesus Federico]]<br />
|float = right<br />
}}<br />
==What is RecordRTC?==<br />
<br />
RecordRTC is a set of plugins for the [https://moodle.org/plugins/tinymce_recordrtc TinyMCE editor], enabling users to add audio and video annotations to text, anywhere a text editor is present. This plugin adds buttons for recording audio or video (with audio) to the editor's toolbar. [[File:recordrtc_buttons.png]] (Note that the [[Atto editor]] has this feature as standard.)<br />
<br />
Using [https://webrtc.org/ WebRTC] technologies, all recording is done instantly in the browser. After recording, users can embed the annotation directly into the text they are currently editing. The recording will appear as an audio or video player in the published writing.<br />
<br />
The plugin works fine with Chrome, Firefox and Opera on Desktop computers running Windows, Linux, Mac OS and Chrome OS.<br />
<br />
==How do I get it?==<br />
For the default Atto editor this functionality is included, no additional installation is required.<br />
<br />
For the TinyMCE editor:<br />
*Administrators whose Moodle sites allow plugins to be installed directly can install RecordRTC by clicking the Install Plugins link from the Plugins area of Site administration and then searching for the [https://moodle.org/plugins/tinymce_recordrtc TinyMCE RecordRTC plugin].<br />
*Administrators who are not able to install plugins directly can [https://moodle.org/plugins/tinymce_recordrtc download the plugin from the Moodle Plugins directory] and upload it to the server.<br />
<br />
See [[#How_do_I_set_it_up_with_Ubuntu.3F|the FAQ below for set up with Ubuntu]].<br />
<br />
=== What are the admin settings? ===<br />
The plugins will work with the defaults, but you can change them from theText editors pages (Atto or TinyMCE) from Plugins in Site administration.<br />
<br />
Administrators can:<br />
<br />
* Allow the users to record only audio, only video, or both by changing the buttons that appear in the editor toolbar.<br />
* Change the target bitrate of recorded audio.<br />
* Change the target bitrate of recorded video<br />
* Set the recording time limit, to control maximum recording size<br />
<br />
The default bitrate for recorded audio (128000) should lead to generate files of about 15kB per minute and the default bitrate for recorded video (2500000) to generate files of 20MB per minute. The lower the bitrate the smaller the file size.<br />
<br />
The recording time limit is set to 120 seconds by default so the maximum size expected on video files should be of about 40MB<br />
<br />
==How does it work?==<br />
*The Atto or TinyMCE editors will display one or both icons for audio and/or video, depending on the administrator's setting.<br />
<br />
[[File:RecordAtto.png]]<br />
*Click the icon for audio or video recording. You'll see a button 'Start recording'. Click it and speak.<br />
[[File:attachasannotation.png]]<br />
*When you have finished, click to stop the recording. It will ask you to name it and attach the recording as an annotation.<br />
<br />
== Troubleshooting ==<br />
=== Recording stops after a few seconds ===<br />
[[File:recordingrtc_error_limit_reached.png]]<br />
<br />
There are two settings that establish the maximum file size that can be uploaded to Moodle. These are defined in php.ini for the web server.<br />
post_max_size = 8M<br />
upload_max_filesize = 2M<br />
Just edit the file and increase their values to something between 40M-50M for 2 minutes video recordings. <br />
In Ubuntu<br />
vi /etc/php/7.0/apache2/php.ini<br />
<br />
You can set some large values as described in [https://tracker.moodle.org/browse/MDL-62872?focusedCommentId=654424&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-654424 this Moodle tracker issue]:<br />
post_max_size = 1024M<br />
upload_max_filesize = 1024M <br />
<br />
== Known Issues ==<br />
* The media files don't show duration<br />
* The controls for navigating the files do not work properly in the player.<br />
<br />
== F.A.Q. ==<br />
=== Why won't these plugins work with all browsers? ===<br />
WebRTC ("Web Real-Time Communication") is a collection of communications protocols and application programming interfaces that enable real-time communication over peer-to-peer connections. Implemented in browsers it enables applications such as video conferencing, file transfer, chat, or desktop sharing without the need of either internal or external plugins.[[https://en.wikipedia.org/wiki/WebRTC Wikipedia]]<br />
<br />
MediaStream Recording API, sometimes simply referred to as the Media Recording API or the MediaRecorder API, is closely affiliated with the Media Capture and Streams API and the WebRTC API. The MediaStream Recording API makes it easy to record audio and/or video streams. When used with navigator.mediaDevices.getUserMedia(), it provides an easy way to record from the user's input devices and instantly use the result in web apps. Both audio and video may be recorded, separately or together. [[https://developer.mozilla.org/en-US/docs/Web/API/MediaRecorder MediaRecorder Documentation]]<br />
<br />
As these plugins make use of diverse WebRTC technologies, they can only be used in browsers that have implemented both [[https://www.w3.org/TR/webrtc/ WebRTC 1.0]] and [[https://www.w3.org/TR/mediastream-recording/ MediaRecorder API]]. This is the case for [https://www.google.com/chrome/ Chrome], [https://www.mozilla.org/en-US/firefox/new/ Firefox] and [http://www.opera.com/ Opera]. [[https://webrtc.org/ See `Supported browsers and platforms`]] Therefore these are the only ones that the initial version of these plugins (1.0) support.<br />
<br />
Edge has implemented WebRTC 1.0 in [https://www.microsoft.com/en-us/windows/microsoft-edge Microsoft Edge] but it does not include MediaRecorder API, so implementing the plugins for this browser requires some customisation to the libraries and the use of an external server.<br />
<br />
Safari 11 for iOS will support WebRTC 1.0 [[https://webrtc.ventures/2017/06/webrtc-support-in-safari-11/ See]] but same as edge, the implementation of MediaRecorder API has not been announced.<br />
<br />
As this covers only about the 60% of the browsers, there are plans for adding support to these two browsers by making use of Media Streaming as in version 2.0 of these plugins.<br />
<br />
=== Can I have recordings of more than 2 minutes? ===<br />
Yes. That can be changed in the plugin configuration. Keep in mind that as the file size will increase, the settings in php should also be edited.<br />
Also, because the size can be too much for the browser itself, we recommend not going to large.<br />
The only solution for giving a really large limit to the file size is to include a server component for doing a progressive upload and trans coding. But the first version of these plugins do not cover that possibility.<br />
<br />
=== Where are the recordings stored? ===<br />
Storing the RecordRTC recordings is not different than storing any other media file that is uploaded to Moodle. So, it depends of the file system your Moodle server has configured.<br />
When using the default configuration, all files are stored in <code>/moodlepath/moodledata/filedir/xx/yy/</code> where xx and yy are the path defined by the API when the file was uploaded.<br />
If you are a developer interested in learning more details about this you can see [https://docs.moodle.org/dev/File_API_internals#File_storage_on_disk File storage on disk]. It is an old article but it gives a good idea on what is underneath. Also see [[Amazon S3 repository]] for information on storing files externally in Amazon S3 buckets.<br />
<br />
=== How do I set it up with Ubuntu?===<br />
* Navigate to `moodle_root_path/lib/editor/atto/plugins` or `moodle_root_path/lib/editor/tinymce/plugins`, where `moodle_root_path` is the location where Moodle is installed (ex.: `/var/www/html/moodle`)<br />
** For Atto execute <code>sudo git clone https://github.com/blindsidenetworks/moodle-atto_recordrtc.git recordrtc</code><br />
** For TinyMCE execute <code>sudo git clone https://github.com/blindsidenetworks/moodle-tinymce_recordrtc.git recordrtc</code><br />
* Log into a Moodle account with administration capabilities<br />
<br />
==Notes for system administrators ==<br />
=== Increasing max file size ===<br />
The default maximum size of uploads in PHP is very small, it is recommended to set the upload_max_filesize setting to 40M and the post_max_size setting to 50M for a time limit of 2:00 to avoid getting an alert while recording.<br />
<br />
The file size of recorded video for Firefox will likely be twice that of other browsers, even with the same settings; this is expected as it uses a different writing library for recording video. The audio file size should be similar across all browsers.<br />
<br />
== Notes for developers ==<br />
=== Updating libraries ===<br />
These plugins makes use of two libraries. Adapter.js which makes all the WebRTC magic and Bowser.js that helps to identify the browser and OS where the application is running.<br />
<br />
If trying to update Bowser or Adapter.js dependencies for the project, it is necessary to replace the named definition at the top of the file with an anonymous one, like so <br />
For Bowser.js:<br />
<br />
Old code:<br />
<code><br />
!function (root, name, definition) {<br />
if (typeof module != 'undefined' && module.exports) module.exports = definition()<br />
else if (typeof define == 'function' && define.amd) define(name, definition)<br />
else root[name] = definition()<br />
}(this, 'bowser', function () {<br />
</code><br />
<br />
New code:<br />
<code><br />
define([], function() {<br />
</code><br />
<br />
Or so for Adapter.js:<br />
<br />
Old code<br />
<code><br />
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.adapter = f()}})(function(){<br />
</code><br />
<br />
New code<br />
<code><br />
define([], function() {<br />
</code><br />
<br />
<br />
<br />
[[Category:Audio]]<br />
[[Category:Video]]<br />
[[Category:Language teaching]]<br />
<br />
[[es:RecordRTC]]</div>Leonstrhttps://docs.moodle.org/310/en/index.php?title=Using_Assignment&diff=139178Using Assignment2020-12-17T12:31:04Z<p>Leonstr: /* What are the options for submitting work in Moodle? */</p>
<hr />
<div>{{Assignment}}<br />
This page explores the different types of assignment, how students submit assignments and how teachers can grade them.<br />
<br />
==What are the options for submitting work in Moodle?==<br />
The standard ways students can submit assignments are:<br />
* File submissions (students submit a file for assessment)<br />
* Online text (students can type their responses directly in Moodle)<br />
* Audio or video (via the recording button in the [[Atto editor]])<br />
<br />
Notes:<br />
# It is also possible to use the assignment for grading an "offline assignment", ie, one where work is done outside of Moodle. This is done by simply unchecking the above three options.<br />
# If you're not sure which assignment type best suits your needs, look at the section below [[#Which type of assignment submission suits you best?]]<br />
<br />
==Which type of assignment submission suits you best?==<br />
<br />
===You want students to type shorter or longer responses directly online===<br />
<br />
*Set ''Online text'' to Yes. This works well for younger children who will only manage a sentence or two and works just as well for higher education students who write more. <br />
**Advantage - quick for the student to get started; no need to use a word-processing program and upload the file. The text is saved on a regular basis so it will be preserved if the student loses the page for some reason.<br />
**Disadvantage: if the word count is expected to be large, setting ''Online text'' to No and ''File submission'' to Yes might be a better option.<br />
<br />
===You want students to submit work you can download in a specified program===<br />
<br />
*Set ''File submission'' to Yes, set the number of files you will allow using the ''Maximum number of uploaded files'' setting and the file sizes by using the '' Maximum submission size'' setting.<br />
**Advantage - better than students emailing work as the whole class's work is collated in one space on your course. Markers can provide comments directly on the student work.<br />
**Advantage - with "Attempts reopened" enabled, teachers can see the progression through various drafts of a student's work.<br />
**Disadvantage - assignments must downloaded to be viewed (but they can be [[Assignment_FAQ| downloaded in bulk]]) and the teacher needs the appropriate program to open them.<br />
<br />
===You want students to submit files at different times for a project===<br />
<br />
*Set ''File submission'' to Yes, and use ''Maximum number of uploaded files'' to set the maximum number of separate files they can upload<br />
**Advantage - all project files are in one assignment area for grading so they get a single grade.<br />
**Disadvantage - all project files are in one assignment area for grading - so they can only have a single grade!<br />
<br />
===You want students to write a response to a video/sound file/image===<br />
<br />
*Set up an assignment allowing ''online text'' submission and get students to use the Moodle media icon to add video/sound/image files. <br />
<br />
===You want students to answer a series of questions on a video/sound file/image===<br />
*Investigate the [[Quiz]] module. Assignments are really just for a single question.<br />
<br />
===You want to grade work students have done offline===<br />
*Uncheck the submission types when setting up the assignment. Students won't be required to do anything but you can use the assignment to grade them for work done outside of Moodle.<br />
<br />
===You want to view, comment on and send back students' assignments===<br />
<br />
*Set up an assignment allowing ''file submissions''.<br />
**Advantage: useful for teachers who like using the "comment" options in word-processing programs for example. If you have Ghostscript enabled on your server and the students upload PDF files, you can annotate them inline. See the section [[Using Assignment#Annotating PDF files| Annotating PDF files]] below.<br />
**Disadvantage: if students upload other file types, you have to download them, comment and then re-upload them.<br />
<br />
===You want students to send you a comment or note along with their uploaded work===<br />
<br />
*Although previous versions of Moodle allowed the ''Submission comments'' submission plugin to be toggled, this is no longer the case. If [[Comments#Enabling_comments|comments are enabled site-wide]], students will be able to add submission comments; if comments are disabled site-wide, students will not be given the option to add submission comments.<br />
<br />
===You want to allow students to redraft and decide when to submit the work===<br />
<br />
*In the settings set ''Require students click submit button'' to Yes. Students can then control when their draft work is submitted to the teacher. <br />
<br />
===You want students to keep an ongoing journal or do an iterative assignment===<br />
<br />
*In the settings set ''Require students click submit button'' to No. Students can continue to make changes to their assignment and at no point do they 'submit'. If the work will be graded at some point it is recommended that either ''Prevent late submissions'' is set to Yes to ensure that no changes can be made after the due date, or [[Using_Assignment#Submission_status| all submissions are locked]] when grading commences to ensure that the work is not altered during grading.<br />
**Advantage: the work remains in one place and is constantly improved, graded (if needed) and improved again. <br />
**Disadvantage: there is no record/history of previous attempts (such as with the [[Wiki]]). The online text assignment does not replicate the display of a journal or blog where each new entry is additional to the previous ones.<br />
<br />
===You want students to submit work in groups===<br />
<br />
*In the settings, set "Students submit in groups" to Yes. If you just do this, then once one student has submitted, the assignment will be flagged as submitted even if the others haven't contributed. If you want to ensure everyone has an input, set "Require students click submit button" to Yes and then change "Require all group members to submit" to Yes. The assignment will only be classed as submitted when each member has contributed, and once one student has submitted, the remaining members's names will be displayed for the group to see who still needs to add their input.<br />
<br />
===You want to grade students' work anonymously===<br />
*In the settings, choose "Blind marking". When students submit assignments, their names will be replaced by randomly-generated participant numbers so you will not know who is who. Note that this is not '''totally''' blind marking because you can reveal their identities in the assignment settings and you can work out identities from the logs - so this might not be suitable if your establishment has very precise privacy requirements.<br />
<br />
===You want to read and grade student assignments offline===<br />
*In the settings, choose "Offline grading worksheet". When students have submitted, click "View/grade all submissions" and you can download their assignments from the link "Download all submissions" and download the grading sheet from the link "Download grading worksheet". You can then edit grades and re-upload the grading worksheet. You can also upload multiple feedback files in a zip from this drop down menu. See [[Assignment settings]] for an explanation of how to use the "upload multiple feedback files as zip" feature.<br />
<br />
===You want to hide students' grades until a time of your choosing.===<br />
Use 'marking workflow' as explained in [[Assignment settings]]<br />
<br />
===You want to moderate other colleagues' marking or allocate certain teachers to certain students===<br />
Use 'marking allocation' as explained in [[Assignment settings]]<br />
==How do students submit their assignments?==<br />
The first page students will see when they click on the assignment activity link from the course page will display the assignment name, description and the submission status. The first time a student views the assignment it will look like this:<br />
{|<br />
|[[Image:statuses.jpg|thumb|Student view of assignment]] <br />
|}<br />
The submission status section includes:<br />
*'''Submission status''' <br />
*'''Grading status'''<br />
*Due date<br />
*Time remaining<br />
*Last modified<br />
*Submission details<br />
<br />
As they progress through the assignment the Submission status and Grading status will update and the Last modified date will appear.<br />
{|<br />
|[[Image:submission statuses graded.jpg|thumb|Example of submitted and graded assignment]] <br />
|}<br />
<br />
If the student uploaded a file which the teacher has annotated, this will be made available in the feedback section. The student can search through the document and filter specific comments.<br />
{|<br />
|[[File:26pdfstudentgraded.png|thumb|Student view of graded pdf file]]<br />
|[[File:26searchcomments.png|thumb|Searching and filtering comments in annotated pdf]]<br />
|}<br />
Submission statuses include:<br />
<br />
*Nothing submitted for this assignment<br />
*Draft (not submitted)<br />
*Submitted for grading<br />
<br />
Grading statuses include:<br />
<br />
*Not graded<br />
*Graded<br />
<br />
===File submission===<br />
To submit a file submission, students complete the following steps:<br />
<br />
# Click the ‘Add submission’ button to bring up the file upload page.<br />
# Upload the relevant file into the submission. They are able to ‘drag and drop’ the file into the submission box.<br />
# Click ‘Save Changes’.<br />
<br />
There should now be a Last modified date and the file(s) uploaded will also be displayed. Depending on how the assignment is setup the status will either read ‘Submitted for grading’ - in which case no further action is need, or ‘Draft (not submitted)’.<br />
<br />
# If changes are required, click on ‘Edit my submission’.<br />
# Once ready to submit, click ‘Submit assignment’.<br />
<br />
Note that once the assignment is 'submitted’ no further changes are allowed.<br />
<br />
{|<br />
|[[File:file upload.jpg|thumb|Student view when adding a submission]]<br />
|[[File:file uploaded.jpg|thumb|Student view once file is uploaded]]<br />
|[[File:submit button.jpg|thumb|Student view when submitting assignment]]<br />
|}<br />
Note: Depending on how the assignment is setup students may see '''both''' a file submission page and an online text editor.<br />
<br />
===Access controlled links===<br />
If the administrator has enabled this feature for either the [[Google Drive repository]] or the [[OneDrive repository]] then students can upload a file as an 'access controlled link' from either of these repositories. The file is then copied to the site account and the student is no longer able to edit it.The student retains the original file in their own Google Drive or OneDrive. The teacher is given permission to edit the file for grading purposes, and the student is sent a copy of the edited file.<br />
[[File:accesscontrolledlink.png|center|thumb|Student submits an access controlled link]]<br />
<br />
===Online text===<br />
To submit online text, students complete the following steps:<br />
<br />
# Click the ‘Add submission’ button to bring up the online text editor page. <br />
# Type the relevant text into the [[Text_editor|text editor]], or paste from a previously written file.<br />
# Click ‘Save Changes’.<br />
<br />
There should now be a Last modified date and the first 100 characters entered will also be displayed. Depending on how the assignment is setup the status will either read ‘Submitted for grading’ - in which case no further action is need, or ‘Draft (not submitted)’.<br />
<br />
# If changes are required, click on ‘Edit my submission’.<br />
# Once ready to submit, click ‘Submit assignment’.<br />
<br />
Note that once the assignment is 'submitted’ no further changes are allowed.<br />
<br />
{|<br />
|[[File:online text entered.jpg|thumb|Online text entered]]<br />
|[[File:submit button online text.jpg|thumb|Submitting assignment]]<br />
|}<br />
<br />
===Submission comments===<br />
If enabled by the administrator, there may be a section where students can leave submission comments.<br />
{|<br />
|[[Image:student comments.jpg|thumb|Student comments]]<br />
|}<br />
<br />
==How do teachers grade assignments?==<br />
When students have submitted their assignments, they can be accessed by clicking on the assignment activity. This will bring up the Grading Summary page.<br />
<br />
The Grading Summary page displays a summary of the assignment, including; number of participants, number of drafts, number of submitted assignments, due date and time remaining.<br />
<br />
Clicking 'Grade' will take you to the first student in the list so you can start grading individually. If you wish to grade several assignments, clicking Save and Show next will take you to the next submission.<br />
<br />
[[File:saveandshownext.png|center|thumb|400px]]<br />
<br />
Clicking 'View all submissions' will take you to the grading table where you see all students.<br />
<br />
The Grading Table contains columns of information about the student, the status of their submission, a link to grade their submission, a link to each submission and feedback comments and files (if enabled). <br />
<br />
===Filtering submissions===<br />
<br />
A dropdown menu accessed from the 'Options' section allows you to filter submissions so you can for example quickly see which students have not submitted yet.<br />
<br />
You can also filter submissions which have had extensions granted.<br />
<br />
[[File:filterassignments.png]]<br />
<br />
===Allocating submissions to markers===<br />
If you need to divide submissions between more than one person, you can apply groups to the assignment and let markers know which group(s) to mark. Note that because group membership is not itself anonymised, this may make anonymised submissions that bit less anonymous, though as long as the groups aren't very small this should be acceptable.<br />
<br />
An alternative is to use [[Assignment_settings#Use_marking_allocation|marking allocation]] - this allows anyone with a teacher role to allocate one marker to each submission. This works particularly well if marking is allocated by subject specialism.<br />
<br />
===Submission status===<br />
If you will be assigning grades to student work, you may want to take note of the submission status before you begin the marking process. If you have required students click the Submit button, you may find that some submissions are still marked as Draft (not submitted), meaning the student has either uploaded a file(s) or entered some text, but has not clicked ‘Submit assignment’. <br />
<br />
If it's after the due date and you are about to commencing marking that you use ‘Prevent submission changes’ to stop students from making changes to their assignment. You can do this one by one by using the icon in the Edit column.<br />
<br />
Or you can select two or more students by putting a tick in the select column and going to 'Lock submissions’ from the ''With selected'' menu under the grading table.<br />
<br />
Likewise you can also revert a student's submission to draft if they have uploaded the incorrect file. Instead of selecting ‘Prevent submission changes’ select ‘Revert the submission to draft’, or place ticks against selected students and choose 'Revert the submission to draft status' from the ''With selected'' menu under the grading table.<br />
<br />
{|<br />
|[[File:submission statuses.jpg|thumb|Submission statuses]]<br />
|[[File:prevent submission changes dropdown.jpg|thumb|Prevent submission changes dropdown]]<br />
|[[File:lock submissions.jpg|thumb|Lock submissions]]<br />
|[[File:revert to draft.jpg|thumb|Revert to draft]]<br />
|[[File:revert submission to draft status.jpg|thumb|Revert to draft status]]<br />
|}<br />
<br />
If the submission setting 'Attempts reopened' is set to 'Automatically until pass' and a submission is graded below the grade to pass, then then submission is automatically unlocked when the grade is saved. Similarly, if the submission setting 'Attempts reopened' is set to Manually, and a teacher selects 'Allow another attempt, then the submission is automatically unlocked. <br />
<br />
===Overriding assignment deadlines===<br />
<br />
A teacher can override a deadline for an individual or group from the assignment settings link (gear menu in the [[Boost theme]] or Assignment administration other themes.) See the screencast [https://youtu.be/5Ghe7rueIME Assignment overrides] for a demo.<br />
[[File:AssignmentOverridesBoost.png||thumb|center|600px]]<br />
<br />
When adding overrides for a group, it is possible to have one group override trump another. This is achieved by moving the override up/down on the group overrides page:<br />
<br />
[[File:AssignGroupOverrides.png|||center]]<br />
<br />
In this situation, a student in both groups (e.g. Frodo Baggins) will have the override from "The Council of Elrond" applied. By pressing the arrow icons on the right, the override for "The Fellowship" can be moved to the top of the list, and will have higher precedence.<br />
<br />
Note also that if there exists a user override for a student, it will always take precedence over any group overrides.<br />
<br />
===Granting extensions===<br />
If an assignment has a deadline, a teacher can grant individual or group assignment extensions by selecting the Edit link next to a particular student or group.<br />
<br />
#To grant an extension, open the assignment<br />
#Click on "View all submissions"<br />
#Locate the student who is to be allowed to submit after the "Cut-off date"To<br />
#Click on the adjacent "Edit" drop down menu and select "Grant extension"<br />
##[[File:grantextension0.png|thumb|center|600px]]<br />
#Set the extension date and time. The student's or group's name is also shown on this screen.<br />
##[[File:grantextension.png||thumb|center|600px]]<br />
#Click on "Save changes".<br />
<br />
===Quick grading===<br />
<br />
'''Quick grading''' allows you to enter numeric grades directly into the grading table, bypassing the more detailed grading interface. Please note:<br />
*if you want to give feedback, you need to use the more detailed Grade interface. <br />
*Quick grading is incompatible with advanced grading e.g. Rubrics, and is not recommended when there are multiple markers. <br />
*'''Submission comments''' are a two-way private conversation between a student and staff and are visible to students immediately i.e. markers use the grading interface to give feedback, not the submission comments.<br />
<br />
To access the Quick Grading interface, from the Grading Summary page click 'View all submissions'; the Grading Table displays. Scroll to bottom of the page to configure Options, and check the box for 'Quick grading'. While you're down there, you can also set the number of assignments to display per page, filter the assignments e.g. to see who has not submitted, unmarked assignments, etc.<br />
<br />
When you are ready to Quick Grade: <br />
<br />
#You can enter grades directly into the grading table. <br />
#Scroll to the bottom of the grading table and click 'Save all quick grading changes'<br />
#A confirmation displays.<br />
<br />
===Grading individual submissions===<br />
If you have enabled File Feedback in the [[Assignment settings]] and wish to upload either the marked student assignment, a completed text based feedback document or audio feedback, click on the green tick in the Grade column (or use the icon in the Edit column and select Grade).<br />
<br />
This brings you to the Student Grading Page where you can give grades, feedback comments and feedback files (if enabled in the [[Assignment settings]]). You can use drag and drop to upload feedback files.<br />
<br />
{|<br />
|[[File:green tick.jpg|thumb|Green tick]]<br />
|[[File:grade.jpg|thumb|Grading]]<br />
|[[File:feedbackfiles.png|thumb|Feedback files]]<br />
|}<br />
<br />
====Annotating submissions====<br />
<br />
If the student has uploaded a PDF, docx or odt file, or if you set 'Comment inline' for an online text submission, then their submission will be displayed on the grading screen, allowing you to annotate it (requires [http://www.ghostscript.com/ Ghostscript] for PDF and [[Universal Office Converter (unoconv)|unoconv]] for docx and odt files), using a variety of tools, stamps (if uploaded by the admin) and comments which may be saved to a comments bank. When the annotations are complete, clicking to save the changes will result in it being displayed to the student as part of their feedback. <br />
<br />
'Rotate' icons let you change the orientation of an uploaded document if the student submitted it in landscape mode for example.<br />
<br />
<br />
[[File:AnnotatingAssignment.png|thumb|500px|center|Annotating a student's submission]]<br />
<br />
Comments may be added and then saved in a quick list for future use ''(1)'' Click the paper/magnifying glass icon to the right of the page selector to filter comments you have already added to the work''(2)'':<br />
*In the '''Search comments''' pop-up window, enter the term you would like to search for in the '''Filter comments...''' box. <br />
*Clicking on the comment will take you to the part of the paper where that comment has been added.<br />
<br />
{|<br />
|[[File:NFaddcomment.png|thumb|400px|1.Saving and re-using comments]]<br />
|[[File:NFcommentsearch.png|thumb|400px|2. Accessing comments]]<br />
|}<br />
<br />
Note: To ensure that comments display to students as the marker intends, do instruct students to download the annotated PDF rather than just previewing it. Preview sometimes displays comments in a way which obscures the original text.<br />
<br />
The review panel and / or the grading panel may be collapsed by clicking the icons at the bottom right of the screen.<br />
<br />
[[File:CollapseReviewPanel.png|center]]<br />
<br />
===Controlling when to notify students of graded work===<br />
<br />
====Notifying as you mark====<br />
<br />
If you need to notify individual students, one by one, as you mark, the '''Notify students''' checkbox is available when grading individual submissions. Choose Yes to notify the student immediately or No to grade without notifying the student. Assuming you are not hiding grades in the ways outlined below, then Moodle will send a notification.<br />
<br />
Note: How students receive Moodle notifications depends on your local default settings, and any changes students have made to those.<br />
<br />
[[File:notifystudents.png|center|thumb|500px]]<br />
<br />
====Keeping grades hidden until a release date====<br />
<br />
Assessors often decide to hide grades and feedback until marking is complete and finalised, and then release them all at once. There are two alternatives for this. <br />
<br />
*[[Grade_hiding|Hide the item in the Grader Report]]. This is convenient if there are few markers and you have decided a provision date for releasing the marks and feedback. <br />
*Or enable [[Assignment_settings#Use_marking_.28grading.29_workflow|Use marking workflow]] in the Assignment's settings. This way is best where there are many markers, and/or you don't have a provisional date to release marks and feedback. <br />
<br />
(If you would like the Moodle Assignment to have its own setting for releasing grades and feedback to students please vote for MDL-18722.)<br />
<br />
====Examples of Marking workflow====<br />
<br />
One marker, Marker, wants to release all grades at the same time <br />
* Marker enables "Use marking workflow" <br />
* Marker marks each submission and transitions the grading to "Marking completed" as each submission is graded. <br />
* Marker then uses the batch operations to transition all grades to "Released" at the same time. <br />
<br />
Multiple markers, <br />
* Marker enables "Use marking workflow" <br />
* Marker marks each submission and transitions the grading to "Marking completed" as each submission is graded. <br />
* Marker then uses the batch operations to transition all grades to "Released" at the same time.<br />
<br />
===Offline marking - downloading and uploading multiple grades and feedback files===<br />
<br />
If you don't have an internet connection or prefer to grade outside Moodle, you can do so (including with anonymous submissions).<br />
These easy stages explained below:<br />
#Download the submissions<br />
#Download the spreadsheet (grading worksheet) to record grades.<br />
#Grade and annotate (if applicable) the submitted work.<br />
#Upload the completed grading worksheet.<br />
#Upload the annotated submissions (if applicable).<br />
<br />
Note:You cannot upload marks and feedback to Moodle if you have enabled Rubrics or Marking Guides.<br />
<br />
====Before you start, enable the multiple file upload settings====<br />
Go to the settings of that assignment.<br />
For Feedback types, ensure that the Moodle Assignment settings, Feedback comments, Feedback files, and Offline grading worksheet are ticked. <br />
<br />
====Downloading student submissions====<br />
<br />
You can download a zip file containing all of the assignment submissions by selecting ‘Download all submissions’ from the 'Grading actions' menu at the top of the grading table, or in the settings menu. <br />
<br />
File submissions will be downloaded in the format uploaded by the student. Online text submissions will be downloaded as html files. Each file in the zip will be named with the student first and last name followed by a unique identifier (not the user ID number).<br />
<br />
If each submission is more than a single file, then submissions may be downloaded in folders by ticking the option 'Download submissions in folders' (below the grading table). Each submission is put in a separate folder, with the folder structure kept for any subfolders, and files are not renamed. Each folder will be named with the student first and last name followed by a unique identifier (not the user ID number).<br />
<br />
You can also download selected assignment submissions (rather than all of them) by selecting the ones you want and then choosing 'With selected....Download selected submissions'.<br />
<br />
====Download the Grading Worksheet to record grades ====<br />
#Next, to download the spreadsheet in which you'll enter the grades and brief comments, return to the Moodle Assignment page and from its Grading action drop-down menu choose Download grading worksheet and save that file (keep its csv file format).<br />
<br />
Note: Helpfully that downloaded worksheet will contain any existing grades and summary comments which have already been given for that assignment i.e. if marking has already started. However, to see pre-existing comments fully you may need to set your spreadsheet to 'wrap text' within cells.<br />
<br />
====Grade and annotate (if applicable) the submitted work====<br />
After downloading the submissions and the grading worksheet:<br />
#Open a downloaded assignment file to assess it. <br />
#Open the csv file in a spreadsheet editor e.g. Excel. <br />
#For that student's record (if anonymous, a number corresponding to the submission file name will display), enter grades in the Grade column and summary comments in the Feedback comments column for each student. <br />
#Leave the other data untouched unless you know exactly what you're doing.<br />
#Repeat as needed.<br />
#Save the csv file.<br />
<br />
Note: Take care to enter data in the correct column of the spreadsheet.<br />
<br />
If you are annotating the submissions to return to students as feedback:<br />
#Open a downloaded submission.<br />
#Carry out your annotations.<br />
#Save it in its original place i.e. the folder corresponding to that student.<br />
#Repeat as needed.<br />
If you have separate feedback files to upload to students:<br />
#Save these within that student's folder.<br />
#You can give students multiple feedback files in this way e.g. annotations on their work along with a separate pro forma.<br />
<br />
Note: Don't change the name or location of the folder - Moodle needs this information to allocate the files correctly.<br />
<br />
Compress (zip) all the feedback files:<br />
<br />
#Locate the folder containing the feedback files in Moodle, select them all (Ctrl+A within the folder), then zip them: <br />
##Windows: Right click one of the selected files and Send to > Compressed (zipped) folder.<br />
##Mac: Right Click (or Ctrl+click) one of the selected files and click Compress.<br />
#They are now ready for upload (see below).<br />
<br />
====Upload the completed grading worksheet====<br />
When you are ready to upload grades and summary feedback:<br />
#Click on the assignment name on the Moodle course homepage to access the summary page and click '''View/grade all submissions'''.<br />
#From the Grading action drop-down menu choose '''Upload grading worksheet'''.<br />
#Click '''Choose a file...''' and upload the grading worksheet to Moodle, or drag the csv file to the arrow and wait for the file name to appear in the box.<br />
#There is a checkbox to '''overwrite records that have been modified more recently in Moodle than in the spreadsheet''' - only check this if you want to spreadsheet to overwrite all Moodle records, including ones made more recently than the spreadsheet.<br />
#Click '''Upload grading worksheet'''; a Confirmation box displays the students grades and feedback that will be imported - check this carefully.<br />
#If you are ready to proceed, click '''Confirm'''; a summary of updates displays.<br />
#Click '''Continue'''.<br />
<br />
====Upload feedback files (if applicable)====<br />
#Click on the assignment name on the Moodle course homepage to access the summary page and click '''View/grade all submissions'''.<br />
#From the Grading action drop-down menu choose '''Upload multiple feedback files in a zip'''.<br />
#Click '''Choose a file...''' and upload the zipped assignments file to Moodle, or drag the compressed/zipped file to the arrow and wait for the file name to appear in the box.<br />
#Click '''Import feedback file(s)'''.<br />
#The Confirmation box will list all the feedback files and student names that will be imported.<br />
#Click '''Confirm'''; the next screen summarises the changes.<br />
#Click '''Continue'''.<br />
#From the page containing the Grading Table, you can check your feedback files by enabling Quick grading (see Options at the bottom of that page) and scrolling horizontally, if needed.<br />
<br />
For an assignment with no file submissions, see the discussion [https://moodle.org/mod/forum/discuss.php?d=336438 upload feedback files without student file submissions] for details of what to do.<br />
<br />
===Give the same feedback file to multiple students===<br />
If you have high level feedback you want to give to an entire cohort, it is generally a good idea to give this feedback in the context of the assignment, rather than e.g. separately via a Forum. Moodle allows you to select some or all students and attach a single, common feedback file to their assignment feedback. This common feedback will appear to each student along with any other individual feedback files you have prepared for each. <br />
#Prepare the single file of feedback.<br />
#Click on the link to the Assignment; its summary page displays.<br />
#Click '''View all submissions'''; the assignment's Grading Table displays.<br />
#Use the checkboxes to select all or some students to receive the feedback (you may first prefer to configure the Grading Table to show as many students as possible on a single page).<br />
#Underneath the Grading Table click the '''With selected...''' menu, choose '''Send feedback files''', then click '''Go'''; a page displays a list of selected students above a file upload area.<br />
#Upload the file of feedback you prepapred, or drag it to the arrow and wait for the file name to appear in the box.<br />
#Click '''Send feedback files'''; the Grading Table displays again.<br />
#Check your file is in place by scrolling horizontally to the '''Feedback files''' column.<br />
<br />
==Keeping records (archiving, exporting, backing up)==<br />
When students unenrol from a Moodle area, their records become invisible through the Gradebook interface. In order to have the information to hand, departments or course teaching teams may need systems in place to keep their own records for the data retention period required in their particular context. There are two separate procedures for exporting student submissions and marks.<br />
<br />
To export marks (with or without feedback):<br />
#Go to your course administration block and click Grades.<br />
#From the Grader Report Settings block, select Export; a menu displays.<br />
#From the menu, if you need easy viewing and running calculations you probably want to select one of the spreadsheet formats; a page of export settings loads<br />
#Use the Visible Groups pulldown menu to limit the export to specific groups, as required<br />
#In Options, you indicate whether feedback comments are included<br />
#In Grade Items To Be Included lists you can, if required, omit particular Activities from the report<br />
#When you've finished with the settings, click on Submit; a preview of your export displays<br />
#Click on Download to export to the format you chose, and save the file.<br />
<br />
To download the original student submissions:<br />
#In your course area, click the link to the Assignment whose submissions you want to download.<br />
#Click on the link to View/Grade all submissions; the Grading Table will load.<br />
#Click the link to 'Download all submissions' and save the file.<br />
==Tips and Tricks==<br />
* Want to use an Assignment activity again in another Moodle site? Use the [[Activity_backup| backup and restore]] options. <br />
*Want to use an Assignment activity in another course you teach? Use the [[Import_course_data| Import function]] in the course administration block.<br />
*Moodle will sometimes appear not to be uploading a resubmitted assignment - you seem to be downloading the original assignment. This is a cache issue, in short, go to ''"Tools > Clear Recent History"'' in Firefox or ''"Tools > Delete Browsing History > Delete Temporary Files"'' in Windows Explorer. The newer file will then appear.<br />
<br />
==See also==<br />
<br />
===Examples from [https://school.moodledemo.net School demo site]===<br />
<br />
* [https://school.moodledemo.net/mod/assign/view.php?id=573&rownum=3&action=grade Teacher view of a PDF assignment which can be annotated inline.]Log in with username 'teacher' and password 'moodle'<br />
* [https://school.moodledemo.net/mod/assign/view.php?id=573&action=grading Teacher view of allocated markers and marking workflow status.] Log in with username 'teacher' and password 'moodle'<br />
* [https://school.moodledemo.net/mod/assign/view.php?id=190 Student view of an assignment.] Log in with username 'student' and password 'moodle'. Scroll down to see the rubric and feedback.<br />
* [https://school.moodledemo.net/mod/assign/view.php?id=46&action=editsubmission Student view of a student submission statement] Log in with username 'student' and password 'moodle'<br />
* [https://school.moodledemo.net/mod/assign/view.php?id=715 Student view of group assignment grading screen] Log in with username 'student' and password 'moodle'<br />
* [https://school.moodledemo.net/mod/assign/view.php?id=715&action=grading Teacher view of a group assignment grading screen] Log in with username 'teacher' and password 'moodle'.<br />
* [https://school.moodledemo.net/mod/assign/view.php?id=191&action=grading Teacher view of blind marking grading screen] Log in with username 'teacher' and password 'moodle'<br />
<br />
===Other===<br />
* [http://www.somerandomthoughts.com/blog/2013/07/07/one-approach-for-group-project-grading/ One approach to group project grading] blog post by Gavin Henrick<br />
* [http://moodle.org/mod/forum/discuss.php?d=201307 Advantages of using Assignment upload over emailing a document] forum discussion<br />
<br />
<br />
[[de:Aufgabe nutzen]]<br />
[[fr:Afficher un devoir]]<br />
[[ja:課題を表示する]]<br />
[[es:Usando Tarea]]</div>Leonstrhttps://docs.moodle.org/310/en/index.php?title=Talk:Installing_Moodle&diff=138727Talk:Installing Moodle2020-11-04T11:31:30Z<p>Leonstr: Note about edit https://docs.moodle.org/310/en/index.php?title=Installing_Moodle&oldid=138726</p>
<hr />
<div><blockquote>"'''Oracle and MSSQL are fully supported''' (but may never have been tested for optional plugins) but documentation and '''support is limited'''".</blockquote> (emphasis added)<br />
How can they be fully supported if support is limited? Perhaps there should be a better explanation of what is meant by "support" here?<br />
<br />
[[User:Mark Johnson|Mark Johnson]] 16:48, 23 January 2012 (WST)<br />
<br />
Fair point - improved I hope --[[User:Howard Miller|Howard Miller]] 22:52, 21 March 2012 (WST)<br />
<br />
----<br />
<br />
<blockquote>It is strongly recommended to use ACL when your server supports it ... <code>chmod -R +a ...</code></blockquote><br />
<br />
The docs suggest a specific syntax for setting ACLs that only seems to work on OSX instead of Linux systems which is what the Requirements section suggestions this document is primarily focused on.<br />
<br />
The ACL given also seems to directly against the security advice also given on that page. <code>It is vital that the files are not writable by the web server user</code><br />
<br />
--[[User:Chris Francy|Chris Francy]] ([[User talk:Chris Francy|talk]]) 04:51, 1 February 2014 (WST)<br />
<br />
I agree and think that talk of ACL's it confusing and unnecessary in the standard install docs.<br />
<br />
--[[User:Paul Verrall|Paul Verrall]] ([[User talk:Paul Verrall|talk]]) 21:55, 30 November 2015 (AWST)<br />
<br />
: Thanks Chris and Paul for your comments. Please feel free to edit the info and remove or amend the references to ACL. --[[User:Helen Foster|Helen Foster]] ([[User talk:Helen Foster|talk]]) 23:12, 30 November 2015 (AWST)<br />
<br />
:What is the way to do it without ACL? Is it safe to just allow write access to all users? Or should www-data be added to a group and only allow the group write access? Is ACL better in some way? Thanks in advance! --[[User:Lexi K|Lexi K]] ([[User talk:Lexi K|talk]]) 15:12, 29 April 2020 (UTC)<br />
<br />
----<br />
<br />
Please see Create an empty database section and check if --<blockquote> Oracle (known issues, not fully supported)<br />
</blockquote> -- is correct or which Moodle version affects. When you go and see release_notes for Software requirements, don't say anything about issues. --[[User:Carina Martinez 2|Carina Martinez 2]] ([[User talk:Carina Martinez 2|talk]]) 00:43, 20 November 2014 (AWST)<br />
<br />
----<br />
<br />
Removed "(recommended)" for PostgreSQL, MariaDB as these were unclear, e.g. https://moodle.org/mod/forum/discuss.php?d=413245#p1666339. Particularly unsure why MySQL isn't recommended, Moodle now insists the MariaDB version has a support lifetime overlapping the Moodle version (MDL-65809) which may make MySQL a better choice for some wanting a longer support lifetime. Suggest adding a reason as why it's recommended. [[User:Leon Stringer|Leon Stringer]] ([[User talk:Leon Stringer|talk]]) 11:30, 4 November 2020 (UTC)<br />
<br />
----</div>Leonstrhttps://docs.moodle.org/310/en/index.php?title=Installing_Moodle&diff=138726Installing Moodle2020-11-04T11:23:07Z<p>Leonstr: /* Create an empty database */ Removed "(recommended)" for PostgreSQL, MariaDB as these were confusing: https://moodle.org/mod/forum/discuss.php?d=413245</p>
<hr />
<div>{{Template:Installing Moodle}}<br />
''This page explains how to install Moodle. If you are an expert and/or in a hurry try [[Installation Quickstart]].''<br />
<br />
If you just want to try Moodle on a standalone machine there are 'one-click' installers for Windows (see [[Complete install packages for Windows]]) and for OSX (see [[Complete Install Packages for Mac OS X]]) or [[ install on OS X]]. These are unsuitable for production servers.<br />
<br />
If you want to avoid installing Moodle yourself completely, consider https://moodlecloud.com/<br />
<br />
== Requirements ==<br />
<br />
Moodle is primarily developed in Linux using [[Apache]], [[PostgreSQL]]/[[MySQL]]/[[MariaDB]] and [[PHP]] (sometimes known as the LAMP platform). Typically this is also how Moodle is run, although there are other options as long as the software requirements of the [{{Release notes}} release] are met.<br />
<br />
If you are installing Moodle in a Windows server, note that from php5.5 onwards, you will also need to have the Visual C++ Redistributable for Visual Studio 2012 installed from:<br />
http://www.microsoft.com/en-us/download/details.aspx?id=30679 Visual C++] ( x86 or x64) <br />
<br />
The basic requirements for Moodle are as follows:<br />
<br />
=== Hardware === <br />
* Disk space: 200MB for the Moodle code, plus as much as you need to store content. 5GB is probably a realistic minimum. <br />
* Processor: 1GHz (min), 2GHz dual core or more recommended.<br />
* Memory: 512MB (min), 1GB or more is recommended. 8GB plus is likely on a large production server<br />
* Consider separate servers for the web "front ends" and the database. It is much easier to "tune"<br />
<br />
All the above requirements will vary depending on specific hardware and software combinations as well as the type of use and load; busy sites may well require additional resources. Further guidance can be found under [[Performance_recommendations|performance recommendations]]. Moodle scales easily by increasing hardware.<br />
<br />
For very large sites, you are much better starting with a small pilot and gaining some experience and insight. A "what hardware do I need for 50,000 user?" style post in the forums is highly unlikely to get a useful answer.<br />
<br />
=== Software ===<br />
<br />
See the [{{Release notes}} release notes] in the dev docs for software requirements.<br />
<br />
== Set up your server ==<br />
<br />
Depending on the use case a Moodle server may be anything from a Desktop PC (e.g. for testing and evaluating) to a rackmounted or [[Server cluster|clustered]] solution to cloud VMs or other hosted solutions. As mentioned above there are lots of possibilities for installing the basic server software, some links and pointers are at [[Installing AMP]], [[Internet_Information_Services|IIS]], [[Nginx]]. <br />
<br />
It will help hugely, regardless of your deployment choices, if time is taken to understand how to configure the different parts of your software stack (HTTP daemon, database, PHP etc). Do not expect the standard server configuration to be optimal for Moodle. For example, the web server and database servers will almost certainly require tuning to get the best out of Moodle.<br />
<br />
If a hosting provider is being used ensure that all Moodle [{{Release notes}}#Server_requirements requirements] (such as PHP version) are met by the hosting platform before attempting the installation. It will help to become familiar with changing settings within the hosting provider's platform (e.g. PHP file upload maximums) as the options and tools provided vary.<br />
<br />
== Download and copy files into place ==<br />
<br />
'''IMPORTANT: While there are now a number of places you can get the Moodle code (including host provided Moodle installers), you are strongly advised to only obtain Moodle from moodle.org. If you run into problems it will be a great deal easier to support you.'''<br />
<br />
You have two options:<br />
* Download your required version from http://moodle.org/downloads and unzip/unpack...<br />
* '''OR''' Pull the code from the Git repository (recommended for developers and also makes upgrading very simple):<br />
<pre><br />
$ git clone -b MOODLE_{{Version3}}_STABLE git://git.moodle.org/moodle.git <br />
</pre><br />
<br />
For a fuller discussion see [[Git for Administrators]]. <br />
<br />
Either of the above should result in a directory called '''moodle''', containing a number of files and folders. <br />
<br />
You can typically place the whole folder in your web server documents directory, in which case the site will be located at '''<nowiki>http://yourwebserver.com/moodle</nowiki>''', or you can copy all the contents straight into the main web server documents directory, in which case the site will be simply '''<nowiki>http://yourwebserver.com</nowiki>'''. See the documentation for your system and/or web server if you are unsure. <br />
<br />
:''Tip:'' If you are downloading Moodle to your local computer and then uploading it to your hosted web site, if possible upload the compressed file and decompress at the remote end (check your 'file manager'). Failing that, watch FTP progress carefully for errors or missed files.<br />
<br />
* '''Secure the Moodle files:''' It is vital that the files are not writeable by the web server user. For example, on Unix/Linux (as root):<br />
<pre><br />
chown -R root /path/to/moodle<br />
chmod -R 0755 /path/to/moodle<br />
</pre><br />
(files are owned by the administrator/superuser and are only writeable by them - readable by everyone else)<br />
<br />
On test/dev sites you ''may'' want to make the files writeable in order to use the built in plugin installer. This is discouraged for live sites (at least, revert to more secure settings if you do).<br />
<br />
== Create an empty database ==<br />
<br />
Next create a new, empty database for your installation. You need to find and make a note of following information for use during the final installation stage:<br />
* '''dbhost''' - the database server hostname. Probably ''localhost'' if the database and web server are the same machine, otherwise the name of the database server<br />
* '''dbname''' - the database name. Whatever you called it, e.g. ''moodle'' <br />
* '''dbuser''' - the username for the database. Whatever you assigned, e.g. ''moodleuser'' - do not use the root/superuser account. Create a proper account with the minimum permissions needed.<br />
* '''dbpass''' - the password for the above user<br />
<br />
If your site is hosted you should find a web-based administration page for databases as part of the control panel (or ask your administrator). For everyone else or for detailed instructions, see the page for your chosen database server:<br />
* [[PostgreSQL]]<br />
* [[MariaDB]]<br />
* [[MySQL]]<br />
* [[MSSQL]]<br />
* [[Oracle]] (not recommended)<br />
<br />
== Create the (''moodledata'') data directory ==<br />
<br />
Moodle requires a directory to store all of its files (all your site's uploaded files, temporary data, cache, session data etc.). The web server needs to be able to write to this directory. On larger systems consider how much free space you are going to use when allocating this directory. <br />
<br />
Due to the default way Moodle caches data you may have serious performance issues if you use relatively slow storage (e.g. NFS) for this directory. Read the [[Performance_recommendations]] carefully and consider using (e.g.) redis or memcached for [[Caching]].<br />
<br />
'''IMPORTANT:''' This directory must '''NOT''' be accessible directly via the web. This would be a serious security hole. Do not try to place it inside your web root or inside your Moodle program files directory. Moodle will not install. It can go anywhere else convenient. <br />
<br />
Here is an example (Unix/Linux) of creating the directory and setting the permissions for '''anyone''' on the server to write here. This is only appropriate for Moodle servers that are not shared. Discuss this with your server administrator for better permissions that just allow the web server user to access these files.<br />
<br />
<pre><br />
# mkdir /path/to/moodledata<br />
# chmod 0777 /path/to/moodledata<br />
</pre><br />
<br />
==== Securing moodledata in a web directory ====<br />
<br />
If you are using a hosted site and you have no option but to place 'moodledata' in a web accessible directory. You may be able to secure it by creating an .htaccess file in the 'moodledata' directory. This does not work on all systems - see your host/administrator. Create a file called .htaccess containing only the following lines:<br />
<pre><br />
order deny,allow<br />
deny from all<br />
</pre><br />
<br />
== Start Moodle install ==<br />
It's now time to run the installer to create the database tables and configure your new site. The recommended method is to use the command line installer. If you cannot do this for any reason (e.g. on a Windows server) the web-based installer is still available.<br />
<br />
=== Command line installer ===<br />
<br />
It's best to run the command line as your system's web user. You need to know what that is - see your system's documentation (e.g. Ubuntu/Debian is 'www-data', Centos is 'apache')<br />
<br />
* Example of using the command-line (as root - substitute 'www-data' for your web user):<br />
<pre><br />
# chown www-data /path/to/moodle<br />
# cd /path/to/moodle/admin/cli<br />
# sudo -u www-data /usr/bin/php install.php<br />
# chown -R root /path/to/moodle<br />
</pre><br />
The chowns allow the script to write a new config.php file. More information about the options can be found using <br />
<pre><br />
# php install.php --help<br />
</pre><br />
<br />
You will be asked for other settings that have not been discussed on this page - if unsure just accept the defaults. For a full discussion see [[Administration via command line]]<br />
<br />
=== Web based installer ===<br />
<br />
For ease of use you can install Moodle via the web. We recommend configuring your web server so that the page is not publicly accessible until the installation is complete.<br />
<br />
To run the web installer script, just go to your Moodle's main URL using a web browser.<br />
<br />
The installation process will take you through a number of pages. You should be asked to confirm the copyright, see the database tables being created, supply administrator account details and supply the site details. The database creation can take some time - please be patient. You should eventually end up at the Moodle front page with an invitation to create a new course. <br />
<br />
It is very likely that you will be asked to download the new config.php file and upload it to your Moodle installation - just follow the on-screen instructions.<br />
<br />
==Final configuration==<br />
<br />
=== Settings within Moodle ===<br />
There are a number of options within the Moodle Site Administration screens (accessible from the 'Site administration' tab in the 'Administration' block (Classic theme) or the Site administration button in the navigation bar (Boost). Here are a few of the more important ones that you will probably want to check:<br />
* ''Administration > Site administration > Server > Email > Outgoing mail configuration'': Set your smtp server and authentication if required (so your Moodle site can send emails). You can also set a norepy email on this page.<br />
* ''Administration > Site administration > Server > Server > Support contact''. Set your support contact email. <br />
* ''Administration > Site administration > Server > System paths'': Set the paths to du, dot and aspell binaries.<br />
* ''Administration > Site administration > Server > HTTP'': If you are behind a firewall you may need to set your proxy credentials in the 'Web proxy' section.<br />
* ''Administration > Site administration > Location > Update timezones'': Run this to make sure your timezone information is up to date. (more info [[Location]])<br />
** [http://php.net/manual/en/timezones.php Set server's local timezone] inside <tt>php.ini</tt> (should probably be inside <tt>/etc/php.ini</tt> or <tt>/etc/php.d/date.ini</tt>, depending on the underlying OS):<br />
<code php><br />
[Date] <br />
; Defines the default timezone used by the date functions <br />
date.timezone = "YOUR LOCAL TIMEZONE"<br />
</code><br />
<br />
=== Remaining tasks ===<br />
<br />
* '''Configure Cron''': Moodle's background tasks (e.g. sending out forum emails and performing course backups) are performed by a script which you can set to execute at specific times of the day. This is known as a cron script. Please refer to the [[Cron|Cron instructions]].<br />
* '''Set up backups''': See [[Site backup]] and [[Automated course backup]].<br />
* '''Secure your Moodle site''': Read the [[Security recommendations]].<br />
*'''Increasing the maximum upload size''' See [[Installation FAQ]] Maximum upload file size - how to change it?<br />
* '''Check mail works''' : From Site administration > Server > Test outgoing mail configuration, use the link to send yourself a test email. Don't be tempted to skip this step.<br />
<br />
=== Installation is complete :) ===<br />
<br />
* Create a new course: You can now access Moodle through your web browser (using the same URL as you set during the install process), log in as your admin user and creatse a new course. See [[Adding a new course|create a new course]].<br />
<br />
=== If something goes wrong... ===<br />
<br />
Here are some things you should try...<br />
<br />
* Check the [[Installation FAQ]]<br />
* Check your file permissions carefully. Can your web server read (but not write) the Moodle program files? Can your web server read and write your Moodle data directory? If you don't fully understand how file ownership and permissions work on your operating system it would be time very well spent to find out.<br />
* Check your database permissions. Have you set up your database user with the correct rights and permissions for your configuration (especially if the web server and database server are different machines)?<br />
* Create your [[Configuration file]] (config.php) by hand. Copy config-dist.php (in the root of the Moodle program directory) to config.php, edit it and set your database/site options there. Installation will continue from the right place. <br />
* Once you have a config.php (see previous tip) you can edit it to turn on debugging (in section 8). This may give you extra information to help track down a problem. If you have access, check your web server error log(s).<br />
* Re-check your php.ini / .htaccess settings. Are they appropriate (e.g. memory_limit), did you edit the correct php.ini / .htaccess file and (if required) did you re-start the web server after making changes?<br />
* Did you include any non-core (optional) plugins, themes or other code before starting the installation script? If so, remove it and try again (it may be broken or incompatible).<br />
* Explain your problem in the [http://moodle.org/mod/forum/view.php?id=28 Installation problems forum]. '''PLEASE''' list your software versions; explain what you did, what happened and what error messages you saw (if any); explain what you tried. There is no such thing as 'nothing', even a blank page is something!<br />
<br />
== Platform specific instructions ==<br />
<br />
'''Note:''' Much of this information is provided by the community. It may not have been checked and may be out of date. Please read in conjunction with the above installation instructions.<br />
<br />
* [[Windows installation]]<br />
** [[Installing Moodle on SmarterASP.NET]]<br />
* [[Unix or Linux Installation]]<br />
* [[Mac Installation]]<br />
* [[Amazon EC2 Cloud Services Installation]]<br />
<br />
== See also ==<br />
* [http://www.slideshare.net/gb2048/my-own-moodle Slideshare presentation by Gareth Barnard on installing a local installation of Moodle] and accompanying [https://drive.google.com/folderview?id=0B17B0rYH2zERU21sQnVweUZCUFk&usp=sharing help guides]<br />
* [http://moodle.org/mod/forum/discuss.php?d=182086 New Video Tutorial- How to Install Moodle on Shared Hosting via cPanel (Not Fantastico)]<br />
* [https://moodle.org/mod/forum/discuss.php?d=401983 Another one for cPanel using videos]<br />
* [http://moodle.org/mod/forum/discuss.php?d=199542 Video Tutorial - Install Moodle on a Virtual Box from scratch] <br />
<br />
[[es:Instalaci%C3%B3n_de_moodle]]<br />
[[de:Installation von Moodle]]<br />
[[fr:Installation de Moodle]]<br />
[[ja:Moodleのインストール]]</div>Leonstrhttps://docs.moodle.org/310/en/index.php?title=admin/environment/php_extension/xmlrpc&diff=138457admin/environment/php extension/xmlrpc2020-09-17T10:28:24Z<p>Leonstr: CentOS and Fedora now use dnf instead of yum, Ubuntu/Debian won't be using php5-XXX now.</p>
<hr />
<div>{{Environment}}<br />
To install the xmlrpc library on Microsoft Windows:<br />
<br />
#Open the ''php.ini'' file, depending on your installation this may be found in the ''moodle/apache/bin'' folder<br />
#Find the line: <code>;extension=php_xmlrpc.dll</code><br />
#Remove the <code>;</code> at the beginning of the line<br />
#If necessary restart the web server, e.g. IIS or Apache.<br />
<br />
To install the xmlrpc library on Linux/Unix<br />
<br />
If you are using PHP as provided by the OS, you can just install the appropriate package, and restart the service (e.g. PHP-FPM or Apache):<br />
<br />
* On Ubuntu and Debian, the command is: apt-get install php-xmlrpc<br />
* On RedHat, Fedora, CentOS and SuSE, the command is: dnf install php-xmlrpc<br />
<br />
If you compiled your PHP from source:<br />
<br />
# You need to recompile PHP from source <br />
# add '''--with-xmlrpc''' to the command line when you run '''configure'''<br />
<br />
<br />
[[Category:Environment|PHP extension]]<br />
[[Category:MNet|PHP]]<br />
<br />
[[fr:admin/environment/php extension/xmlrpc]]<br />
[[es:admin/environment/php extension/xmlrpc]]</div>Leonstrhttps://docs.moodle.org/310/en/index.php?title=OPcache&diff=138456OPcache2020-09-17T10:12:09Z<p>Leonstr: Removed PHP 5.x specific instructions, tried to clarify zend_extension setting for installation</p>
<hr />
<div>{{Environment}}<br />
<br />
The standard OPcache extension is strongly recommended; since Moodle 2.6, it is the only solution officially supported by PHP developers. The benefits are increased performance and significantly lower memory usage. However, opcode caching extensions (including OPcache, eAccelerator and APC) aren't compatible with servers configured to use some common types of high-security PHP handlers such as suPHP (the default on WHM / cPanel Linux servers).<br />
<br />
[[File:Opcache_error.png|800px]]<br />
<br />
==Installation==<br />
<br />
The OPcache extension is distributed as part of PHP 5.5 and later. It is available also for older stable PHP releases from PECL under the original name ZendOPcache. To check if the extension is loaded and enabled look at [[PHP#Displaying_phpinfo_in_Moodle|the PHP info page]] under the '''Zend OPcache''' heading.<br />
<br />
===Linux, Mac OS and other Unix-like platforms===<br />
<br />
You may need to install a specific package, e.g. on CentOS, Fedora or Red Hat: '''dnf install php-opcache'''. If necessary add the following to '''php.ini''' (package installers may do this automatically):<br />
<code ini><br />
zend_extension=/full/path/to/opcache.so <br />
</code><br />
<br />
===Microsoft Windows===<br />
<br />
The extension '''php_opcache.dll''' is included in the '''ext''' folder in the [https://windows.php.net/download PHP for Windows binary downloads].<br />
To enable it add the following to '''php.ini''':<br />
<br />
<code ini><br />
zend_extension=php_opcache.dll<br />
</code><br />
<br />
==Configuration==<br />
<br />
'''php.ini''' settings:<br />
<br />
<code ini><br />
[opcache]<br />
opcache.enable = 1<br />
opcache.memory_consumption = 128<br />
opcache.max_accelerated_files = 10000<br />
opcache.revalidate_freq = 60<br />
<br />
; Required for Moodle<br />
opcache.use_cwd = 1<br />
opcache.validate_timestamps = 1<br />
opcache.save_comments = 1<br />
opcache.enable_file_override = 0<br />
<br />
; If something does not work in Moodle<br />
;opcache.revalidate_path = 1 ; May fix problems with include paths<br />
;opcache.mmap_base = 0x20000000 ; (Windows only) fix OPcache crashes with event id 487<br />
<br />
; Experimental for Moodle 2.6 and later<br />
;opcache.fast_shutdown = 1<br />
;opcache.enable_cli = 1 ; Speeds up CLI cron<br />
;opcache.load_comments = 0 ; May lower memory use, might not be compatible with add-ons and other apps.<br />
</code><br />
<br />
; memory_consumption<br />
From: [http://blog.jpauli.tech/2015-03-05-opcache-html/ PHP's OPCache extension review]<br />
*''The size of the memory segment can be told using the opcache.memory_consumption INI setting (Megabytes). Size it big, don't hesitate to give space. Never ever run out of shared memory space, if you do, you will lock your processes, we'll get back to that later.''<br />
<br />
*''Size the shared memory segment according to your needs, don't forget that a production server dedicated to PHP processes may bundle several dozens of Gigabytes of memory, just for PHP. Having a 1Gb shared memory segment (or more) is not uncommon, it will depend on your needs, but if you use a modern application stack, aka framework based, with lots of dependencies etc... , then use at least 1Gb of shared memory.''<br />
<br />
Having that in mind, set opcache.memory_consumption to a value high enough to avoid filling it up (as long as your RAM usage allows you to), and then monitor the OPCache to adjust that value to its optimal size. As the total size of the PHP files in a standard Moodle 3.6 is almost 90MB, setting this value higher than that can be a good idea. Take into account that the PHP files of the plugins and those on the MoodleData folder (language pack files...) also count, so these values can be different on each installation. If you have several instances of Moodle you should multiply that value by the number of instances.<br />
<br />
Tip: If using Linux, you can know the total size of the PHP files of a folder using this command:<br />
<code ini><br />
find ./ -type f -name "*.php" -printf "%s\n" | gawk -M '{t+=$1}END{print t}' | numfmt --to=iec<br />
</code><br />
<br />
; max_accelerated_files<br />
From: [http://php.net/manual/en/opcache.configuration.php#ini.opcache.max-accelerated-files php.net max-accelerated-files]<br />
*''The maximum number of keys (and therefore scripts) in the OPcache hash table. The actual value used will be the first number in the set of prime numbers { 223, 463, 983, 1979, 3907, 7963, 16229, 32531, 65407, 130987 } that is greater than or equal to the configured value. The minimum value is 200. The maximum value is 100000 in PHP < 5.5.6, and 1000000 in later versions.''<br />
<br />
As Moodle 3.6 contains almost 10.000 php files it is recommended above that opcache.max_accelerated_files should be set to 10000 to accommodate this (16229 will actually be used as per the explanation above). If you have several instances of Moodle you should multiply that value by the number of instances.<br />
<br />
If many additional plugins are installed so that your total PHP files exceed 16229 then the next most suitable value for max_accelerated_files should be used.<br />
Tip: If using Linux, you can know the total PHP files of your Moodle using this command:<br />
<code ini><br />
find ./ -type f | grep -E ".*\.php$" | sed -e 's/.*\(\.[a-zA-Z0-9]*\)$/\1/' | sort | uniq -c | sort -n<br />
</code><br />
<br />
==Opcache management plugin==<br />
[[File:Opcache_management_message.png|400px]]<br />
<br />
You may consider installing the additional [https://moodle.org/plugins/tool_opcache Opcache management] - Moodle plugin which adds a PHP Opcache management GUI to Moodle site administration, a CLI tool to reset PHP Opcache and a Nagios check for PHP Opcache.<br />
<br />
[[File:Opcache management status.png|800px]]<br />
<br />
==See also==<br />
* [http://pecl.php.net/package/ZendOpcache PECL ZendOPcache]<br />
<br />
Forum discussions:<br />
* [https://moodle.org/mod/forum/discuss.php?d=244133 OPcache: Memory Usage = 100% (is this good or bad?)]<br />
* [https://moodle.org/mod/forum/discuss.php?d=245885 OPCode cache]<br />
<br />
<br />
<br />
[[Category:Environment]]<br />
[[Category:Installation]]<br />
[[Category:Performance]]<br />
<br />
[[es:OPcache]]</div>Leonstrhttps://docs.moodle.org/310/en/index.php?title=OPcache&diff=138455OPcache2020-09-17T09:32:55Z<p>Leonstr: Undo revision 138051 by Battya (talk) Previous edit put php.ini settings under === Windows ===, this is not correct they apply to all OSes (except .dll which should not be there)</p>
<hr />
<div>{{Environment}}<br />
<br />
The standard OPcache extension is strongly recommended; since Moodle 2.6, it is the only solution officially supported by PHP developers. The benefits are increased performance and significantly lower memory usage. However, opcode caching extensions (including OPcache, eAccelerator and APC) aren't compatible with servers configured to use some common types of high-security PHP handlers such as suPHP (the default on WHM / cPanel Linux servers).<br />
<br />
[[File:Opcache_error.png|800px]]<br />
<br />
==Installation==<br />
<br />
The OPcache extension is distributed as part of PHP 5.5.0 and later. It is available also for older stable PHP releases from PECL under the original name ZendOPcache.<br />
<br />
'''NOTE: If you are running PHP 5.3 or 5.4 you can safely ignore the Environment Check message about OpCache. Nonetheless, [https://moodle.org/mod/forum/discuss.php?d=245885 it might be useful] to upgrade Operating System/PHP and get to 5.5 or newer; as there have been all sorts of problems described on PHP 5.2 and 5.3, and upgrading PHP turned out to be the easier solution. '''<br />
<br />
==Configuration==<br />
<br />
PHP.ini settings:<br />
<br />
<code ini><br />
[opcache]<br />
zend_extension = php_opcache.dll<br />
opcache.enable = 1<br />
opcache.memory_consumption = 128<br />
opcache.max_accelerated_files = 10000<br />
opcache.revalidate_freq = 60<br />
<br />
; Required for Moodle<br />
opcache.use_cwd = 1<br />
opcache.validate_timestamps = 1<br />
opcache.save_comments = 1<br />
opcache.enable_file_override = 0<br />
<br />
; If something does not work in Moodle<br />
;opcache.revalidate_path = 1 ; May fix problems with include paths<br />
;opcache.mmap_base = 0x20000000 ; (Windows only) fix OPcache crashes with event id 487<br />
<br />
; Experimental for Moodle 2.6 and later<br />
;opcache.fast_shutdown = 1<br />
;opcache.enable_cli = 1 ; Speeds up CLI cron<br />
;opcache.load_comments = 0 ; May lower memory use, might not be compatible with add-ons and other apps.<br />
</code><br />
<br />
When using non-Windows platforms, you have to use the ''zend_extension'' configuration to load the OPcache extension into PHP by adding to php.ini.<br />
<code ini><br />
zend_extension=/full/path/to/opcache.so <br />
</code><br />
<br />
When using IIS you will need PHP 5.5 and you will need to add the extension for opcache under the ''ExtensionList'' section of the php.ini file. For PHP 5.3 and 5.4 you can download the binaries separately from [http://windows.php.net/downloads/pecl/releases/opcache] and you will also need to enter full absolute path to the module dll in php.ini.<br />
<br />
<code ini><br />
[ExtensionList]<br />
...<br />
zend_extension=php_opcache.dll<br />
</code><br />
<br />
; memory_consumption<br />
From: [http://blog.jpauli.tech/2015-03-05-opcache-html/ PHP's OPCache extension review]<br />
*''The size of the memory segment can be told using the opcache.memory_consumption INI setting (Megabytes). Size it big, don't hesitate to give space. Never ever run out of shared memory space, if you do, you will lock your processes, we'll get back to that later.''<br />
<br />
*''Size the shared memory segment according to your needs, don't forget that a production server dedicated to PHP processes may bundle several dozens of Gigabytes of memory, just for PHP. Having a 1Gb shared memory segment (or more) is not uncommon, it will depend on your needs, but if you use a modern application stack, aka framework based, with lots of dependencies etc... , then use at least 1Gb of shared memory.''<br />
<br />
Having that in mind, set opcache.memory_consumption to a value high enough to avoid filling it up (as long as your RAM usage allows you to), and then monitor the OPCache to adjust that value to its optimal size. As the total size of the PHP files in a standard Moodle 3.6 is almost 90MB, setting this value higher than that can be a good idea. Take into account that the PHP files of the plugins and those on the MoodleData folder (language pack files...) also count, so these values can be different on each installation. If you have several instances of Moodle you should multiply that value by the number of instances.<br />
<br />
Tip: If using Linux, you can know the total size of the PHP files of a folder using this command:<br />
<code ini><br />
find ./ -type f -name "*.php" -printf "%s\n" | gawk -M '{t+=$1}END{print t}' | numfmt --to=iec<br />
</code><br />
<br />
; max_accelerated_files<br />
From: [http://php.net/manual/en/opcache.configuration.php#ini.opcache.max-accelerated-files php.net max-accelerated-files]<br />
*''The maximum number of keys (and therefore scripts) in the OPcache hash table. The actual value used will be the first number in the set of prime numbers { 223, 463, 983, 1979, 3907, 7963, 16229, 32531, 65407, 130987 } that is greater than or equal to the configured value. The minimum value is 200. The maximum value is 100000 in PHP < 5.5.6, and 1000000 in later versions.''<br />
<br />
As Moodle 3.6 contains almost 10.000 php files it is recommended above that opcache.max_accelerated_files should be set to 10000 to accommodate this (16229 will actually be used as per the explanation above). If you have several instances of Moodle you should multiply that value by the number of instances.<br />
<br />
If many additional plugins are installed so that your total PHP files exceed 16229 then the next most suitable value for max_accelerated_files should be used.<br />
Tip: If using Linux, you can know the total PHP files of your Moodle using this command:<br />
<code ini><br />
find ./ -type f | grep -E ".*\.php$" | sed -e 's/.*\(\.[a-zA-Z0-9]*\)$/\1/' | sort | uniq -c | sort -n<br />
</code><br />
<br />
==Opcache management plugin==<br />
[[File:Opcache_management_message.png|400px]]<br />
<br />
You may consider installing the additional [https://moodle.org/plugins/tool_opcache Opcache management] - Moodle plugin which adds a PHP Opcache management GUI to Moodle site administration, a CLI tool to reset PHP Opcache and a Nagios check for PHP Opcache.<br />
<br />
[[File:Opcache management status.png|800px]]<br />
<br />
==See also==<br />
* [http://pecl.php.net/package/ZendOpcache PECL ZendOPcache]<br />
* [http://windows.php.net/downloads/pecl/releases/opcache/ Windows builds for PHP 5.3-5.4]<br />
<br />
Forum discussions:<br />
* [https://moodle.org/mod/forum/discuss.php?d=244133 OPcache: Memory Usage = 100% (is this good or bad?)]<br />
* [https://moodle.org/mod/forum/discuss.php?d=245885 OPCode cache]<br />
<br />
<br />
<br />
[[Category:Environment]]<br />
[[Category:Installation]]<br />
[[Category:Performance]]<br />
<br />
[[es:OPcache]]</div>Leonstrhttps://docs.moodle.org/310/en/index.php?title=admin/environment/php_extension/intl&diff=138453admin/environment/php extension/intl2020-09-17T09:09:48Z<p>Leonstr: /* Other operating systems */ CentOS 8.0 uses dnf instead of yum, definitely not php5-intl for Debian/Ubuntu</p>
<hr />
<div>{{Environment}}<br />
The Internationalization extension (Intl) is a wrapper for the ICU library, a set of C/C++ and Java libraries that provide Unicode and Globalization support for software applications. It enables PHP programmers to perform UCA-conformant collation and date/time/number/currency formatting in their scripts.<br />
<br />
The Intl extension is required in Moodle 3.4 onwards.<br />
<br />
==MS Windows==<br />
<br />
To enable this extension add the following line to your php.ini file usually found in /php:<br />
<br />
<code><br />
extension= php_intl.dll<br />
</code><br />
<br />
And then set the ''intl.default_locale'' and ''intl.error_level'' directives in your php.ini file.<br />
<br />
<code><br />
[intl]<br />
<br />
intl.default_locale = en_utf8<br />
<br />
intl.error_level = E_WARNING<br />
</code><br />
<br />
The ''intl.error_level'' directive is optional.<br />
<br />
In a WAMP installation it may be required to add the php path to the the system PATH so that the module4 could uploaded properly (see http://forum.wampserver.com/read.php?2,80704,82499 for a couple of other approaches).<br />
<br />
==Other operating systems==<br />
<br />
Use system package manager or specify compilation flag.<br />
<br />
*Debian 5.0 (& Ubuntu) use: '''apt-get install php-intl'''.<br />
<br />
*CentOS 8.0 (& Red Hat) use: '''dnf install php-intl'''. CentOS 7.0 (& RedHat) use: '''yum install php-intl'''. The package name may be slightly different depending on the repository used for PHP packages, e.g. '''php74-intl'''.<br />
<br />
==See also==<br />
<br />
*[http://www.php.net/manual/en/intro.intl.php INTL Introduction]<br />
*[http://www.php.net/manual/en/book.intl.php PHP Internationalization Functions]<br />
*[https://docs.moodle.org/en/Table_of_locales Table of locales] lists the locales that you can use.<br />
<br />
[[Category:Environment|PHP]]<br />
<br />
[[fr:admin/environment/php extension/intl]]<br />
[[es:admin/environment/php extension/intl]]</div>Leonstrhttps://docs.moodle.org/310/en/index.php?title=File:phpMyAdmin2.png&diff=138259File:phpMyAdmin2.png2020-08-28T15:11:05Z<p>Leonstr: Example output from SHOW GLOBAL VARIABLES</p>
<hr />
<div>Example output from SHOW GLOBAL VARIABLES</div>Leonstrhttps://docs.moodle.org/310/en/index.php?title=File:phpMyAdmin1.png&diff=138258File:phpMyAdmin1.png2020-08-28T15:10:41Z<p>Leonstr: Example output from SHOW GLOBAL VARIABLES</p>
<hr />
<div>Example output from SHOW GLOBAL VARIABLES</div>Leonstrhttps://docs.moodle.org/310/en/index.php?title=MySQL&diff=138257MySQL2020-08-28T15:09:56Z<p>Leonstr: /* Configure full UTF-8 support */ Rewrite as MariaDB deprecates innodb_file_format/innodb_large_prefix, setting these generates a warning</p>
<hr />
<div>{{Installing Moodle}}<br />
MySQL is one of the supported databases that underpins a Moodle installation. <br />
<br />
== Installing MySQL ==<br />
<br />
* If you are running Linux your preference should be to install using your distribution's package manager. This ensures you will get any available updates. However, you can also use apt-get or yum depending on the distribution that you are running.<br />
* There are installers available for most popular operating systems at http://www.mysql.com/downloads/mysql/.<br />
* It is possible and reasonably straightforward to build mysql from source but it is not recommended (the pre-built binaries are supposedly better optimised).<br />
* Make sure you set a password for the 'root' user (see http://dev.mysql.com/doc/refman/5.0/en/default-privileges.html).<br />
* Consider installing and configuring my.cnf (the MySQL settings file) to suit your needs. The default configuration is usually very conservative in respect of memory usage versus performance. Increase the 'max_allowed_packet' setting to at least 4 megabytes.<br />
* If you are going to use Master/Slave replication, you must add binlog_format = 'ROW' into your my.cnf within [mysqld]. Otherwise, Moodle will not be able to write to the database.<br />
<br />
=== Configure full UTF-8 support ===<br />
<br />
It's recommended that full UTF-8 support is configured in MySQL. If this is not done some character sets – notably emojis – cannot be used. It is possible to do this after installing your site but is much easier and quicker before installation.<br />
<br />
Check if this is already configured by running the following statement, e.g. at the '''mysql>''' prompt or in phpMyAdmin:<br />
<pre>SHOW GLOBAL VARIABLES WHERE variable_name IN ('innodb_file_format', 'innodb_large_prefix', 'innodb_file_per_table');</pre><br />
<br />
[[File:phpMyAdmin1.png|alt=innodb_file_format=Barracuda;innodb_file_per_table=ON;innodb_large_prefix=ON]] or [[File:phpMyAdmin2.png|alt=innodb_file_per_table=ON]]<br />
<br />
If the settings you see match either list above then no changes are needed and you can skip to [[#Creating_Moodle_database| Creating Moodle database]].<br />
<br />
If your settings do not match either list you will have to edit the MySQL configuration file. On Linux this may be '''/etc/my.cnf''', '''/etc/mysql/my.cnf''', or '''/etc/my.cnf.d/mariadb-server.cnf'''; on Microsoft Windows it may be '''my.ini'''.<br />
<br />
* Note: Back up the configuration file before changing it.<br />
* Note: Back up all databases before making this change.<br />
* Note: Other systems with databases on this server may be impacted by this change.<br />
<br />
Add the following settings to the configuration file, skip '''innodb_file_format''' and '''innodb_large_prefix''' if these were blank in the table above:<br />
<pre>[client]<br />
default-character-set = utf8mb4<br />
<br />
[mysqld]<br />
innodb_file_format = Barracuda # Do not set if blank<br />
innodb_file_per_table = 1<br />
innodb_large_prefix = 1 # Do not set if blank<br />
<br />
character-set-server = utf8mb4<br />
collation-server = utf8mb4_unicode_ci<br />
skip-character-set-client-handshake<br />
<br />
[mysql]<br />
default-character-set = utf8mb4</pre><br />
<br />
Restart the MySQL server process to apply these settings (e.g. MariaDB on Linux: '''systemctl restart mariadb''').<br />
<br />
If you have any difficulty applying these settings, see [[MySQL_full_unicode_support]] for further information.<br />
<br />
If for some reason you cannot change to the settings described here you can continue to install Moodle but you must select '''utf8''' and '''utf8_unicode_ci''' for the default character set and collation respectively.<br />
<br />
== Creating Moodle database ==<br />
<br />
These are the steps to create an empty Moodle database. Substitute your own database name, user name and password as appropriate.<br />
<br />
The instructions assume that the web server and MySQL server are on the same machine. In this case the 'dbhost' is 'localhost'. If they are on different machines substitute the name of the web server for 'localhost' in the following instructions and the 'dbhost' setting will be the name of the database server. <br />
Databases have a "Character set" and a "Collation". For Moodle, we recommend the Character Set be set to '''utf8mb4''' and the Collation '''utf8mb4_unicode_ci'''. You may get the option to set these values when you create the database. If you are not given a choice, the default options are probably good. An install on an old server may have the wrong settings.<br />
<br />
=== Command line === <br />
<br />
* To create a database using the 'mysql' command line client, first log into MySQL<br />
<pre><br />
$ mysql -u root -p<br />
Enter password: <br />
</pre><br />
(Enter the password you previously set - or been given - for the MySQL 'root' user). After some pre-amble this should take you to the ''mysql>'' prompt.<br />
* Create a new database (called 'moodle' - substitute your own name if required).<br />
If you have successfully configured the recommended full UTF-8 support as described above run:<br />
<pre><br />
mysql> CREATE DATABASE moodle DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;<br />
</pre><br />
If you do not have the recommended full UTF-8 support run:<br />
<pre>mysql> CREATE DATABASE moodle DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;</pre><br />
* Add a user/password with the minimum needed permissions:<br />
<pre><br />
mysql> CREATE USER moodleuser@localhost IDENTIFIED BY 'yourpassword';<br />
mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,CREATE TEMPORARY TABLES,DROP,INDEX,ALTER ON moodle.* TO moodleuser@localhost;<br />
mysql> FLUSH PRIVILEGES;<br />
</pre><br />
...which creates a user called 'moodleuser' with a password 'yourpassword'. Make sure you invent a strong password and resist the temptation to 'GRANT ALL'.<br />
* Exit from mysql:<br />
<pre><br />
mysql> quit<br />
</pre><br />
<br />
=== phpMyAdmin ===<br />
<br />
[http://www.phpmyadmin.net/ phpMyAdmin] is a web based administration tool for MySQL. If this is available you can use it to create a new database. If you have successfully configured the recommended full UTF-8 support as described above select collation '''utf8mb4_unicode_ci'''. If you do not have the recommended full UTF-8 support select collation '''utf8_unicode_ci'''.<br />
<br />
==Which database belongs to which Moodle==<br />
If you have installed several Moodle installations on the same server, there will be several databases in your MySQL server. The names might be quite poor reflections of the content like _mdl1 _mdl2 _mdl3 . So how do I see which database goes with which Moodle installation? You can go in with phpMyAdmin and in the various databases check for the table "mdl_course". There you will easily see the name of that Moodle Installation. In table mdl_config you can see the Moodle version. The main URL for the site is not in the database except where there are absolute links.<br />
<br />
== See also ==<br />
<br />
* [[MariaDB]]<br />
* [[MySQL full unicode support]]<br />
* [http://www.mysql.com/ The MySQL homepage]<br />
* [http://en.wikipedia.org/wiki/MySQL Wikipedia article about ''MySQL'']<br />
* [http://forums.mysql.com/read.php?24,92131,92131 List of articles on MySQL performance tuning]<br />
<br />
[[Category:SQL databases]]<br />
<br />
[[ja:MySQL]]<br />
[[de:MySQL]]<br />
[[es:MySQL]]</div>Leonstr