Moodle is a free and open-source learning management system designed to provide teachers or educators the tools to create personalized learning environments filled with dynamic online courses which help students and other users to achieve their learning goals. Today we will learn how to install the latest Moodle 3.5 version on Debian 9, with Apache web server, MariaDB and PHP 7.
Moodle comes with hundreds of built-in features such as:
- Modern and easy to use interface
- Personalized Dashboard
- Collaborative tools and activities
- All-in-one calendar
- Secure authentication and mass enrollment
- Multilingual capability
- Direct learning paths
- Multimedia Integration
- Customizable site design and layout
- and much more …
1. Login via SSH
Connect to your server via SSH as user root, using the following command:
ssh [email protected]IP_ADDRESS -p PORT_NUMBER
make sure that you replace “IP_ADDRESS” and “PORT_NUMBER” with your actual server IP address and SSH port number.
2. Update the OS Packages
Once logged in, run the following command to update your OS packages:
apt-get update apt-get upgrade
3. Install Apache Web Server
To install the Apache web server on your server, run the following command:
apt-get install apache2
Once the installation is complete, you need to start Apache and enable it to start automatically upon system boot
systemctl start apache2 systemctl enable apache2
4. Install MariaDB
Moodle stores most of its data in a database, so we will install the MariaDB database server:
apt-get install mysql-client mysql-server
When the MariaDB installation is complete, run the following command to secure your MariaDB installation:
5. Install PHP 7
Next, we will install PHP 7 and all the additional PHP modules which will be required by Moodle:
apt-get install php7.0 libapache2-mod-php7.0 php7.0-pspell php7.0-curl php7.0-gd php7.0-intl php7.0-mysql php7.0-xml php7.0-xmlrpc php7.0-ldap php7.0-zip php7.0-soap php7.0-mbstring
6. Download and install Moodle
Before we download the moodle package, first let’s navigate to the default Apache web server root directory:
To download the latest moodle package, use the following command:
[email protected]:/# wget https://download.moodle.org/stable35/moodle-latest-35.tgz --2018-09-15 12:56:34-- https://download.moodle.org/stable35/moodle-latest-35.tgz Resolving download.moodle.org (download.moodle.org)... 18.104.22.168, 22.214.171.124, 2400:cb00:2048:1::6814:da19, ... Connecting to download.moodle.org (download.moodle.org)|126.96.36.199|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 46447511 (44M) [application/x-gzip] Saving to: 'moodle-latest-35.tgz' moodle-latest-35.tgz 100%[=====================================================================================================>] 44.29M 60.7MB/s in 0.7s 2018-09-15 12:56:36 (60.7 MB/s) - 'moodle-latest-35.tgz' saved [46447511/46447511]
To extract the file, run the following command:
tar xzf moodle-latest-35.tgz
Change the ownership and the permissions of the extracted Moodle directory with the following command:
chown -R www-data:www-data /var/www/html/moodle chmod -R 775 /var/www/html/moodle
Additionally, you will also need to create a directory for the Moodle data:
And set the correct ownership and permissions:
chown www-data:www-data /var/www/html/moodledata chmod 775 /var/www/html/moodledata
7. Configure MariaDB and create a new database
Before you create a new moodle database, you will need to modify the default MariaDB configuration file. Moodle requires that you change the default storage engine to innodb and change the default file format to Barracuda. You will also need to set innodb_file_per_table in order for Barracuda to work properly.
To edit the MariaDB configuration file. Run the following command:
Then add the following lines just below the [mysqld] section:
default_storage_engine = innodb innodb_file_per_table = 1 innodb_file_format = Barracuda innodb_large_prefix = 1
Save and exit the file and restart the MariaDB server with:
systemctl restart mariadb
You can now log in to the MariaDB server as user root and create a new user and database for the Moodle installation:
mysql -u root -p CREATE DATABASE moodle DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci; GRANT ALL PRIVILEGES ON moodle.* TO 'moodle_user'@'localhost' IDENTIFIED BY '<span style="color: #ff0000;">PASSWORD</span>'; FLUSH PRIVILEGES; exit;
Don’t forget to replace ‘PASSWORD‘ with an actual strong password.
8. Configure Apache Web Server
If you have a valid domain name which you would like to use to access your Moodle installation, you will need to create a new Apache virtual host for your domain name with the following content:
<VirtualHost *:80> ServerAdmin [email protected]m DocumentRoot /var/www/html/moodle ServerName yourdomain.com ServerAlias www.yourdomain.com <Directory /var/www/html/moodle/> Options FollowSymLinks AllowOverride All Order allow,deny allow from all </Directory> ErrorLog /var/log/apache2/yourdomain.com-error_log CustomLog /var/log/apache2/yourdomain.com-access_log common </VirtualHost>
Save the file and enable the virtual host with the following command:
Once you enable the virtual host, you will need to restart the Apache web server:
systemctl restart apache2
9. Finish the Moodle installation in your browser
If the DNS records are properly configured, and your domain is pointed to your server, you can use it to access your Moodle installation by typing http://yourdomain.com in your browser and choose the preferred language to continue with the installation.
Verify that all Moodle directory paths are correct and click on Next.
Choose the database type.
Enter the database name, username, and password of the moodle database we have created earlier.
Follow the on-screen instructions to finish the installation. In the end, you should see the following screen where you need to configure your main administrator account.
Congratulations! You have now successfully installed Moodle on your server. For more information on how to configure and use Moodle, you can check their official documentation.
Of course, you don’t have to install Moodle on Debian 9, if you use one of our Managed Debian Cloud Hosting services, in which case you can simply ask our expert system administrators to install Moodle on Debian 9 for you. They are available 24×7 and will take care of your request immediately.
PS. If you liked this post, on how to install Moodle on Debian 9, please share it with your friends on the social networks using the buttons below or simply leave a comment in the comments section. Thanks.