{"id":5821,"date":"2018-07-31T13:35:27","date_gmt":"2018-07-31T09:35:27","guid":{"rendered":"https:\/\/www.howtoforge.com\/tutorial\/debian-moodle-e-learning-platform\/"},"modified":"2018-07-31T13:35:27","modified_gmt":"2018-07-31T09:35:27","slug":"install-moodle-learning-management-platform-in-debian-9","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/install-moodle-learning-management-platform-in-debian-9\/","title":{"rendered":"Install Moodle (Learning Management Platform) in Debian 9"},"content":{"rendered":"<p>Moodle is a flexible and powerful free open source course management system and e-learning platform written in PHP and often deployed in Linux under Apache\/Nginx web servers with PHP and MySQL\/MariaDB database management system, also known as LAMP or LEMP stack.<\/p>\n<p>This tutorial will explain how to install and configure the latest version of Moodle in Debian 9 release in order to create an e-learning platform at your premises.<\/p>\n<p>Moodle platform offers an intuitive web interface that can be used by educators and trainers to store course data and to keep track of students, grades and online courses. Most major universities worldwide are deploying Moodle e-learning platform in order to ease the educational activities for their students and teachers.<\/p>\n<h2 id=\"requirements\">Requirements<\/h2>\n<p>In order to successfully install and deploy Moodle, your server needs to meet the below requirements.<\/p>\n<ul>\n<li><span\/>A Debian 9 server installed with minimal software requirements on a bare-metal server machine or on a virtual private server<\/li>\n<li><span\/>direct access to root account via console or SSH or remote or direct access to an account with root privileges gained via sudo utility<\/li>\n<li><span\/>A network interface card configured with a static IP address<\/li>\n<li><span\/>In order to use Moodle email registration, notifications or another type of features you should properly set up a mail server properly at your premises with access to IMAP, POP3 and SMTP services.<\/li>\n<li><span\/>A private or a public domain name, depending on your deployment, with the proper DNS records configured for web services. If don\u2019t have a valid or a registered domain name you can perform the installation and access the website via your server IP address<\/li>\n<\/ul>\n<h2 id=\"install-apache-php-and-mysql\">Install Apache, PHP, and MySQL<\/h2>\n<p>In the first step, before you start to install and configure Moodle platform, first log in to your server with root account or an account with root powers and start to update Debian system repositories and software packages by issuing the below commands.<\/p>\n<p class=\"command\">apt update<\/p>\n<p class=\"command\">apt upgrade<\/p>\n<p><strong><b> <\/b><\/strong>Next, after you\u2019ve updated the system software, configure the name for your Debian server by executing the following commands. Make sure you replace the hostname variable to match your own settings, as illustrated in the below example.<\/p>\n<p class=\"command\">hostnamectl set-hostname www.myblog.com<\/p>\n<p>Then, you can verify your machine hostname and hosts file by issuing the below commands.<\/p>\n<p class=\"command\">hostnamectl<\/p>\n<p class=\"command\">cat \/etc\/hostname<\/p>\n<p class=\"command\">hostname \u2013s<\/p>\n<p class=\"command\">hostname \u2013f<\/p>\n<p><strong><b> <\/b><\/strong>In order to apply the kernel updates and apply the hostname changes, issue the below command to reboot the machine.<\/p>\n<p class=\"command\">systemctl reboot<\/p>\n<p>One of the most important LAMP components for deploying Moodle learning platform is an RDBMS database that is used by the web application to store different configurations, such as users, sessions, contacts and other data. In this tutorial, we\u2019ll configure Moodle CMS with MariaDB database backend with loopback access to MySQL database. This means that the database can only be accessed via localhost or 127.0.0.1 address. No external connections can be made to MySQL database. In order to install MariaDB database server and client in Debian 9 server, issue the below command.<\/p>\n<p class=\"command\">apt install mariadb-server mariadb-client<\/p>\n<p>After MariaDB database has finished installing in your Debian server, issue <strong><b>netstat<\/b><\/strong> command as shown in the below example in order to check if the service is up and running and listens for connections on localhost, port 3306.<\/p>\n<p class=\"command\">netstat \u2013tlpn | grep mysql<\/p>\n<p><strong><b> <\/b><\/strong>In case <strong><b>netstat<\/b><\/strong> network utility is not installed by default in your Debian system, execute the below command to install it.<\/p>\n<p class=\"command\">apt install net-tools<\/p>\n<p><strong><b> <\/b><\/strong>The MySQL root account is not properly secured in Debian 9 at installation time. You can log in to the database without a root password. In order to secure the root account, log in to MySQL server console and secure execute the following commands.<\/p>\n<p class=\"command\">mysql -h localhost<\/p>\n<pre readability=\"14\">Welcome to the MariaDB monitor. Commands end with ; or \\g.<p>Your MariaDB connection id is 2<\/p><p>Server version: 10.1.26-MariaDB-0+deb9u1 Debian 9.1<\/p><p>Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.<\/p><p>Type 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.<\/p><\/pre>\n<p class=\"command\"><em><i>MariaDB [(none)]&gt; <\/i><\/em>use mysql;<\/p>\n<pre readability=\"5\">Reading table information for completion of table and column names<p>You can turn off this feature to get a quicker startup with -A<\/p><p>Database changed<\/p><\/pre>\n<p class=\"command\">MariaDB [mysql]&gt; update user set plugin=&#8221; where user=&#8217;root&#8217;;<\/p>\n<pre readability=\"5\">Query OK, 1 row affected (0.00 sec)<p>Rows matched: 1 Changed: 1 Warnings: 0<\/p><\/pre>\n<p class=\"command\">MariaDB [mysql]&gt; flush privileges;<\/p>\n<pre><em><i>Query OK, 0 rows affected (0.00 sec)<\/i><\/em><\/pre>\n<p class=\"command\">MariaDB [mysql]&gt; exit<\/p>\n<pre><em><i>Bye<\/i><\/em><\/pre>\n<p>After you\u2019ve properly enforced the database root account, execute the <strong><b>mysql_secure_installation <\/b><\/strong>script, provided by Debian stretch repositories while installing the database, in order to further secure MySQL database.The script will ask you a series of questions designed to secure MariaDB database: if you want to change MySQL root password, to remove anonymous users, to disable remote root logins and delete the test database. Execute the script by issuing the below command and assure you type <strong><b>yes<\/b><\/strong> to all questions, as shown in the below script output excerpt:<\/p>\n<p class=\"command\">mysql_secure_installation<\/p>\n<pre readability=\"83\">NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB<p>SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!<\/p><p>In order to log into MariaDB to secure it, we'll need the current<\/p><p>password for the root user. If you've just installed MariaDB, and<\/p><p>you haven't set the root password yet, the password will be blank,<\/p><p>so you should just press enter here.<\/p><p>Enter current password for root (enter for none):<\/p><p>OK, successfully used password, moving on...<\/p><p>Setting the root password ensures that nobody can log into the MariaDB<\/p><p>root user without the proper authorisation.<\/p><p>You already have a root password set, so you can safely answer 'n'.<\/p><p>Change the root password? [Y\/n] y<\/p><p>New password:<\/p><p>Re-enter new password:<\/p><p>Password updated successfully!<\/p><p>Reloading privilege tables..<\/p><p>... Success!<\/p><p>By default, a MariaDB installation has an anonymous user, allowing anyone<\/p><p>to log into MariaDB without having to have a user account created for<\/p><p>them. This is intended only for testing, and to make the installation<\/p><p>go a bit smoother. You should remove them before moving into a<\/p><p>production environment.<\/p><p>Remove anonymous users? [Y\/n] y<\/p><p>... Success!<\/p><p>Normally, root should only be allowed to connect from 'localhost'. This<\/p><p>ensures that someone cannot guess at the root password from the network.<\/p><p>Disallow root login remotely? [Y\/n] y<\/p><p>... Success!<\/p><p>By default, MariaDB comes with a database named 'test' that anyone can<\/p><p>access. This is also intended only for testing, and should be removed<\/p><p>before moving into a production environment.<\/p><p>Remove test database and access to it? [Y\/n] y<\/p><p>- Dropping test database...<\/p><p>... Success!<\/p><p>- Removing privileges on test database...<\/p><p>... Success!<\/p><p>Reloading the privilege tables will ensure that all changes made so far<\/p><p>will take effect immediately.<\/p><p>Reload privilege tables now? [Y\/n] y<\/p><p>... Success!<\/p><p>Cleaning up...<\/p><p>All done! If you've completed all of the above steps, your MariaDB<\/p><p>installation should now be secure.<\/p><p>Thanks for using MariaDB!<\/p><\/pre>\n<p><em><i> <\/i><\/em>Finally, after you\u2019ve secured MySQL daemon, log in to the database console and provide no password for root account. The access to the database should be denied if no password is provided for the root account, as illustrated in the below command excerpt:<\/p>\n<p class=\"command\">mysql -h localhost -u root<\/p>\n<pre><em><i>ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)<\/i><\/em><\/pre>\n<p><strong><b> <\/b><\/strong>Logging in to MySQL database console should be granted if you provide the <strong><b>root<\/b><\/strong> password, as shown in the command sample:<\/p>\n<p class=\"command\">mysql -h localhost -u root -p<\/p>\n<pre readability=\"16\">Enter password:<p>Welcome to the MariaDB monitor. Commands end with ; or \\g.<\/p><p>Your MariaDB connection id is 15<\/p><p>Server version: 10.1.26-MariaDB-0+deb9u1 Debian 9.1<\/p><p>Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.<\/p><p>Type 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.<\/p><p>MariaDB [(none)]&gt; exit<\/p><p>Bye<\/p><\/pre>\n<p><strong><b> <\/b><\/strong><strong\/>Moodle CMS is a web-based application that is mostly written in PHP server-side programming language. So far we\u2019ve installed only MySQL database component of LAMP. In order to execute the PHP file scripts of the application, a web server, such as Apache HTTP server, and a PHP processing gateway must be installed and operational in the system. In order to install Apache web server and the PHP interpreter alongside with all required PHP modules needed by the application to run properly, issue the following command in your server console.<\/p>\n<p class=\"command\">apt install apache2 libapache2-mod-php7.0 php7.0 php7.0-mysql php7.0-gd php7.0-opcache php7.0-json php7.0-mbstring php7.0-xml php7.0-ldap php7.0-cli php7.0-curl php7.0-ldap php7.0-zip php7.0-bcmath php-imagick php7.0-xmlrpc php7.0-soap php7.0-intl<\/p>\n<p>Issue the following command in order to verify if all the installed PHP modules are enabled in your system<\/p>\n<p class=\"command\">php7.0 \u2013m<\/p>\n<p>After Apache and PHP have been installed, test if the web server is up and running and listening for network connections on port 80 by issuing the following command with root privileges.<\/p>\n<p class=\"command\">netstat \u2013tlpn<\/p>\n<p><strong><b> <\/b><\/strong>From the netstat command output we can see that Apache web server is listening for incoming network connections on port 80. For the same task, you can also use the <strong><b>ss<\/b><\/strong> command, which is automatically installed, by default, in Debian 9.<\/p>\n<p class=\"command\">ss- tulpn<\/p>\n<p><strong><b> <\/b><\/strong>In case the UFW firewall application is installed and enabled in Debian server, you should add a new rule to allow HTTP traffic to pass through the firewall by issuing the following command.<\/p>\n<p class=\"command\">ufw allow WWW<\/p>\n<p>or<\/p>\n<p class=\"command\">ufw allow 80\/tcp<\/p>\n<p><strong><b> <\/b><\/strong>In case <strong><b>iptables<\/b><\/strong> raw rules are used by the system administrator to manage Firewall rules in Debian server, add the following rules to allow port 80 inbound traffic on the firewall so that visitors can browse the online application.<\/p>\n<p class=\"command\">apt-get install -y iptables-persistent<\/p>\n<p class=\"command\">iptables -I INPUT -p tcp &#8211;destination-port 80 -j ACCEPT<\/p>\n<p class=\"command\">netfilter-persistent save<\/p>\n<p class=\"command\">systemctl restart netfilter-persistent<\/p>\n<p class=\"command\">systemctl status netfilter-persistent<\/p>\n<p class=\"command\">systemctl enable netfilter-persistent.service<\/p>\n<p><strong><b> <\/b><\/strong>In case you are remotely managing your Debian server via SSH, make sure you add the below rule to allow incoming SSH connections to your machine.<\/p>\n<p class=\"command\">iptables -I INPUT -p tcp &#8211;destination-port 22 -j ACCEPT<\/p>\n<p class=\"command\">netfilter-persistent save<\/p>\n<p class=\"command\">systemctl restart netfilter-persistent<\/p>\n<p><strong><b> <\/b><\/strong>You might also need to enable and activate the following Apache modules required by the Moodle application to run properly, by issuing the below commands.<\/p>\n<p class=\"command\">a2enmod rewrite<\/p>\n<p class=\"command\">systemctl restart apache2<\/p>\n<p>Finally, test if Apache web server default web page can be displayed in your client&#8217;s browser by visiting your Debian machine IP address or your domain name or server FQDN via HTTP protocol, as shown in the below image. If you don\u2019t know your machine IP address, execute <strong><b>ifconfig<\/b><\/strong> or <strong><b>ip a<\/b><\/strong> command\u00a0to reveal the IP address of your server.<\/p>\n<p><em><strong><span>http:\/\/your_domain.tld<\/span><\/strong><\/em><\/p>\n<p><a class=\"fancybox\" id=\"img-Picture1\" href=\"https:\/\/www.howtoforge.com\/images\/install_moodle_learning_management_platform_in_debian_9\/big\/Picture1.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/07\/install-moodle-learning-management-platform-in-debian-9.png\" alt=\"Apache default page\" width=\"550\" height=\"327\" title=\"\"><\/a><\/p>\n<p>On the next step edit PHP default configuration file in order to assure that the following PHP variables are enabled and the PHP <strong><b>timezone<\/b><\/strong> setting is correctly configured and matches your system geographical location. Open <strong><b>\/etc\/php\/7.0\/apache2\/php.ini<\/b><\/strong> file for editing and assure that the following lines are set up as follows. Also, initially, make a backup of PHP configuration file.<\/p>\n<p class=\"command\">cp \/etc\/php\/7.0\/apache2\/php.ini{,.backup}<\/p>\n<p class=\"command\">nano \/etc\/php\/7.0\/apache2\/php.ini<\/p>\n<p><strong><b> <\/b><\/strong>Search, edit and change the following variables in <strong><b>php.ini<\/b><\/strong> configuration file:<\/p>\n<pre>file_uploads = On<br\/>memory_limit = 128M<br\/>post_max_size = 80M<br\/>upload_max_filesize = 80M<br\/>default_charset = UTF-8<br\/>date.timezone = Europe\/London<\/pre>\n<p>Increase <strong><b>upload_max_file_size<\/b><\/strong> variable as suitable to support large file attachments if that\u2019s the case and replace the <strong><em><b><i>date.timezone<\/i><\/b><\/em><\/strong> variable accordingly to your geographical time by consulting the list of time zones provided by PHP docs at the following link <span><a href=\"http:\/\/php.net\/manual\/en\/timezones.php\" target=\"_blank\" rel=\"noopener\"><span><span>http:\/\/php.net\/manual\/en\/timezones.php<\/span><\/span><\/a><\/span><\/p>\n<p>If you want to increase the load speed of your website pages via OPCache plugin available for PHP7, append the following OPCache settings at the bottom of the PHP interpreter configuration file, below the <strong><em><b><i>[opcache]<\/i><\/b><\/em><\/strong> statement, as detailed below:<\/p>\n<p class=\"command\">nano \/etc\/php\/7.0\/apache2\/conf.d\/10-opcache.ini<\/p>\n<pre>[opcache]<br\/>opcache.enable=1 <br\/>opcache.enable_cli=1 <br\/>opcache.interned_strings_buffer=8 <br\/>opcache.max_accelerated_files=10000 <br\/>opcache.memory_consumption=128 <br\/>opcache.save_comments=1<br\/>opcache.revalidate_freq=1<\/pre>\n<p>Close the <strong><em><b><i>php.ini<\/i><\/b><\/em><\/strong> configuration file and check if the verify the end of PHP configuration file to check if the OPCache variables had been correctly added by issuing the below command.<\/p>\n<p class=\"command\">grep opcache \/etc\/php\/7.0\/apache2\/conf.d\/10-opcache.ini<\/p>\n<p>After you\u2019ve made all changes explained above, restart Apache daemon to apply the new changes by issuing the following command.<\/p>\n<p class=\"command\">systemctl restart apache2<\/p>\n<p><strong><b> <\/b><\/strong>In order to access Moodle web interface via HTTPS protocol that will secure the traffic for your clients, issue the following command to enable Apache web server SSL module and SSL site configuration file.<\/p>\n<p class=\"command\">a2enmod ssl<\/p>\n<p class=\"command\">a2ensite default-ssl.conf<\/p>\n<p>Next, open Apache default SSL site configuration file with a text editor and enable URL rewrite rules by adding the following lines of code after <strong><em><b><i>DocumentRoot<\/i><\/b><\/em><\/strong> directive, as shown in the below sample:<\/p>\n<p class=\"command\"><em><i>nano \/etc\/apache2\/sites-enabled\/default-ssl.conf<\/i><\/em><\/p>\n<p><strong><em><b><i> <\/i><\/b><\/em><\/strong>SSL site configuration file excerpt:<\/p>\n<pre>&lt;Directory \/var\/www\/html&gt;<br\/>Options +FollowSymlinks<br\/>AllowOverride All<br\/>Require all granted<br\/>&lt;\/Directory&gt;<\/pre>\n<p>Also, make the following change to VirtualHost line to look like shown in the below excerpt:<\/p>\n<pre>&lt;VirtualHost *:443&gt;<\/pre>\n<p><strong\/>Close the SSL Apache file and open <strong><b>\/etc\/apache2\/sites-enabled\/000-default.conf<\/b><\/strong> file for editing and add the same URL rewrite rules as for SSL configuration file. Insert the lines of code after <strong><b>DocumentRoot<\/b><\/strong> statement as shown in the below example.<\/p>\n<pre>&lt;Directory \/var\/www\/html&gt;<br\/>Options +FollowSymlinks<br\/>AllowOverride All<br\/>Require all granted<br\/>&lt;\/Directory&gt;<\/pre>\n<p>Finally, restart Apache daemon to apply all rules configured so far and visit your domain via HTTP protocol. Because you\u2019re using the automatically Self-Signed certificate pairs issued by Apache at installation time, the\u00a0certificate is untrusted by the browser, an error warning should be displayed in the browser.<\/p>\n<p class=\"command\">systemctl restart apache2<\/p>\n<p><strong><em><span>https:\/\/yourdomain.tld<\/span><\/em><b> <\/b><\/strong><\/p>\n<p>Accept the warning in order to accept the untrusted certificate and continue to be redirected to Apache default web page.<\/p>\n<p>In case the UFW firewall application blocks incoming network connections to HTTPS port, you should add a new rule to allow HTTPS traffic to pass through the firewall by issuing the following command.<\/p>\n<p class=\"command\">ufw allow \u2018WWW Full\u2019<\/p>\n<p>or<\/p>\n<p class=\"command\">ufw allow 443\/tcp<\/p>\n<p>If <em><i>iptables<\/i><\/em> is the default firewall application installed to protect your Debian system at the network level, add the following rule to allow port 443 inbound traffic in the firewall so that visitors can browse your domain name.<\/p>\n<p class=\"command\">iptables -I INPUT -p tcp &#8211;destination-port 443 -j ACCEPT<\/p>\n<p class=\"command\">netfilter-persistent save<\/p>\n<p class=\"command\">systemctl restart netfilter-persistent<\/p>\n<p class=\"command\">systemctl status netfilter-persistent<\/p>\n<p><strong><b> <\/b><\/strong>Finally, to display all server PHP variables, create a PHP info file by executing the following command and check if the PHP time zone has been correctly configured by visiting the PHP info script file from a browser at the following URL, as illustrated in the below image. Scroll down to the\u00a0<strong><b>date<\/b><\/strong> setting to check PHP time zone configuration.<\/p>\n<p class=\"command\">echo &#8216;&lt;?php phpinfo(); ?&gt;&#8217;| tee \/var\/www\/html\/info.php<\/p>\n<p><span><a href=\"https:\/\/domain.tld\/info.php\" target=\"_blank\" rel=\"noopener\"><span><span\/><\/span><\/a><em><strong><a>https:\/\/domain.tld\/info.php <\/a><\/strong><\/em><\/span><\/p>\n<p><span><span><span\/><\/span><\/span>Next, before creating the database required by Moodle to store information, first we need to make some changes to MariaDB server and set up the proper character set. Open MariaDB client configuration file and add the following line after <strong><b>[client]<\/b><\/strong> directive, as illustrated in the below sample:<\/p>\n<p class=\"command\">nano \/etc\/mysql\/mariadb.conf.d\/50-client.cnf<\/p>\n<pre>[client]<br\/># Default is Latin1, if you need UTF-8 set this (also in server section)<br\/>default-character-set = utf8mb4<\/pre>\n<p>Next, open mysql.cnf file and add the same line as above after [mysql] statement:<\/p>\n<p class=\"command\">nano \/etc\/mysql\/conf.d\/mysql.cnf<\/p>\n<p>mysql.cnf file excerpt:<\/p>\n<pre>default-character-set = utf8mb4<\/pre>\n<p>Open for editing MariaDB server configuration file and add the below lines after <strong><b>[mysqld]<\/b><\/strong> statement to ensure that MySQL engine <strong><em><b><i>innodb<\/i><\/b><\/em><\/strong> uses <strong><em><b><i>Barracuda<\/i><\/b><\/em><\/strong> file format and utf8mb4 character set.<\/p>\n<p class=\"command\">nano \/etc\/mysql\/mariadb.conf.d\/50-server.cnf<\/p>\n<p>50-server.cnf file excerpt:<\/p>\n<pre readability=\"6\">[mysqld]<br\/>innodb_file_format = Barracuda<br\/>innodb_file_per_table = 1<br\/>innodb_large_prefix<p>character-set-server = utf8mb4<br\/>collation-server = utf8mb4_unicode_ci<br\/>skip-character-set-client-handshake<\/p><\/pre>\n<p>In order to apply all changes made so far to the database, restart the MySQL daemon and verify if the service is running by issuing the following commands.<\/p>\n<p class=\"command\">systemctl restart mysql<\/p>\n<p class=\"command\">systemctl status mysql<\/p>\n<p>Finally, log in to the MariaDB database console and create a database for application with a user and a password that will be used to manage the application database, by issuing the following commands. Make sure you replace the database name, user and password accordingly.<\/p>\n<p class=\"command\">mysql \u2013u root -p<\/p>\n<pre readability=\"14\">Welcome to the MariaDB monitor. Commands end with ; or \\g.<p>Your MariaDB connection id is 2<\/p><p>Server version: 10.1.26-MariaDB-0+deb9u1 Debian 9.1<\/p><p>Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.<\/p><p>Type 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.<\/p><\/pre>\n<p class=\"command\">MariaDB [(none)]&gt; CREATE DATABASE moodle_db;<\/p>\n<pre><em><i>Query OK, 1 row affected (0.00 sec)<\/i><\/em><\/pre>\n<p class=\"command\">MariaDB [(none)]&gt; grant all privileges on moodle_db.* to &#8216;moodle_user&#8217;@&#8217;localhost&#8217; identified by &#8216;password1234&#8217;;<\/p>\n<pre><em><i>Query OK, 0 rows affected (0.00 sec)<\/i><\/em><\/pre>\n<p class=\"command\">MariaDB [(none)]&gt; flush privileges;<\/p>\n<pre><em><i>Query OK, 0 rows affected (0.00 sec)<\/i><\/em><\/pre>\n<p class=\"command\"><em><i>MariaDB [(none)]&gt;<\/i><\/em> exit<\/p>\n<pre><em><i>Bye<\/i><\/em><\/pre>\n<h2 id=\"install-moodle\">Install Moodle<\/h2>\n<p>After all system requirements are met to install the Moodle CMS application, visit Moodle official download page at <span><a href=\"https:\/\/download.moodle.org\/releases\/latest\/\" target=\"_blank\" rel=\"noopener\"><span><span>https:\/\/download.moodle.org\/releases\/latest\/<\/span><\/span><\/a><\/span> and grab the latest zip compressed archive in your system by issuing the below command.<\/p>\n<p class=\"command\">wget <span>https:\/\/download.moodle.org\/download.php\/direct\/stable34\/moodle-latest-34.zip<\/span><\/p>\n<p>After the zip archive download finishes, extract Moodle zip archive file to your current working directory and list the extracted files by issuing the below commands. Also, remove the default index.html file installed by Apache web server to webroot path and also delete the info.php file created earlier.<\/p>\n<p class=\"command\">unzip moodle-latest-34.zip<\/p>\n<p class=\"command\">ls<\/p>\n<p class=\"command\">rm \/var\/www\/html\/index.html<\/p>\n<p class=\"command\">rm \/var\/www\/html\/info.php<\/p>\n<p>Then, copy all the content of Moodle extracted directory to your web server document root path by issuing the following command. Also, make sure you copy the following hidden dot files to webroot path.<\/p>\n<p class=\"command\">cp -rf moodle\/* \/var\/www\/html\/<\/p>\n<p class=\"command\">cp -rf moodle\/.eslint* \/var\/www\/html\/<\/p>\n<p class=\"command\">cp -rf moodle\/.gherkin-lintrc \/var\/www\/html\/<\/p>\n<p class=\"command\">cp -rf moodle\/.jshintrc \/var\/www\/html\/<\/p>\n<p class=\"command\">cp -rf moodle\/.s* \/var\/www\/html\/<\/p>\n<p class=\"command\">cp -rf moodle\/.travis.yml \/var\/www\/html\/<\/p>\n<p>Next, create the data directory for Moodle one level up to your server document root and execute the below commands in order to grant Apache runtime user with full write permissions to the web root path and moodle data directory. Use <strong><b>ls<\/b><\/strong> command to list permissions for application\u2019s installed files, located in \/var\/www\/html\/ directory.<\/p>\n<p class=\"command\">mkdir \/var\/www\/moodledata<\/p>\n<p class=\"command\">chown -R www-data:www-data \/var\/www\/moodledata\/<\/p>\n<p class=\"command\">chown -R www-data:www-data \/var\/www\/html\/<\/p>\n<p class=\"command\">ls -al \/var\/www\/html\/<\/p>\n<p>Now let\u2019s start installing Moodle CMS via the web interface installer. Open a browser and navigate to your server IP address or domain name via HTTPS protocol. On the first installation screen, choose the installation language and press on Next button to continue.<\/p>\n<p><a class=\"fancybox\" id=\"img-Picture2\" href=\"https:\/\/www.howtoforge.com\/images\/install_moodle_learning_management_platform_in_debian_9\/big\/Picture2.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/07\/install-moodle-learning-management-platform-in-debian-9-1.png\" alt=\"Moodle installation\" width=\"550\" height=\"380\" title=\"\"><\/a><\/p>\n<p>On the next screen, the installer will ask you to confirm the web server address, the moodle directory path and moodle data directory path. Leave the first two paths variables as default and add <strong><b>\/var\/www\/moodledata<\/b><\/strong> for Moodle Data directory path, as illustrated in the below image. Hit on Next button to continue.<\/p>\n<p><a class=\"fancybox\" id=\"img-Picture3\" href=\"https:\/\/www.howtoforge.com\/images\/install_moodle_learning_management_platform_in_debian_9\/big\/Picture3.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/07\/install-moodle-learning-management-platform-in-debian-9-2.png\" alt=\"Confirm paths\" width=\"510\" height=\"550\" title=\"\"><\/a><\/p>\n<p>On the next screen, select MariaDB (native\/madiadb) as database driver and hit on Next button to continue the installation process.<\/p>\n<p><a class=\"fancybox\" id=\"img-Picture4\" href=\"https:\/\/www.howtoforge.com\/images\/install_moodle_learning_management_platform_in_debian_9\/big\/Picture4.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/07\/install-moodle-learning-management-platform-in-debian-9-3.png\" alt=\"Choose database driver\" width=\"550\" height=\"343\" title=\"\"><\/a><\/p>\n<p>Next, add you Database settings, such as database host, name, user, and password. Use the database name and credentials configured earlier for the Moodle database.<\/p>\n<p>Database host should be set to localhost. Add your own database table prefix, use 3306 as database port and hit on Next button to complete this step and continue the installation process.<\/p>\n<p><a class=\"fancybox\" id=\"img-Picture5\" href=\"https:\/\/www.howtoforge.com\/images\/install_moodle_learning_management_platform_in_debian_9\/big\/Picture5.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/07\/install-moodle-learning-management-platform-in-debian-9-4.png\" alt=\"Database settings\" width=\"512\" height=\"550\" title=\"\"><\/a><\/p>\n<p>On the next screen, read Moodle license terms and conditions and hit on Continue button to confirm the license terms.<\/p>\n<p><a class=\"fancybox\" id=\"img-Picture6\" href=\"https:\/\/www.howtoforge.com\/images\/install_moodle_learning_management_platform_in_debian_9\/big\/Picture6.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/07\/install-moodle-learning-management-platform-in-debian-9-5.png\" alt=\"Start installation\" width=\"523\" height=\"550\" title=\"\"><\/a><\/p>\n<p>Next, the Moodle installation script will perform a series of server checks in order to determine if all requirements are meet for continuing the installation process. Check if all database and PHP extensions are set to OK, scroll down to the bottom of the page and hit on Continue button to move forward with the installation process.<\/p>\n<p><a class=\"fancybox\" id=\"img-Picture7\" href=\"https:\/\/www.howtoforge.com\/images\/install_moodle_learning_management_platform_in_debian_9\/big\/Picture7.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/07\/install-moodle-learning-management-platform-in-debian-9-6.png\" alt=\"Server requirement check\" width=\"516\" height=\"550\" title=\"\"><\/a><\/p>\n<p>Next, wait while the installer finishes installing a series of modules and hit on Continue button again to move to the next step.<\/p>\n<p><a class=\"fancybox\" id=\"img-Picture8\" href=\"https:\/\/www.howtoforge.com\/images\/install_moodle_learning_management_platform_in_debian_9\/big\/Picture8.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/07\/install-moodle-learning-management-platform-in-debian-9-7.png\" alt=\"Installing modules\" width=\"550\" height=\"508\" title=\"\"><\/a><\/p>\n<p>In the next step, add a Moodle administrator account, choose a strong password for this account and fill all account information, such as First name, Surname, email, City, Country, Timezone, and description. When you finish hit on Update profile button to save admin account information.<\/p>\n<p><a class=\"fancybox\" id=\"img-Picture9\" href=\"https:\/\/www.howtoforge.com\/images\/install_moodle_learning_management_platform_in_debian_9\/big\/Picture9.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/07\/install-moodle-learning-management-platform-in-debian-9-8.png\" alt=\"Setup the Moodle details like timezone etc.\" width=\"527\" height=\"550\" title=\"\"><\/a><\/p>\n<p>Next, set up the full site name, add a short site name and a front page summary, scroll down and hit in Save changes button to complete the installation process.<\/p>\n<p><a class=\"fancybox\" id=\"img-Picture10\" href=\"https:\/\/www.howtoforge.com\/images\/install_moodle_learning_management_platform_in_debian_9\/big\/Picture10.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/07\/install-moodle-learning-management-platform-in-debian-9-9.png\" alt=\"Front page settings\" width=\"546\" height=\"550\" title=\"\"><\/a><\/p>\n<p>After completing the installation process, you will be redirected to the Moodle administration dashboard. Here you can use the registration form to register the application with Moodle.net portal.<\/p>\n<p><a class=\"fancybox\" id=\"img-Picture111\" href=\"https:\/\/www.howtoforge.com\/images\/install_moodle_learning_management_platform_in_debian_9\/big\/Picture111.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/07\/install-moodle-learning-management-platform-in-debian-9-10.png\" alt=\"Moodle admin dashboard\" width=\"550\" height=\"404\" title=\"\"><\/a><\/p>\n<p>In order to access Moodle frontend page, open a browser and navigate to your server IP address or domain name via HTTPS protocol.<\/p>\n<p><a class=\"fancybox\" id=\"img-Picture12\" href=\"https:\/\/www.howtoforge.com\/images\/install_moodle_learning_management_platform_in_debian_9\/big\/Picture12.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/07\/install-moodle-learning-management-platform-in-debian-9-11.png\" alt=\"Moodle Frontend\" width=\"550\" height=\"547\" title=\"\"><\/a><\/p>\n<p>Finally, return to Debian server console and create a <em><i>.htaccess<\/i><\/em> file that will be located in your website document root path, by issuing the below command.<\/p>\n<p class=\"command\">nano \/var\/www\/html\/.htaccess<\/p>\n<p>In .htaccess file, add the below lines so that you can manipulate the native PHP server settings to match your own server resources and configurations.<\/p>\n<p><strong><b> <\/b><\/strong><strong><b>.htaccess<\/b><\/strong> file excerpt:<\/p>\n<p><strong><em><b><i> <\/i><\/b><\/em><\/strong># Modify PHP settings<\/p>\n<pre>php_value register_globals 1<br\/>php_value upload_max_filesize 100M<br\/>php_value post_max_size 100M<br\/>Options -Indexes<\/pre>\n<p><strong><b>Install cron<\/b><\/strong><\/p>\n<p>In order to periodically run the Moodle maintenance script that sends out emails, cleans up the database, updates feeds or other tasks, add the below cron job to run every 10 minutes, by issuing the below command.<\/p>\n<p class=\"command\">crontab -u www-data -e<\/p>\n<p>Add the following line and save the cronjob.<\/p>\n<pre>*\/10 * * * * \/usr\/bin\/php7.0 \/var\/www\/html\/admin\/cli\/cron.php &gt;\/dev\/null<\/pre>\n<p>Congratulations! You have successfully installed and configured Moodle CMS in Debian 9 server. Moodle documentation page can be found at the following address: <span><a href=\"https:\/\/docs.moodle.org\/23\/en\/Main_page\" target=\"_blank\" rel=\"noopener\"><span><span>https:\/\/docs.moodle.org\/23\/en\/Main_page<\/span><\/span><\/a><\/span><\/p>\n<div>\n<p><b>Share this page:<\/b><\/p>\n<p>\n<a href=\"https:\/\/www.facebook.com\/sharer.php?u=https%3A%2F%2Fwww.howtoforge.com%2Ftutorial%2Fdebian-moodle-e-learning-platform%2F\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/07\/install-moodle-learning-management-platform-in-debian-9-12.png\" height=\"20\" alt=\"\" title=\"\"><\/a><br \/>\n<a href=\"https:\/\/twitter.com\/intent\/tweet?url=https%3A%2F%2Fwww.howtoforge.com%2Ftutorial%2Fdebian-moodle-e-learning-platform%2F&amp;text=Install+Moodle+eLearning+Platform+on+Debian+9&amp;via=howtoforgecom&amp;related=howtoforgecom\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/07\/install-moodle-learning-management-platform-in-debian-9-13.png\" height=\"20\" alt=\"\" title=\"\"><\/a><br \/>\n<a href=\"https:\/\/twitter.com\/howtoforgecom\/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/07\/install-moodle-learning-management-platform-in-debian-9-14.png\" height=\"20\" alt=\"\" title=\"\"><\/a><br \/>\n<a href=\"https:\/\/plus.google.com\/share?url=https%3A%2F%2Fwww.howtoforge.com%2Ftutorial%2Fdebian-moodle-e-learning-platform%2F\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/07\/install-moodle-learning-management-platform-in-debian-9-15.png\" height=\"20\" alt=\"\" title=\"\"><\/a>\n<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Moodle is a flexible and powerful free open source course management system and e-learning platform written in PHP and often deployed in Linux under Apache\/Nginx web servers with PHP and MySQL\/MariaDB database management system, also known as LAMP or LEMP stack. This tutorial will explain how to install and configure the latest version of Moodle &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[36],"tags":[],"class_list":["post-5821","post","type-post","status-publish","format-standard","hentry","category-36"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/5821","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/comments?post=5821"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/5821\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=5821"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=5821"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=5821"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}