{"id":5876,"date":"2021-04-22T16:15:14","date_gmt":"2021-04-22T16:15:14","guid":{"rendered":"https:\/\/linuxways.net\/?p=5876"},"modified":"2021-04-22T16:15:14","modified_gmt":"2021-04-22T16:15:14","slug":"how-to-install-moodle-on-red-hat-enterprise-linux-8","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/red-hat\/how-to-install-moodle-on-red-hat-enterprise-linux-8\/","title":{"rendered":"How to Install Moodle on Red Hat Enterprise Linux 8"},"content":{"rendered":"<p>Moodle is an open-source digital learning solution for creating dynamic teaching and learning environments. Moodle is written in PHP, and it powers numerous learning platforms worldwide. You can download and install the Moodle software on your own web server, or let a <a href=\"https:\/\/moodle.com\/partners\">Moodle Partner<\/a> handle the hosting and implementation for you.<\/p>\n<p>This tutorial focuses on how to download and install Moodle on your own Apache web server running on Red Hat Enterprise Linux 8 (RHEL 8).<\/p>\n<h2>Prerequisites<\/h2>\n<ul>\n<li>The <a href=\"https:\/\/linuxways.net\/de\/red-hat\/install-lamp-stack-on-red-hat-enterprise-linux-8\/\">LAMP stack<\/a> installed on RHEL 8<\/li>\n<li>A user with sudo privileges<\/li>\n<\/ul>\n<h2>Prepare Apache for Moodle<\/h2>\n<p>If you would like to use Moodle with your own registered domain name, then it is recommended to create a virtual host on Apache as follows.<\/p>\n<p>Open the Apache main configuration file.<\/p>\n<pre><strong>$<\/strong> sudo nano \/etc\/httpd\/conf\/httpd.conf<\/pre>\n<p>Scroll down to the bottom of the file and then append the following configuration directives.<\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<pre># Virtual Hosts\r\n\r\n&lt;VirtualHost *:80&gt;\r\n\r\nDocumentRoot \"\/var\/www\/linuxways.net\/\"\r\n\r\nServerName linuxways.net\r\n\r\nCustomLog \/var\/log\/httpd\/linuxways.net_access.log combined\r\n\r\nErrorLog \/var\/log\/httpd\/linuxways.net_error.log\r\n\r\n&lt;\/VirtualHost&gt;<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>Note:<\/strong> Replace <strong>linuxways<\/strong> with your own domain name. Also, ensure that the DNS A record for your domain is pointing to the IP address of your Apache web server.<\/p>\n<p>Save changes and close the httpd.conf file.<\/p>\n<p>Next, run the following command to create the DocumentRoot directory where your Moodle website content will be stored.<\/p>\n<pre>$ sudo mkdir \/var\/www\/linuxways.net<\/pre>\n<h2>Prepare PHP for Moodle<\/h2>\n<p>Moodle requires some PHP extensions without which the installation will not complete.<\/p>\n<pre><strong>$<\/strong> sudo dnf install php-json php-xml php-mysqlnd php-mbstring php-zip php-gd php-intl<\/pre>\n<h2>Download Moodle<\/h2>\n<p>As of this posting, Moodle 3.10.3+ is the latest version available on the official download page.<\/p>\n<pre><strong>$<\/strong> sudo wget <a href=\"https:\/\/download.moodle.org\/download.php\/direct\/stable310\/moodle-latest-310.tgz\">https:\/\/download.moodle.org\/download.php\/direct\/stable310\/moodle-latest-310.tgz<\/a><\/pre>\n<p>Run the next command to extract the downloaded Moodle archive and place the contents in your website\u2019s document root. Do remember to replace linuxways.net accordingly.<\/p>\n<pre><strong>$<\/strong> sudo tar -xvf moodle-latest-310.tgz -C \/var\/www\/linuxways.net<\/pre>\n<p>You should now have a folder named <strong>moodle<\/strong> under the \/var\/www\/yourdomain directory.<\/p>\n<p>Now, you need to change the ownership of the Moodle DocumentRoot directory to the default Apache service account. For instance:.<\/p>\n<pre>$ sudo chown -R apache:apache \/var\/www\/linuxways.net<\/pre>\n<p>Further, change the permissions on the Moodle DocumentRoot directory.<\/p>\n<pre>$ sudo chmod -R 755 \/var\/www\/linuxways.net<\/pre>\n<p>Next, Moodle needs a data directory for storing files that are uploaded by users. This directory should not be accessible to the public.<\/p>\n<pre>$ sudo mkdir \/var\/moodledata<\/pre>\n<p>Change ownership of the Moodle data directory to the default Apache service account as follows.<\/p>\n<pre>$ sudo chown -R apache:apache \/var\/moodledata<\/pre>\n<p>Also, change the permissions on the Moodle data directory as follows.<\/p>\n<pre>$ sudo chmod -R 755 \/var\/moodledata<\/pre>\n<h2>Prepare MariaDB for Moodle<\/h2>\n<p>Moodle requires a database for storing application data such as user details, site information, course details, etc.<\/p>\n<p>Login to MariaDB with the command below.<\/p>\n<pre>$ sudo mysql -u root -p<\/pre>\n<p>Once logged in, you should see the <strong>MariaDB [(none)]&gt; <\/strong>prompt.<\/p>\n<p>Now, create a database for Moodle as follows.<\/p>\n<pre><strong>MariaDB [(none)]&gt;<\/strong> CREATE DATABASE moodle;<\/pre>\n<p>Next, create a database user. Replace <strong>moodleuser<\/strong> and <strong>moodlepass<\/strong> accordingly.<\/p>\n<pre><strong>MariaDB [(none)]&gt; <\/strong>CREATE USER 'moodledb'@'localhost' IDENTIFIED BY 'moodlepass';<\/pre>\n<p>After that, run the query below to grant all privileges on the moodle database to moodleuser.<\/p>\n<pre><strong>MariaDB [(none)]&gt; <\/strong>GRANT ALL PRIVILEGES ON moodle.* TO 'moodledb'@'localhost';<\/pre>\n<p>Update the grant tables to save your changes.<\/p>\n<pre><strong>MariaDB [(none)]&gt; <\/strong>FLUSH PRIVILEGES;<\/pre>\n<p>Quit MariaDB.<\/p>\n<pre><strong>MariaDB [(none)]&gt; <\/strong>QUIT;<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-5877 size-full\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/Prepare-MariaDB-Moodle.jpg\" alt=\"Prepare MariaDB for Moodle\" width=\"607\" height=\"214\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/Prepare-MariaDB-Moodle.jpg 607w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/Prepare-MariaDB-Moodle-300x106.jpg 300w\" sizes=\"auto, (max-width: 607px) 100vw, 607px\" \/><\/p>\n<h2>Configure Moodle<\/h2>\n<p>First, change into the previously extracted <strong>moodle<\/strong> folder. For example:<\/p>\n<pre><strong>$<\/strong> cd \/var\/www\/linuxways.net\/moodle<\/pre>\n<p>And then create the main Moodle configuration file (config.php) from the sample configuration file (config-dist.php) as follows.<\/p>\n<pre><strong>$<\/strong> sudo cp config-dist.php config.php<\/pre>\n<p>Edit the config.php Moodle configuration file.<\/p>\n<pre><strong>$<\/strong> sudo nano config.php<\/pre>\n<p>In the Moodle configuration file, locate the <strong>DATABASE SETUP<\/strong> section, and change the default values for <strong>dbtype<\/strong>, <strong>dbname<\/strong>, <strong>dbuser<\/strong>, and <strong>dbpass<\/strong>. The image below shows what this section should look like after making the necessary changes.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-5878 size-full\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/Configure-Moodle.jpg\" alt=\"Configure Moodle\" width=\"609\" height=\"195\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/Configure-Moodle.jpg 609w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/Configure-Moodle-300x96.jpg 300w\" sizes=\"auto, (max-width: 609px) 100vw, 609px\" \/><\/p>\n<p>Scroll down until you see <strong>WEB SITE LOCATION<\/strong>. Change \u2018<a href=\"http:\/\/example.com\/moodle\">http:\/\/example.com\/moodle<\/a>\u2019 to \u2018<a href=\"http:\/\/yoursite.com\/moodle\">http:\/\/yoursite.com\/moodle<\/a>\u2019 accordingly. This is where users will go to access your Moodle website.<\/p>\n<p>Scroll down further until you see <strong>DATA FILES<\/strong>. Change \u2018\/home\/example\/moodledata\u2019 to the moodle data directory path which you created earlier. That is, \u2018\/var\/moodledata\u2019<\/p>\n<p>Save changes and close the Moodle configuration file.<\/p>\n<h2>Install Moodle<\/h2>\n<p>Open a web browser and go <strong>yourdomain.com\/moodle\/admin<\/strong> to complete the installation of Moodle. In my case, going to linuxways.net\/moodle\/admin takes me to the Moodle installation page shown in the image below.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-5879 size-full\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/Install-Moodle.jpg\" alt=\"Install Moodle\" width=\"605\" height=\"515\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/Install-Moodle.jpg 605w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/Install-Moodle-300x255.jpg 300w\" sizes=\"auto, (max-width: 605px) 100vw, 605px\" \/><\/p>\n<p>Click <strong>Continue<\/strong> to proceed. On the next page, server checks might report some missing PHP extensions. As long as nothing is highlighted in red here, you are good to go. Otherwise, read the instructions next to any required extensions which are highlighted in red to resolve the issues.<\/p>\n<p>As shown in the image below, nothing is highlighted in red in my case. Also, at the bottom of the page, there is a message indicating that my server meets all requirements, and I can therefore click <strong>Continue<\/strong> to proceed.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-5880 size-full\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/Install-Moodle-.jpg\" alt=\"Install Moodle\" width=\"575\" height=\"379\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/Install-Moodle-.jpg 575w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/Install-Moodle--300x198.jpg 300w\" sizes=\"auto, (max-width: 575px) 100vw, 575px\" \/><\/p>\n<p>After you click <strong>Continue<\/strong>, wait for the Moodle installation to complete. You would see a series of success messages as the installation progresses. Do not leave the installation page. Once done, click <strong>Continue<\/strong> at the bottom of the page.<\/p>\n<p>On the next page, you would be required to create your main Moodle admin account. Provide the required information and click <strong>Update Profile<\/strong>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-5881 size-full\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/Moodle-Installation.jpg\" alt=\"Moodle Installation\" width=\"613\" height=\"505\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/Moodle-Installation.jpg 613w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/Moodle-Installation-300x247.jpg 300w\" sizes=\"auto, (max-width: 613px) 100vw, 613px\" \/><\/p>\n<p>Follow the instructions on the next page to configure your site name, front page summary, etc.<\/p>\n<p>After completing the installation process, users can visit yourdomain.com\/moodle in a web browser to access your Moodle website.<\/p>\n<p>Here is what my new Moodle website looks like.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-5882 size-full\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/Installing-Moodle.jpg\" alt=\"Installing Moodle\" width=\"648\" height=\"358\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/Installing-Moodle.jpg 648w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/Installing-Moodle-300x166.jpg 300w\" sizes=\"auto, (max-width: 648px) 100vw, 648px\" \/><\/p>\n<h2>Conclusion<\/h2>\n<p>In this tutorial, we have successfully downloaded, configured, and installed Moodle powered by the LAMP stack on RHEL 8. If you encounter any issues following this guide, do let us know.<\/p>","protected":false},"excerpt":{"rendered":"<p>Moodle is an open-source digital learning solution for creating dynamic teaching and learning environments. Moodle is written in PHP, and it powers numerous learning platforms worldwide. You can&hellip;<\/p>","protected":false},"author":1,"featured_media":5956,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[165],"tags":[285,198],"class_list":["post-5876","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-red-hat","tag-moodle","tag-red-hat-enterprise-linux-8"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/5876","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=5876"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/5876\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/5956"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=5876"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=5876"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=5876"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}