Difference between revisions of "Cool Solution - Install Moodle"

From Univention Wiki

Jump to: navigation, search
Line 193: Line 193:
* Moodle 2.5 Documentation - http://docs.moodle.org/25/en/Main_page
* Moodle 2.5 Documentation - http://docs.moodle.org/25/en/Main_page

Revision as of 12:27, 7 April 2014

Produktlogo UCS Version 3.1
Produktlogo UCS@School Version 3.1

Note: Cool Solutions are articles documenting additional functionality based on Univention products. Not all of the shown steps in the article are covered by Univention Support. For questions about your support coverage contact your contact person at Univention before you want to implement one of the shown steps.

Also regard the legal notes at Terms of Service.


This article introduces you to the usage of Moodle. It covers the installation on a dedicated school server, as well as the users authentication with the LDAP. If further integration packages are needed, like loading classes from the LDAP or using the Microsoft Windows authentication for already logged in users, feel free to contact Univention for assistance.


This section will cover the preparation and installation of Moodle on the system. Please make sure that every command is executed as root user.

For the installation to succeed, some packages must be downloaded from the Univention unmaintained repositories. To activate the Univention unmaintained repository, execute the following command:

ucr set repository/online/unmaintained=yes

To install Moodle and some dependencies, execute the following command:

univention-install php5-pgsql univention-postgresql moodle

The PostgreSQL database modules must be included in PHP. Add the following two lines into the /etc/php5/apache2/php.ini file:


To use Moodle effectively, it is recommended to raise the maximum size for uploads, e. g. 20 MB, to provide small programs to students. The changes must be done in the /etc/php5/apache2/php.ini file:

post_max_size = 20M
upload_max_filesize = 20M

For the changes to take effect, the Apache webserver must be restarted:

/etc/init.d/apache2 restart


This section handles the basic configuration and LDAP connection for Moodle and how to delete users in Moodle that are not in the LDAP anymore.

Basic configuration

First, Moodle's entry restrictions must be changed. To do so, edit the file /etc/moodle/apache.conf and edit the following line to match your network settings:

allow from

Also check the settings in the /etc/moodle/config.php file and change the entry localhost to the server's hostname:


To install with alias, create a symbolic link to apache2:

ln -s /etc/moodle/apache.conf /etc/apache2/conf.d/moodle

For the changes to take effect, the Apache webserver must be restarted:

/etc/init.d/apache2 restart

Now the Moodle service can be reached and configured by opening the web page in a webbrowser:


LDAP authentification

After the basic configuration is done, https should be activated in Security -> HTTP security. Next, in Users -> Authentication -> Manage authentication the option Email-based self-registration should be deactivated and LDAP server should be activated.

Next, a simple authentication account should be created using the UDM. This account can then be used for an authenticated bind. To find the DN of the account issue the following command on the command line:

udm users/user list --filter username=<NAME of the account> | grep DN

Now the LDAP connection can be configured under Settings. The table gives information which default settings must be changed:

Key Value
LDAP server settings
Host URL ldap://<school server's FQDN>:7389
Version 3
Bind settings
Distinguished Name <DN of the authentication account>
Password <Password of the authentication account>
User lookup settings
Contexts cn=users,ou=<school>,dc=<domain>
Search subcontexts Yes
User Attribute uid
Course creator
Creators cn=lehrer,cn=users,ou=<school>,dc=<domain>
Cron synchronization script
Removed ext user Full delete internal
Data mapping
Update local On Every Login
Update external Never
Lock value Locked

Hint: To obtain the LDAP basis, execute the following command on the school server:

ucr get ldap/base

Hint: To obtain the system's FQDN, execute the following command on the relevant system:

hostname -f

LDAP mapping

Furthermore, the following mapping applies for LDAP entries:

Key Value
First name givenName
Surname sn
Email address mail
Phone 1 telephoneNumber
Phone 2 homePhone
City/town l
Country c

Note: Some fields like Email address are mandatory for moodle, so you should make sure all moodle users have a valid email in UCS.

Cronjob for deleting users

In order for Moodle to remove users from its database that are deleted in the LDAP, a cronjob must be defined in the UDM.

ucr set cron/moodle/command='wget -q -O /dev/null http://localhost/moodle/admin/cron.php'\
cron/moodle/time='*/10 * * * *'


  1. OU: At this time it is not possible for Moodle to search for all users using the LDAP base DN.
  2. Class mapping: This article does not handle mappings between UCS@School classes and Moodle groups. If you need assistance to create the respective mapping or would like to have the setup packaged, feel free to contact Univention for an offer to create either.


Personal tools