course header 2000x350

In our previous article, we used the Hestia File Manager to install Moodle into our root public_html folder and to install the moodle data folder into the Hestia private folder. In this article, we will use the Moodle installer to complete the installation process.

Step 1 Open a New Web Browser and enter your Domain Name

We will still be using our Hestia Control Panel. So we need to keep a separate web browser open to keep us logged into our Hestia User account. But we also need a browser where we can clear the browser cache. So we will open a new browser and clear the cache. Then type in our domain name. The first Moodle Installation screen is called Language. Use the drop down to change the language to English US.

01

Then click Next.

Step 2 Set the correct path for the Moodle Data Folder
The next screen is called Confirm Paths. Change the Moodle Data path to add the private folder to the path:

/home/course0/web/localdevtest.com/private/moodledata

Then click Next.

Step 3: Change the Database Driver to Maria DB
The next screen is Choose Database driver. The default is mysqli. Use the drop down to change this to MariaDB.

02

Then click Next.

Step 4: Enter your Database Name, User Name and Password
The next screen is to set Database Connection information.

03

Replace the database name moodle with the actual database name. Then type your Hestia created database username and password. Note that the password has a capital letter. Then click Next. The next screen is the Copyright screen. Click Continue.

Step 5: Fix the Errors on the Server Check screen
The Server check screen has one error at the top of the screen:

04

Error 1: The XMLRPC extension is not installed

Scroll down the page to see two more errors:

05

Error 2: The current setup of MySQL or MariaDB is using 'utf8'. This character set does not support four byte characters which include some emoji. Trying to use these characters will result in an error when updating a record, and any information being sent to the database will be lost. Change your settings to 'utf8mb4'.

Error 3: PHP setting max_input_vars is recommended to be at least 5000.

Fix Errors 1 and 3 (which are both php errors)
Sadly, the command given by the Moodle documentation is wrong. We need to add the php version. So the correct command is

apt-get install php7.4-xmlrpc

XMLRPC is a program that allows remote updates to Moodle. It is disabled by default because in the past it was a security risk. Note that php-xmlrpc typically can not be used on a shared hosting account. You need to have either a real server or a virtual private server (vps). To install this program, open the terminal on your home computer and start an SSH session. then copy paste this command:

apt-get install php7.4-xmlrpc

Next we need to change the php.ini file. We can not change this file in Hestia File Manager. The change seems to be done. But reopen the file and it was not done. We therefore need to use an SSH session and change the file with Midnight Commander. Go to the root folder. Then open the etc folder. Then the php folder. Then open the 7.4 folder. Then php-fpm folder then php.ini. Press Alt plus c to show the page numbers. Then scroll down to line 405 and delete the semi-colon. Then change

max_input_vars = 1000 to max_input_vars = 5000

Then scroll down to line 948 and delete the semi-colon in front of extension=xmlrpc.

Then click Save. Once it is installed we need to enable it. Go to your Hestia User Panel and click Exit to Control Panel. Then click Log out. Then log into the Hestia Admin panel and click Settings. Then scroll down to php-fpm which is the backend server and select it. Then click Restart.

Check that PHP-XMLRPC is working
To check if php-xmlrpc is enabled, in the Hestia User Panel File Manager, public_html folder, click New and add a new file called info.php Then open the file to edit it. Copy and paste:

<?php

echo 'XMLRPC is ', extension_loaded('xmlrpc') ? 'loaded' : 'not loaded';

?>

Then open a browser and type your domain name followed by a forward slash and then info.php:

06

You should see “XMLRPC is loaded” which confirms that XMLRPC is installed and enabled. Then go back to the installation browser and refresh the page. There is now only one error left:

07

Challenges in Fixing the Final Installation Check Error
The yellow text claims that the current setup of MySQL or MariaDB is using 'utf8'. This character set does not support four byte characters which include some emoji. Trying to use these characters will result in an error when updating a record, and any information being sent to the database will be lost. The yellow text claims that we need to change our database character settings to 'utf8mb4'. However, log into your moodle database and it showed that it is set for utfmb4:

08

Log out of database.

Use the MySQL collation conversion tool.
This tool is a command line script that helps to add the proper settings to our database. The script strongly recommends we stop the web server before the conversion. So go to the Hestia Admin Panel, settings and turn off Apache, Nginx and PHP-FPM. Then start an SSH session. The Moodle installation instructions recommended using this command to fix the problem:

php admin/cli/mysql_collation.php –collation=utf8mb4_unicode_ci

However, the path is wrong. The word admin refers to the moodle admin folder. So we need to add the full path to the moodle admin folder which is in our public_html. Here is the correct command with the correct path to copy and paste into our terminal after starting the SSH session:

php /home/course0/web/localdevtest.com/public_html/admin/cli/mysql_collation.php --collation=utf8mb4_unicode_ci

returned: Converting database to 'utf8mb4_unicode_ci' for https://localdevtest.com: DATABASE CONVERTED

Converting tables and columns to 'utf8mb4_unicode_ci' for https://localdevtest.com: Converted: 0, skipped: 0, errors: 0

Now go back to the Hestia Admin panel and click Settings and start the servers again and also restart the database. Then open the installation browser tab again, clear the cache and reload the installation page. The error is still there. However, because we have the correct character set, we will ignore the final error and continue the installation. Click Continue. This error screen may appear:

09

To clear this error, restart the server from your Hestia Admin Panel. This brings up the next Installation screen.

Step 6: Plugins Check

Next is the Plugins check page

09a

Scroll to the bottom and click Upgrade Moodle database now. Wait a few minutes for the update to finish. Then click Continue.

Step 7: Add the Primary Administrator Details

The next screen has the Primary Administrator details.

10

Make sure you give it a secure username and password as well as a valid email address. You can create more admin accounts later on. For username, only lower case letters are allowed. Change the username to something other than admin.

Then scroll down the page to fill out these boxes:

11

Then fill out these boxes:

12

Then click Update Profile.

Step 8 Add the Website Details
The next screen adds the website details.

13

Then fill out the location:

14

Then click Save Changes.

Step 9 View your new Moodle Website!

15r


Click on the Dashboard to see the back end of your site. Then click on Site Home to see the front end of your Moodle site.

16r

To log out, click on the down arrow near your name. Here is the Home page after logging out:

17r

 Congratulations. You have installed a Moodle Website on a Hestia VPS.

Final Configuration Tasks
There are several tasks you will want to configure before going live. Some are listed below.

Add Moodle Cron Jobs
Moodle requires periodic updates to several functions. Moodle's background tasks (e.g. sending out forum emails and performing course backups) are performed by a script which you can set to run at periodic intervals. This is known as a cron job. Do not skip setting up the cron process on your server for your Moodle. Your site will not work properly without it! Thankfully, Hestia makes it easy to add Cron Jobs. For more information on setting Cron jobs with Hestia, see this article:

https://createyourownvps.com/final-steps/8-firewalls-backups-and-appearance/8-3-use-hestia-to-run-a-cron-job

Note that the command for the Moodle cron job in Hestia is slightly different than the command shown in the Moodle Cron Job documentation. Specifically, you need to use php7.4 rather than just php. Thus, the command is

/usr/bin/php7.4 /path/to/moodle/admin/cli/cron.php

Note that there is an empty space after 7.4 and before the forward slash in front of the word path. In the future, the php version may change. To see the PHP version used by your installation of Hestia CP, log into the admin panel and click on Files. Then go to the /usr/bin folder and scroll down to php:

18

Note that the php7.4 file size is much bigger than the php file size. This is your clue that you need to use the php7.4 file and not just the php file in the Moodle cron command.

To make the actual Moodle cron job, log out of the Hestia admin panel and into your Hestia user panel. In the Hestia User Panel, click Cron. There are no current Cron Jobs for this user. Click Add Job. Copy paste the command into the top box.

/usr/bin/php7.4 /home/course0/web/collegeintheclouds.com/public_html/admin/cli/cron.php

Then use the drop down arrow to select every 10 minutes. Then click the Generate button to generate the proper time code.

cron 10m

Then click Save and Back.

cron2 10m


Then wait one hour and log into your Hestia User email account. If you see one or more emails with the Moodle Cron Job command ending with "Cron script completed correctly", you know that you have properly set up your Moodle Cron and that the command is working.

Stop Moodle Cron Jobs from Sending your emails every 30 minutes
Now that we know the command is working, we need to change the command so that the Moodle cron job does not fill up our email in box. Go back to your Hestia User panel and click Cron Jobs. Then select the Moodle cron job to edit it. Change the command to add an empty space at the end and then copy paste >/dev/null

Here is my command with the full path:

/usr/bin/php7.4 /home/course0/web/collegeintheclouds.com/public_html/admin/cli/cron.php >/dev/null

Then click Save and Back. Adding >/dev/null should stop you getting an email every time the Moodle cron job runs (every 30 minutes). To check this, open your email account and verify that the Moodle cron job emails have been stopped.

Check to make your sure your Moodle Email System works
Both Hestia and Moodle have steps that need to be taken to set up an email system. For the Hestia process, see this page:

https://createyourownvps.com/final-steps/7-email-security/7-1-overview-of-the-hestia-email-system

For the Moodle process, log into your Moodle site and send a test email. Click Site administrator, Server, Outgoing mail configuration. Scroll down to “Test outgoing mail configuration” and click on the blue text.

22

Enter your email address and click Send a test message. Then log into your protonmail account and see if you got the test message.

24

If you did not receive an email copy of the message, check the settings in Settings > Site administration > Plugins > Message outputs > Email. Don't skip this step as Moodle uses email to recover lost passwords.

Increase the Maximum Moodle Upload Size
We need to increase the maximum file size upload limit in order to install some later extensions. To see the current limit, go to Site Administrator > Security -> Site Policies now known as Site Security Settings. Scroll down to "Maximum Uploaded File Size". The default maximum is 2 MB. Teachers may also set the maximum file size by the course administration block.

To increase the Maximum Upload File Size, you need to change your php.ini file. Go to Moodle Site administration > Server > PHP Info and look a few lines down you will find the php.ini location that your Moodle PHP installation is using.

25

Then open an SSH session and start Midnight Commander.

ssh This email address is being protected from spambots. You need JavaScript enabled to view it.

Open the /etc/php/7.4/fpm folder and open the php.ini file. Press Alt plus c to display the line numbers. Then use the down arrow to scroll down to the Data Handling section, line 694

Change pos_max_size = from 8 MB to 128MB.

Then scroll down to the File Upload section, line 846 and change upload_max_filesize = from 2 MB to 64MB.

Then save and close the file. Then click File Exit to exit Midnight Commander and type exit to exit the SSH session. Then go to Hestia Admin Panel, settings and restart the back end web server called php7.4-fpm for these changes to take effect.

Then in your Moodle Admin area, reload the phpinfo.php page and scroll down to confirm that the Upload Max File Size has been increased to 64 MB. This will also be updated in the other Moodle admin screens.

Turn off Guest Login.
By default, Moodle allows the public to log into your Moodle website and look at your courses. If this is OK with you, then leave guest log in enabled. However, if you do not want to allow guest log in, then go to Site administration and click the plugins tab. Then click authentication/ manage authentication. Then scroll down to Guest login button and change the setting from Show to Hide. Then click Save Changes.

Temporarily turn off Moodle and Hestia Backups
Both Hestia and Moodle have programs to back up your Moodle website. For the Hestia process, see this page: https://createyourownvps.com/final-steps/8-firewalls-backups-and-appearance/8-2-use-hestia-to-set-up-a-vps-backup-system

For the Moodle process, see these pages:

 Site backup and Automated course backup.

Note that you should avoid setting up your Moodle and Hestia backups until after configuring your course structure in order to avoid overwhelming your moodledata folder. To turn off Hestia backups, log in to the Hestia admin page and click on users. Then copy the default package and change the number of backups for the default-copy package from 1 to 0. Then assign the admin user and the new moodle user to the default-copy package.

How to Solve Installation Problems
If you run into problems installing Moodle, you are not alone. The first place to ask questions is at the Moodle Installation forum.

https://moodle.org/mod/forum/view.php?id=28

There are 189 pages of questions on how to install Moodle. Each page has 100 questions. So nearly 19,000 people have asked questions just about the Moodle Installation process. Read the most recent 10 pages as it is likely that others have already had the same problem you are having.

When you ask a question on the Moodle forum, always list your software versions including what version of Moodle you are installing. Then explain what you did, what happened and what error messages you saw. Also explain any steps you took to try to fix the problem before posting your question on their forum.

You can also ask a question on the Hestia forum. However, be aware that most Hestia administrators have not used Moodle and thus may be unable to answer your Moodle installation questions.

What’s Next?

This is just the beginning. In the next chapter, we will review how to set up the initial Courses and Users structure of your Moodle website.