37,19 €
This updated fourth edition of the classic Moodle Administration guide has been written from the ground up and covers all the new Moodle features in great breadth and depth. The topics have also been augmented with professional diagrams, illustrations, and checklists.
The book starts by covering basic tasks such as how to set up and configure Moodle and perform day-to-day administration activities. You’ll then progress to more advanced topics that show you how to customize and extend Moodle, manage authentication and enrolments, and work with roles and capabilities. Next, you'll learn how to configure pedagogical and technical Moodle plugins and ensure your LMS complies with data protection regulations. Then, you will learn how to tighten Moodle’s security, improve its performance, and configure backup and restore procedures. Finally, you'll gain insights on how to compile custom reports, configure learning analytics, enable mobile learning, integrate Moodle via web services, and support different types of multi-tenancy.
By the end of this book, you’ll be able to set up an efficient, fully fledged, and secure Moodle system.
Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:
Seitenzahl: 718
Veröffentlichungsjahr: 2022
An administrator’s guide to configuring, securing, customizing, and extending Moodle
Alex Büchner
BIRMINGHAM—MUMBAI
Copyright © 2022 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
Group Product Manager: Pavan Ramchandani
Publishing Product Manager: Bhavya Rao
Senior Editor: Aamir Ahmed
Senior Content Development Editor: Rakhi Patel
Technical Editor: Saurabh Kadave
Copy Editor: Safis Editing
Project Coordinator: Manthan Patel
Proofreader: Safis Editing
Indexer: Hemangini Bari
Production Designer: Prashant Ghare
Marketing Coordinators: Anamika Singh and Marylou De Mello
First Edition: September 2008
Second Edition: October 2011
Third Edition: February 2016
Fourth Edition: October 2022
Production reference: 1211022
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.
ISBN 978-1-80181-672-4
www.packt.com
To Ursel. R.I.P.
–Alex Büchner
Alex Büchner is the co-founder of the Premium Moodle and Platinum Totara partner Synergy Learning. He has implemented Moodle-based projects in the corporate, public, and third sectors for over two decades. He has been configuring learning management systems of all shapes and sizes since their advent in the educational landscape.
Alex holds a Ph.D. in computer science and an M.Sc in software engineering. He has authored over 50 international publications, including six books, and is a frequent speaker on Moodle, Moodle Workplace, and open source technologies. He can be contacted at openumlaut.com.
I want to thank my family for their support and patience while I have been occupying the kitchen table writing this book.
E. Adolfo Suarez is an educator with a strong background in computer science, having over 20 years of experience in the field. He holds a B.Ed., specializing in mathematics, and for many years, he alternated between teaching math and computer science.
Adolfo holds a virtual teacher specialization from UC Irvine Extension, obtained through the Coursera MOOC project. He is passionate about online learning and has over 10 years of experience as a Moodle administrator, dealing with student information systems, exams remote proctoring, e-books, plagiarism detection tools, and more.
Adolfo has been blessed with four grandchildren, and his best times are spent playing with them.
Dr. Laurie E. Korte is an e-learning professional you can count on, with expertise in motivational instructional design, user experience, and accessibility. The organizations she works with are able to focus on learning program objectives and not worry about the complex demands of site growth and engaging design. Laurie’s education and experience extend beyond her Ph.D. in educational technology. She has presented at many local, national, and international conferences, and she has authored books on collaborative and creative thinking skill development, Moodle, and open source. Dr. Korte is also an elected Moodle Users Association Committee Member.
Sarah Ashley, as a solution architect with Moodle US, uses her 15 years of experience in Moodle, instructional design, and instructional technology to provide learning design consultation, crafting creative solutions for new and existing implementation projects, as well as offering technical and functional support for Moodle and Moodle Workplace. She has presented at mini-Moots, iMoots, and many in-person and online Moodle Moots, sharing creative uses of database activity reports and other configurable reports for learning analytics and producing innovative workflows. Sarah has an M.Ed in instructional technology and an M.Sc. and a B.Sc. in computer science. She loves to sing, play drums and piano, and solve all kinds of puzzles – jigsaws, logic, word, Rubik’s cubes, and more!
Big thanks to my husband, Rev. Samuel Kofi Ashley, and son, Sammy, for your support during the review of this book. Thank you to my sister, Dr. Jeanette Paintsil, and brother, Abdel-Azim Brown, for your endless encouragement throughout my life’s journeys. Thanks to my parents, Mr. and Mrs. Brown, in Ghana, for making sure I got a quality education. Thanks, Dr. Martin Dougiamas, for creating Moodle, giving me the daily opportunity to empower others with education.
Since its launch in 2002, Moodle has become the benchmark that every learning management system is measured against. It has won a wide range of international accolades and established itself as an ecosystem for educational tools and services.
There are two versions of Moodle: Moodle LMS and Moodle Workplace.
Moodle LMS is the original version of Moodle, targeted at educational institutions such as schools, colleges, universities, and training providers. Moodle Workplace is designed for corporate and organizational training, resulting in a powerful and flexible platform for workplace learning.
While this book covers the administration of Moodle LMS, it can also be used with Moodle Workplace, since the latter is an extension of the former. References to Moodle Workplace and samples will be provided throughout.
A fun way to demonstrate the various Moodle subjects is in the form of a tube/subway/metro/underground map, where any icon(ic) stations represent Moodle Workplace-only features (you can download higher-quality versions in multiple languages and up-to-date features from www.openumlaut.com):
Figure P.1 – Moodle and Moodle Workplace map
Moodle 4 Administration is a complete, practical guide to administering Moodle sites. It covers setting up Moodle, configuration, day-to-day administrative tasks, and advanced options to customize and extend Moodle.
The author, who has been at the cutting edge of Moodle since its advent, has adopted a problem-solution approach to bring the content in line with your day-to-day operations. The practical examples will help you set up Moodle for large organizations and small entities alike.
This is a one-stop reference for tasks you will encounter when administering a Moodle site of any shape or size. It not only covers core Moodle functionality but also some third-party tools and add-ons that will increase your flexibility and efficiency even further when dealing with administrative duties.
The fourth edition of this title has been written from scratch to align with Moodle’s latest version. It has been further augmented with over 120 diagrams, checklists, and workflows. I hope you find its content useful when administering your Moodle system. Happy Moodling!
This book is written for technicians and systems administrators as well as academic staff – that is, basically anyone who has to administer a Moodle system. Whether you are dealing with a small-scale local Moodle system or a large-scale multi-site Learning Management System (LMS), this book will assist you with any administrative tasks.
Some basic Moodle knowledge would be helpful but is not essential.
A Moodle administrator is an LMS administrator who manages a Moodle system. A quick search through recruitment agencies specializing in the educational sector reveals a growing number of dedicated job titles closely related to LMS administration. A few examples are as follows:
LMS administrator (or VLE administrator or MLE administrator)LMS support officerLMS architectLMS engineerLMS coordinatorThe list does not include functions that regularly act in an administrative capacity, such as IT support. It also does not include roles in the pedagogical field that often take on the work of an LMS administrator, such as learning technologists or e-learning coordinators.
An LMS administrator usually works closely with the staff responsible for IT systems, databases, and networks. It has been proven beneficial to have some basic skills in these areas. Additionally, links with other departments are more likely in larger organizations where content management systems, student information management systems, and other related infrastructure are present.
Given this growing number of LMS administration-related roles, let’s look at some key obligations of the job functions and what skills are essential and desirable.
The responsibilities of an LMS administrator differ from organization to organization. However, some obligations are common across installations and setups:
User management (learners, teachers, and others)Course management (prospectus mapping)Module management (functionality provided to users)Look and feel of the LMS (often carried out by a web designer)Year-end maintenance (if applicable)Beginning-of-year setup (if applicable)Support teaching staff and learnersIn addition to these generic LMS-specific features, you must ensure that your system is secure, stable, and performs well. Backups have to be in place, monitoring has to be set up, usage reports have to be produced, and regular system maintenance has to be carried out.
If you host your own system, you will be responsible for all of the listed tasks and many more. If your LMS is hosted in a managed environment, the hosting provider will carry out some tasks closer to the system level, so it is essential that they have a good understanding of Moodle. Either way, you will be the first person to be contacted by staff and learners if anything goes wrong, if they require new functionality, or if some administrative task has to be carried out.
With great power comes great responsibility!
The book is organized in five parts, as shown in the following diagram:
Figure P.2 – Book structure
These two initial chapters will get you off the ground. You will learn different techniques on how to install Moodle and how to keep it up to date. You will further familiarize yourself with the Moodle system and its user interface. This part comprises the following chapters.
Chapter 1, Installing Moodle, tells you about the most suitable Moodle setup for your organization, including software and hardware requirements. You will learn how to install Moodle in a LAMP environment before Moodle update options are covered in detail. Throughout the chapter, you will learn how to perform the described operations using the Moodle Command-Line Interface (CLI), Git, and the third-party Moodle Shell (Moosh).
Chapter 2, Exploring the Moodle System, covers the building blocks of the learning platform. First, we present the Moodle architecture – that is, the main Moodle components – and where its data and code are stored. You will then acquire the skills to find your way around Moodle via its intuitive user and administration interface and where to find help if required. Finally, you will learn how Moodle’s file management works and how to configure the recycle bin.
Courses, users, and roles form the backbone of Moodle. You will learn how to manage courses and categories and different options to enrol users in courses. We will then deal with the management of users and cohorts and how to set up different authentication methods. Finally, you will learn how to manage permissions by applying roles and capabilities in different contexts. This part comprises the following chapters.
Chapter 3, Exploring Courses, Users, and Roles, gives you an overview of Moodle courses, users, and roles. It covers the basics of the key concepts and demonstrates how the three core elements are inherently intertwined.
Chapter 4, Managing Courses and Enrolments, shows you how to set up new courses (manually and in bulk) and organize them in categories. You will learn how to add custom course fields and deal with course requests. The remainder of the chapter deals with an array of enrolment options, covering Moodle’s internal enrolment (manual, self, and guest), cohort enrolment and synchronization, and database-driven enrolments – for instance, via LDAP, meta courses, and payment-driven enrolments.
Chapter 5, Managing Users, Cohorts, and Authentication, explains how to manage users on your system. We first cover what user profiles look like and how they can be extended before presenting (manual and bulk) standard user actions. We then explain how to add users to Moodle manually – that is, one by one and via batch upload – before dealing with cohorts. Then, we will learn about a plethora of authentication mechanisms that Moodle equips us with. Finally, we will discuss the best practices of user-naming schemes.
Chapter 6, Managing Permissions, Roles, and Capabilities, guides you through permission management. This applies roles and capabilities to users in different contexts. We will cover the assignment of roles, modification of existing roles, and the creation of new roles before we deal with any administrative role- and context-related settings, including context freezing.
This part is about how you, as an administrator, ensure the best possible environment for your learners and teachers. You will learn different enhancement options for Moodle’s look and feel and how to manage Moodle plugins, covering educational and technical features. This part comprises the following chapters.
Chapter 7, Enhancing Moodle’s Look and Feel, tells you how to adapt your Moodle system to align with your organization’s corporate branding. We will cover the customization of the appearance of your system, where you will learn how to change the layout of key pages before we deal with different login workflows and how to adjust the header. We will further deal with some appearance tools that impact the look and feel throughout the site: the block drawer, the Atto HTML editor, video and audio, and finally, user tours. We will briefly cover theme customization before you learn how to support users with accessibility requirements.
Chapter 8, Understanding Moodle Plugins, explains in detail what plugins are and how to extend your Moodle system via third-party add-ons. We will cover how to manage Moodle plugins, which includes their installation, configuration, and removal. Finally, you will be able to distinguish between good add-ons and not-so-good add-ons before we cover some popular extensions.
Chapter 9, Configuring Educational Features, deals with the educational configuration of your Moodle system. Pedagogical topics that are covered are collaboration tools (blogs, comments, and tags), content creation features (the content bank and H5P, LTI platforms and tools, filters, plagiarism prevention, and licenses), grades and assessments, and the management of skills and incentives (competencies, learning plans, badges, and certificates).
Chapter 10, Configuring Technical Features, deals with the technical configuration of your Moodle system. Technical subjects that are dealt with include synchronous and asynchronous communication (chats and BigBlueButton, messages, notifications, and RSS feeds), localization (languages, calendars, and time zones), repositories, and portfolios.
Chapter 11, Enabling Mobile Learning, teaches you how to prepare, configure, and customize the Moodle app. We will cover the different subscriptions Moodle offers, including the branded mobile app, before dealing with the preparatory steps you must take before your learners can use the app. The app configuration covers mobile features, notifications, the app policy, and the app’s look and feel.
Chapter 12, Gaining Insights through Reporting and Analytics, equips you with the tools required to interpret and analyze the vast amount of usage data that Moodle collects. We will first focus on Moodle‘s custom report builder, covering data sources, report building, report audiences, and schedules. After a detailed overview of the underlying Moodle logging framework with its components, events, and log stores, you will then learn how to interact with Moodle logs. Finally, we will deal with two more reporting techniques that use logs as their basis: Moodle statistics and Moodle analytics.
This part covers all topics that are mostly invisible to learners and teachers but are critical to guarantee the smooth operation of your Moodle system. You will learn how to ensure security, comply with data protection regulations, optimize Moodle’s performance, implement a solid backup and restore strategy, and work with helpful admin tools. This part comprises the following chapters.
Chapter 13, Ensuring Moodle Security, focuses on ensuring that the data in your Moodle system is protected from any misuse. You will learn about security notifications, user security, content security, and system security.
Chapter 14, Complying with Data Protection Regulations, deals with data privacy and the protection of personal data. You will learn about Moodle’s implementation of the General Data Protection Regulation, covering designating a privacy officer, managing policies, configuring the data registry, and handling subject access requests.
Chapter 15, Optimizing Moodle Performance, ensures your Moodle system runs to its full potential. We will cover configuring, monitoring, and fine-tuning your learning management system for maximum speed. You will learn how to optimize Moodle feature performance and discuss the trade-off between improved speed and potentially reduced functionality. We will then cover the powerful Moodle Universal Cache (MUC), including cache types, stores, and definitions. Finally, you will learn how to configure various system-related performance settings, namely session handling, cron management, scheduled tasks, global search, and system paths.
Chapter 16, Avoiding Sleepless Nights – Moodle Backup and Restore, focuses on ensuring that your data would not be lost in the event of a disaster. We will cover course backups, site backups, system backups, and restoring data from the taken data archives. You will learn about two procedures that use backup and restore facilities: planning year-end procedures and implementing course templates.
Chapter 17, Working with Moodle Admin Tools, covers Moodle tools that assist you with specific administrative tasks. These include site admin presets, database tools, as well as CLI scripts. We will also look at some add-ons, especially the powerful Moodle Shell, Moosh.
No Moodle is an island. While many Moodle systems are operated in isolation, there are scenarios where your LMS must cooperate with external entities, whether exchanging data with other systems via web services, connecting disparate Moodle instances, or supporting multiple tenants. This part deals with setting up such topologies and comprises the following chapters.
Chapter 18, Integrating External Systems Using Web Services, looks at ways to integrate Moodle with other systems via web services. We will provide information about the basic concepts of Moodle web services before you learn how to set up external systems and users controlling Moodle.
Chapter 19, Setting Up Moodle Networking, tells you how to connect disparate Moodle systems in a peer-to-peer setup or via a Moodle hub. You will further learn how to enable MoodleNet, a platform to find, share and curate open educational resources.
Chapter 20, Supporting Multi-Tenancy, discusses different approaches and models to design and implement a multi-tenancy in Moodle. We distinguish between different multi-tenancy setups: multi-tenancy by categories, multi-tenancy by isolated systems, and multi-tenancy in Moodle Workplace.
Appendix, Configuration Settings, provides you with a list of parameters that can be modified in Moodle’s configuration file and the impact each of these values will have. The areas covered are administration settings and system settings.
For Moodle, you must have the following components up and running on your server (at the time of writing for version 4.0):
Database: MySQL (version 5.7 or later utilizing the ACID-compliant InnoDB storage engine), PostgreSQL 10+, MariaDB 10.2.29+, Aurora MySQL (on Amazon Web Services), Microsoft SQL Server 2017+, and Oracle 11.2+.Web server: Apache is the preferred web server option, but Moodle works well with any other web server that supports PHP, such as Microsoft IIS.PHP 7.3.0 is the minimum PHP version to run Moodle 4; PHP 7.4.0 is the minimum version from Moodle 4.1 onwards. PHP 8 is also supported.PHP extensions: Moodle makes use of a number of PHP extensions, most of which are compiled in PHP by default: curl, ctype, dom, fileinfo, gd, hash, iconv, intl, json, mbstring, openssl, pcre, simplexml, spl, xml, xmlreader, zip, and zlib.Depending on your specific setup, additional software might be required.
If you don’t have access to the preceding components, ensure that you have full administrator access to a Moodle system. You won’t be able to carry out any system-level operations but will be able to administer Moodle via its web interface fully.
We also provide a PDF file that has color images of the screenshots and diagrams used in this book. You can download it here: https://packt.link/PnRUP
There are a number of text conventions used throughout this book.
Code in text: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: “To prevent dataroot from being accessible, move the directory outside the web directory and modify config.php accordingly by changing the $CFG->dataroot entry.”
A block of code is set as follows:
/* Change toolbar background color to orange */ .toolbar-background { background: orange; }Bold: Indicates a new term, an important word, or words you see on screen. For example, words in menus or dialog boxes appear in the text like this. An example is “Go to General | Advanced features and tick the Enable web services for mobile devices option.”
Tips or Important Notes
Appear like this.
Feedback from our readers is always welcome.
General feedback: If you have questions about any aspect of this book, email us at [email protected] and mention the book title in the subject of your message.
Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packtpub.com/support/errata and fill in the form.
Piracy: If you come across any illegal copies of our works in any form on the internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected] with a link to the material.
If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.
Once you’ve read Moodle 4 Administration, we’d love to hear your thoughts! Please click here to go straight to the Amazon review page for this book and share your feedback.
Your review is important to us and the tech community and will help us make sure we’re delivering excellent quality content.
Thanks for purchasing this book!
Do you like to read on the go but are unable to carry your print books everywhere? Is your eBook purchase not compatible with the device of your choice?
Don’t worry, now with every Packt book you get a DRM-free PDF version of that book at no cost.
Read anywhere, any place, on any device. Search, copy, and paste code from your favorite technical books directly into your application.
The perks don’t stop there, you can get exclusive access to discounts, newsletters, and great free content in your inbox daily
Follow these simple steps to get the benefits:
Scan the QR code or visit the link belowhttps://packt.link/free-ebook/9781801816724
Submit your proof of purchaseThat’s it! We’ll send your free PDF and other benefits to your email directlyIn this first chapter, we’ll start by installing Moodle.
After providing an overview describing the most suitable setup, we will outline the necessary software and hardware requirements before covering the following installations:
Installing Moodle in a LAMP environmentInstalling Moodle via the command-line interface (CLI)Upgrading Moodle manually and via the CLI and GitWe won’t be covering the installation on operating systems other than Linux, but we will provide some pointers to resources for Windows and macOS.
Moodle can be scaled from a single instructor to an entire institution. We will only cover basic installations and present solutions to some common problems. We will also assume you are familiar with basic Linux system administration.
In this chapter, we will be covering the following topics:
Preparing your Moodle installationInstallation in a LAMP environmentInstallation via the command-line interfaceUpdating MoodleBefore you start installing Moodle, you have to decide which setup is right for your organization. Once you have decided, there are several hardware and software prerequisites you have to fulfill before you can get started.
There are many different environments in which you can set up Moodle. The three main criteria that will help you determine the correct setup are as follows:
Flexibility: If you want to have complete control over your system, install plugins, be able to tweak system settings, and make frequent changes to the setup, you should host your own server. However, if your preferred choice is to only administer Moodle while somebody else is looking after the operating system, the web server, and backups, it is better to opt for a professionally-hosted setup, particularly the offerings provided by authorized Moodle Partners.Scalability: This is entirely driven by the number of active learners and educators logged in to Moodle simultaneously. Moodle on a small server will not be able to cope with hundreds of concurrently logged-in users. On the other hand, a load-balanced cluster would be overkill for a small institution with a few dozen learners. The following table provides some indicative setups for different types of educational organizations:Figure 1.1 – Moodle setups depending on user numbers
Please bear in mind that these are only indicative numbers that are not written in stone and also depend on the other factors mentioned here.
Each Moodle instance must be installed on a dedicated or shared server, either hosted in-house or externally. If you decide to go down the hosted route, avoiding a cheap hosting package is highly recommended as those systems are not optimized for Moodle usage; their one-size-fits-all approach will significantly impact the system’s performance, especially with an increasing number of concurrent users.
Moodle HQ offers hosting on moodlecloud.com; however, these packages come with some limitations (the numbers depend on the chosen plan): user limits, storage limits, no way to install plugins or custom themes, and the inability to modify some hard-coded admin settings. If these restrictions are acceptable, hosting on moodlecloud.com might be suitable for your organization.
Cost: Budgetary constraints will undoubtedly play an important role. Unless you already have the appropriate infrastructure in place, it will likely be more cost effective to host your Moodle system externally as it saves you from purchasing servers and renting a 24/7 data connection that caters to your users’ needs. The licensing cost will be significantly higher if you use commercial operating systems, web servers, and database systems instead of an open source solution. Either way, Moodle is designed to support a wide range of possible infrastructures suitable to your organization’s IT policy.In addition to these three criteria, which influence the decision about the underlying infrastructure, other factors, such as in-house expertise, compatibility with other systems, IT policies, personal preference, and existing resources, will impact your decision.
We will be covering the most popular operating system for hosting Moodle – Linux. For other operating systems or setups, such as in virtualized environments or on multi-server clusters, please consult your local Moodle Partner (moodle.com/solutions/certified-service-providers). Some hosting companies offer quick one-click installations; while the resulting Moodle system is sufficient for experimental sites, it is certainly unsuitable for production environments.
Several hardware and software requirements must be satisfied before we can start installing Moodle.
These requirements apply if you host Moodle yourself or if it is hosted on an external server (shared, virtual, dedicated, or clustered). On cheaper hosting packages, the hardware configuration is often insufficient to run Moodle efficiently:
Figure 1.2 – Moodle hardware
Let’s take a look at these requirements in more detail:
Disk space: Moodle itself takes up approximately 1 GB of disk space. However, this only provides you with a naked system and does not consider the space you require for any learning resources. The faster the disks, the better. RAIDed disks are recommended but are not essential on smaller installations.Memory: A good rule of thumb is to have 1 GB of RAM for every 5 to 10 concurrent users. You have to double this calculation on Windows-based systems due to the higher overhead of the operating system. Of all the hardware components, RAM will impact Moodle’s performance the most.Important note
The more RAM, the better; the faster the RAM, the better.
CPUs: Processor type and speed are essential too, but not as important as RAM. As always, the faster the CPU, the better, and the more cores a CPU has, the more powerful it will be.Network: While Moodle can run on a standalone machine, its full potential is in a networked environment. Fast network cards are essential, as is good upload and download speed if the LMS is accessed over the internet.Now, let’s look at the software requirements.
While it is recommended to have the latest version installed, for Moodle 4, you must have the following components up and running on your server (release-specific notes can be found at moodledev.io/general/releases):
Database: Moodle officially supports the following database systems: MySQL (version 5.7 or later utilizing the ACID-compliant InnoDB storage engine), PostgreSQL 10+, MariaDB 10.2.29+, Aurora MySQL (on Amazon Web Services), Microsoft SQL Server 2017+, and Oracle 11.2+.Web server: Apache is the preferred web server option, but Moodle works well with any other web server that supports PHP, such as Microsoft IIS.PHP: PHP 7.3.0 is the minimum PHP version for running Moodle 4; PHP 7.4.0 is the minimum version from Moodle 4.1 onwards. PHP 8 is also supported. You might have to change some PHP settings in the php.ini or .htaccess file (for more details, see docs.moodle.org/en/Installing_Moodle).PHP extensions: Moodle makes use of several extensions, most of which are compiled into PHP by default. They are as follows:Compulsory extensions: curl, ctype, dom, fileinfo, gd, hash, iconv, intl, json, mbstring, openssl, pcre, simplexml, spl, xml, xmlreader, zip, and zlibRecommended extensions: exif, soap, sodium, tokenizer, and xmlrpcConditional extensions: mysql, odbc, and pgsql (depending on the database) and ldap, ntlm, and others (depending on the authentication mechanism used)Depending on your specific setup, additional software might be required. It is assumed that the database, web server, PHP, and extensions have been installed correctly, as this is not an LMS administrator task. Once this is the case, we are ready to go.
Important note
To access Moodle, a modern web browser (the latest version of Firefox, Google Chrome, Edge, or Safari) is required.
Before we start the installation process, it is worth familiarizing yourself with Moodle’s releases and versions.
Moodle versions follow a strict calendar that is published and updated regularly on moodledev.io/general/releases. If a planned feature is not ready for the imminent release, it will be moved to the next version; that is, a release date will never be changed, but the time when features will be introduced might be.
The release frequency for major versions (4.0, 4.1, and so on) is twice a year (the second Monday of May and November).
Moodle releases minor versions (4.1.1, 4.1.2, and so on) on the second Monday of March, May, July, September, and November. The same applies to unscheduled releases in the case of a severe security issue or serious regression being fixed.
Moodle distinguishes between two types of releases:
Standard support release: Bugs will be fixed for 12 months, and security issues will be provided for 18 monthsLong-term support release: Bugs will be fixed for 12 months, and security issues will be provided for 36 monthsThe simplified release calendar is shown in the following timeline; you can find a more detailed version at moodledev.io/general/releases:
Figure 1.3 – Moodle releases
When Moodle 4.0 was released in April 2022, versions 3.9 to 3.11 were still supported. By the time Moodle 4.1 is released, only version 3.9 will be supported since its lifetime has been extended (hence the long-long-term support label) to give admins more time to upgrade to the version 4 branch.
If you wish to stay up-to-date with future releases, check Moodle’s roadmap at moodledev.io/general/community/roadmap, where you will find the current plans for the future technical development of all Moodle’s products and services.
OK, enough of version numbers and release dates. Let’s learn how to install (the latest version of) Moodle.
Moodle is developed in Linux using Apache, MySQL, and PHP (known as the LAMP stack). If you have a choice, this is the preferred environment to use. There is an ongoing debate about whether PostgreSQL is the more suitable database option, but we will stick with MySQL/MariaDB as this is the system most administrators are familiar with. Also, some organizations are bound to Microsoft SQL or Oracle. If this is the case, please refer to the respective installation guide, as this is beyond the scope of this book.
The high-level installation process is shown in the following process diagram:
Figure 1.4 – Moodle installation process
We will go through each phase in the remaining subsections, covering each installation step in a Linux environment. The process is the same for other operating systems, which we won’t cover; here are some pointers that should get you started:
For Windows servers with a small number of users, the XAMPP-based Moodle distribution is suitable. XAMPP is a free Apache distribution that contains MySQL and PHP (as well as Perl) and exists for several operating systems. The Moodle distribution for Windows makes full use of XAMPP and is located at download.moodle.org/windows. The installation works on all the latest Windows PCs and server variants.For larger Windows installations, you have to install Moodle manually, which involves installing a database server (MS SQL or any other supported system), a web server (Microsoft IIS or Apache), and PHP separately. You can find details about this process at docs.moodle.org/en/Windows_installation.MAMP is a free distribution that contains Apache (and Nginx), MySQL, and PHP for macOS. Like its Windows counterpart, the Moodle distributions for macOS are only intended for local installations and not for production environments. Moodle4Mac is available as universal binaries via MAMP, located at download.moodle.org/macosx.Now, let’s go through the installation process, starting with downloading Moodle.
Go to download.moodle.org and select the latest release:
Figure 1.5 – Moodle downloads
A newer version is likely to be available by the time you read this. If you wish to go with the 4.0.x version this book has been written for, select Other supported releases; otherwise, feel free to go with the latest stable build; most content in this book will still be applicable.
There are five types of builds available on Moodle’s download site:
Latest release: There are two releases for the current version of Moodle: the latest stable build and the latest official release. The latest stable version is created weekly (every Wednesday) and is the best choice for a new server. The latest official release contains the stable build and new fixes, but the version will not have gone through the weekly code review and might contain unresolved issues.Other supported releases: The Moodle development team maintains older versions than the current ones, as outlined in the release schedule earlier.Security-only-supported releases: Critical fixes impacting security or data loss will be provided for one further release, but no other bug fixes will be back-ported. See the information on Moodle versions provided earlier.Legacy releases: For older versions, the last build is made available. However, these are not maintained any further.Development releases: Moodle also gives you the option to download beta releases of the software (if available) and the latest development release. These should only be downloaded for testing or development purposes, never in production environments!Each version is made available in two compressed formats: TGZ (use the tar command to uncompress) and ZIP (use the unzip command to extract it). You can download them by clicking on the respective link or, if you have (secure) shell access, retrieving the file directly by using the wget command:
wget http://download.moodle.org/moodle/moodle-latest.zipImportant note
The location where you install Moodle is referred to as dirroot.
If you make use of Moodle Shell (MOOSH), which is described in more detail in Chapter 17, Working with Moodle Admin Tools, you can use the following command to download the latest stable branch of Moodle:
moosh download-moodleOnce you have moved the file to the location where you want to install it on your web server (dirroot), extract the file using the unzip command or tar if you downloaded the TGZ version:
unzip moodle-latest.zip tar xvfz moodle-latest.tgzIf you place the entire folder in your web server documents directory, the site will be located at www.yourwebserver.com/moodle. To access your site from www.yourwebserver.com, copy the contents directly into the main web server’s documents directory.
Important note
The URL via which Moodle is accessed is referred to as wwwroot.
Once the download step has been completed, you must create the database that Moodle uses to store its data.
Moodle requires a database where it can store its information. While sharing an existing database is possible, creating a separate database for Moodle is highly recommended. Adding a new database can either be done via a web interface, as provided for hosted servers, or via the command line.
Most hosting providers provide a dedicated web interface to carry out basic database operations. Alternatively, you can use phpMyAdmin, open source software that allows you to manage MySQL databases over the web. phpMyAdmin is part of most Linux distributions and many control panels, but it is often configured not to allow new databases to be created. If this is the case, you must create the database from the database manager in your control panel.
phpMyAdmin allows you to perform both steps – creating a database and adding a new user – in a single action, as shown in the following screenshot. We will create a user, packt, and also check the Create database with same name and grant all privileges option:
Figure 1.6 – Creating a Moodle database and user in phpMyAdmin
While you can use an existing database user account, creating a dedicated user for the Moodle database is good practice.
Important note
Do not use the MySQL root account for your Moodle database!
You don’t need to create any tables; Moodle will populate the database during installation.
Creating the Moodle database via a web interface is simple, but most technical administrators prefer to work via the command line.
If you don’t have access to a web interface to create MySQL databases and user accounts, or if you prefer to use a Linux shell, you can perform these steps via the command line:
Start the database command-line tool by entering mysql -root -p and enter the password at the prompt.Create a database (called packt) by entering CREATE DATABASE packt; (all MySQL commands must be terminated with a semicolon).Set the default character and collation order to UTF8 by entering ALTER DATABASE packt DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ ci;.Create a user and password (here, packt@localhost and password, respectively) and grant database access permissions by entering GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, CREATE TEMPORARY TABLES, DROP, INDEX, ALTER ON packt.* TO packt@localhost IDENTIFIED BY 'password';.Exit the MySQL command tool by entering QUIT.It is necessary to reload the grant tables using the following command line:
mysqladmin -u root -p reloadWith that, you have set up the database. All you have to do now is create Moodle’s data directory. Then, you can start installing Moodle itself.
Moodle stores most of its information in the database you have just created. However, uploaded files such as assignments, course images, or user pictures are stored in a separate directory. This data directory in Moodle is usually referred toas moodledata.
Important note
The location that holds your Moodle data files is referred to as dataroot.
Later, the Moodle installer will attempt to create this directory, but in some setups, this operation will fail due to security restrictions. To be on the safe side, it is better to create moodledata manually or via a web-based file manager, as provided by some systems.
Important note
It is crucial to create moodledata on your server where it cannot be accessed publicly – that is, outside your web directory.
moodledata is where all the uploaded files by course authors and learners will be stored, so ensure this is adequately dimensioned. You may also consider creating moodledata in a separate partition.
Any moodledata permissions should be rwxrwx--- (chmod –R 0770 moodledata). If you use 0777, everybody on the server will have access to the files.
Change the user and group of the directory to that of your web server (usually, this will be apache or www-data and nobody or www-data) by entering chown –R apache:nobody moodledata.
If you don’t have permission to create the data directory in a secure location, create the .htaccess file in your home directory and ensure it contains the following two lines:
order deny,allow deny from allThese two settings prevent files from being accessed without users having permission to do so.
We have completed the first three steps – downloading Moodle, creating the database, and preparing moodledata – which are the prerequisites for running the installer script.
The installer script performs two main actions – populating the database and creating the configuration file, config.php. The Moodle installer is initiated by entering the URL of wwwroot (the location where you copied Moodle) into your web browser; Moodle will recognize that it hasn’t been installed yet and start the process automatically.
The Moodle installer has to set a session cookie. If your browser has been configured to trigger a warning, make sure you accept that cookie.
The first screen lets you choose the language to be used during installation – this is not the locale used for Moodle, only the language for the installation:
Figure 1.7 – Moodle installation – Choose a language
The following screenshot displays the expected values for the Web address entry of the site (wwwroot), the Moodle directory (dirroot) entry, and the Data directory (dataroot) entry; you might have to modify the Data directory entry if the location of your moodledata differs:
Figure 1.8 – Moodle installation – Confirm paths
If dataroot cannot be located or does not have the correct permissions, an error message containing details will be displayed. The same applies if dataroot is accessible directly via the web and is not secure.
You must select which database you wish to use on the following screen. Only the drivers for MySQL, MariaDB, Aurora MySQL, and PostgresSQL are installed on my system. The respective PHP extension must be installed first if you wish to use other database systems such as Oracle or MS SQL Server:
Figure 1.9 – Moodle installation – Choose database driver
This interface uses the configuration details previously established. The following screenshot shows the required fields but will look slightly different if you have chosen a database driver other than MySQL:
Figure 1.10 – Moodle installation – Database settings
The Database host entry’s default is localhost (127.0.0.1), which is correct if the database is located on the same server as the web server. If it is located on a separate server, specify the IP address (preferably unresolved to improve performance).
All the tables the Moodle installer will create will be prefixed with mdl_. The Tables prefix entry should only be changed if you run multiple Moodle installations using the same database.
Next, the Moodle installer checks whether certain components have been installed. Not all the modules are compulsory – see the Moodle prerequisites section of this chapter and the notice on-screen. The installer also verifies the critical PHP settings. If any of the tests have not passed, you must go back to the Software requirements section to resolve any problems and restart the installation process after the issues have been fixed. Otherwise, some features may not work, or the installer will not continue, depending on the importance of the module:
Figure 1.11 – Moodle installation – Server checks
When you have confirmed the server check screen, the installer will display Moodle’s copyright notice, which you must confirm. The appearance of this screen also means that the Moodle configuration file, config.php, has been successfully created. The installer will display the config file’s content if the creation fails (usually because of incorrect permissions). You will have to copy the text from the screen and paste it manually into config.php in your dirroot.
Once you have accepted the agreement (you can find the full text of the GPL license at docs.moodle.org/dev/License), all the database tables will be created. This process might take a few minutes.
Once the table has been created and populated, you will see the screen where you can set up the administrator account. The default Username is admin, which should be changed for security reasons. You must fill in the following self-explanatory fields: New password, First name, Surname, and Email address. In Chapter 5, Managing Users, Cohorts, and Authentication, all other fields will be explained in great detail:
Figure 1.12 – Moodle installation – setting up the admin account
The last screen of the installation script asks you to enter some home page settings; namely, Full site name, Short name for site, and Site home summary. These home page settings can be modified later (see Chapter 7, Enhancing Moodle’s Look and Feel).
Change the Default timezone entry to the location of your server, not your location. The installer allows you to turn on Self registration. Leave this disabled for now until you have read Chapter 5, Managing Users, Cohorts, and Authentication. You must also provide a Support email (for your user queries) and a No-reply address (to avoid email issues).
Once this information has been entered and the screen has been confirmed, you are ready to start using Moodle. However, first, you must set up the execution of Moodle’s maintenance script.
Moodle has to perform plenty of background tasks regularly.
Important note
The cron script, executed by the cron process, performs Moodle’s background tasks.
An entire page has been dedicated to cron in the Moodle documentation; you can find it at docs.moodle.org/en/Cron. You must set up the cron process; otherwise, any timed Moodle features, such as scheduled backups, sending forum notifications, statistics processing, and so on, will not work.
The script, cron.php, is located in the admin directory and can be triggered manually through a web browser (if allowed in the security settings). Once executed, the output from the script (<yoursite>/admin/cron.php) is shown on-screen, and you have to navigate back to your Moodle system manually.
There are several ways to call the cron script. The most popular option is via the wget command:
wget –q –O /dev/null http://<yoursite>/admin/cron.phpHowever, if this does not suit your setup, check out docs.moodle.org/en/Cronfor alternatives.
Most control panels allow you to set up scheduled tasks via a cron job management tool. Bear in mind that this is not part of Moodle but part of your hosting package. Alternatively, you can create a crontab entry, a file located in the /etc directory that contains all the system-wide cron entries. This file can also be edited manually using crontab -e, but ensure you get the syntax right!
To run the CLI cron script every minute, add the following line, replacing <yourpath> with the directory where your Moodle system is located (dirroot):
* * * * * /usr/bin/php <yourpath>/cron.php >/dev/nullImportant note
It is highly recommended to run the cron process every minute!
That’s it. Moodle is now ready to go. Two optional steps you should quickly run through are covered in the next section.
To make sure that Moodle is running without problems, go to Notifications in the Site administration menu of the General tab:
Figure 1.13 – Moodle installation – checking system notifications
In the case of my installation, there are two issues – the cron script has not been configured and the mobile app is not enabled. I need to fix the former issue; the latter can wait until Chapter 11, Enabling Mobile Learning. Other messages might appear in the Notifications area, and you should resolve them promptly.
Moodle provides some statistics about its usage on moodle.net/stats, and to be included in these figures, you have to register your Moodle site via Site administration | General | Registration. Registration with Moodle is optional and free, and you decide what information will be made public.
Important note
Even if you opt out of providing any usage patterns for your site, it is still highly recommended to register to receive information on new Moodle releases, security alerts, and other important news.
The following is the registration form, alongside a screenshot from the public statistics:
Figure 1.14 – Moodle registration and statistics
This concludes the installation process for Moodle in a LAMP environment. If you have encountered any issues that have not been covered in these instructions or if your setup differs from the one described, go to docs.moodle.org/en/Installing_Moodle, where more installation details are provided, and exceptions are covered in great detail.
An alternative to installing Moodle via the web interface is via the command-line interface (CLI), which is the topic of the following section.
Moodle provides a CLI that lets you perform several administrative tasks from the Unix shell prompt. There is no CLI for Windows-based systems. CLI-based installations are useful if you need to automate setups, for example, in an environment where you host multiple Moodle instances.
The CLI is not for the faint-hearted, so be careful when using it. You must execute the installation script as the web server user, usually www-data or apache. You can run the installation script, install.php, in interactive mode (you will have to enter any parameters by hand) or in non-interactive mode, where the script will run silently.
From your dirroot, you can initiate the interactive script as follows:
sudo –u www-data /usr/bin/php admin/cli/install.phpSomething more interesting is the CLI’s non-interactive mode, as this can be used for scripting and automation purposes. A list of all the available parameters can be displayed using the --help command:
sudo –u www-data /usr/bin/php admin/cli/install.php --helpThe output of the executed command is shown in the following screenshot:
Figure 1.15 – Moodle installation via the CLI
An example command line would look similar to the following, where you will have to adjust the parameters to your local setup:
sudo -u www-data /usr/bin/php admin/cli/install.php --wwwroot=http://123.54.67.89/moodle --dataroot=/var/moodledata/ --dbtype=mysqli --dbhost=localhost --dbname=moodle --dbuser=moodle --dbpass=password --fullname=moodle4 --shortname=moodle4 --adminpass=Password123! --non-interactive --agree-licenseMore Moodle tasks can be administered via the CLI, for example, resetting passwords or putting Moodle in maintenance mode. We will show the relevant syntax at the appropriate places throughout this book and have also dedicated a section to the CLI in Chapter 17, Working with Moodle Admin Tools.
Once your Moodle system is up and running, you need to ensure that it is kept up to date. Updating Moodle manually and via the command line is covered in the following section.
We provided an overview of Moodle’s release calendar earlier in this chapter. There is usually no need to install every single minor point release; however, there are several scenarios when you should upgrade your Moodle system:
Security patches have been issuedNew features have been addedBugs have been fixed that affect your setupA major version is releasedThe support cycle of your setup comes to an endThere are principally two ways Moodle systems can be updated: you can run updates manually (using the web interface or the CLI) or stay up to date using Git commands. Both procedures will be described in this section.
Either way, before you start, ensure you put Moodle in maintenance mode to ensure that no other user is logged in during the update. Go to Site administration | Server | Maintenance mode, choose Enable for Maintenance mode, and enter a maintenance message:
Figure 1.16 – Enabling maintenance mode
You can also put Moodle in maintenance mode using its CLI, as follows:
sudo –u www-data /usr/bin/php admin/cli/maintenance.php --enableUsing the --enablelater=MINUTES flag, you can specify the period before entering CLI maintenance mode, which is useful when you run an automatic update.
To change back to normal mode, use the --disable parameter instead of --enable, as follows:
sudo –u www-data /usr/bin/php admin/cli/maintenance.php –disableOnce Moodle has been put in maintenance mode, you are ready to update your Moodle system.
The high-level process for updating Moodle manually is as follows:
Figure 1.17 – Updating Moodle
If you update from a previous version of Moodle, the process is the same. However, double-check the upgrading document at docs.moodle.org/en/Upgrading for any version-specific issues.
Important note
You have to be at least on version 3.6 to update directly to Moodle 4. If you’re upgrading from earlier versions, you must upgrade to 3.6 as a first step.
Before you install a new update, it is highly recommended that you run a backup
