The Moodle architecture
Moodle runs on any web server that supports the PHP programming language and a database. It works best, and there is more support, when running on the Apache web server with a MySQL database. These requirements—Apache, PHP, and MySQL—are common to almost all commercial web hosts, even the lowest-cost ones.
The Moodle learning management system resides in three places on your web host:
- The application occupies one directory, with many subdirectories for the various modules
- Data files that the students and teachers upload—such as photos and assignments submitted by students—reside in the Moodle data directory
- Course material that you create with Moodle (web pages, quizzes, workshops, lessons, and so on), grades, user information, and user logs reside in the Moodle database
The Moodle application directory
The following screenshot shows you my Moodle application directory. Without even knowing much about Moodle, you can guess the function of several of the directories. For example, the admin
directory holds the PHP code that creates the administrative pages, the lang
directory holds translations of the Moodle interface, and the mod
directory holds the various modules:
The index.php
file is the Moodle home page. If a student was browsing my Moodle site, the first page that the student would read is the file http://moodle.williamrice.com/index.php.
On my site, the free course Basic Botany for Foragers happens to be course number 4. Only the Moodle system knows it as course number 4; we know it as Basic Botany for Foragers. When a student enters that course, the URL in the student's browser reads http://moodle.williamrice.com/moodle/course/view.php?id=4. In the preceding screenshot, you can see that /course
is one of the directories in my Moodle installation. As the user navigates around the site, different .php
pages do the work of presenting information.
Because each of Moodle's core components and modules is in its own subdirectory, the software can be easily updated by replacing the old files with new ones. You should periodically check the https://www.moodle.org website for news about updates and bug fixes.
The Moodle data directory
Moodle stores the files uploaded by the users in a data directory. This directory should not be accessible to the general public over the web. That is, you should not be able to type in the URL for this directory and access it using a web browser. You can protect it either by using an .htaccess
file or by placing the directory outside of the web server's documents directory.
The preceding screenshot shows you that in my installation, the web document directory for moodle.williamrice.com is /www/moodle
. Therefore, I placed the data directory outside /www/moodle
, in /www/moodledata_for_moodle.williamrice.com
, as seen in the following screenshot:
On my server, the directory /www/moodledata
corresponds to the subdomain www.moodledata.williamrice.com. This subdomain is protected from open access by a .htaccess
file. The directory /www/www
corresponds to the root domain, www.williamrice.com.
The Moodle database
While the Moodle data directory stores the files uploaded by students, the Moodle database stores most of the information in your Moodle site. The database stores objects that you create using Moodle. For example, Moodle enables you to create web pages for your courses. The actual HTML code for these web pages is stored in the database. Links that you add to a course, the settings, the content of forums and wikis, and quizzes created with Moodle, are all examples of data stored in the Moodle database.
The three parts of Moodle—the application, data directory, and database, work together to create your learning site. Backup and disaster recovery are an obvious application of this knowledge. However, knowing how the three parts work together is also helpful when upgrading, troubleshooting, and moving your site between servers.