Bobcares

Moodle DigitalOcean | Basic Setup Guide

by | Oct 1, 2022

Let’s take a closer look at installing and configuring Moodle on DigitalOcean servers. Bobcares, as a part of our DigitalOcean Managed Service offers solutions to every query that comes our way.

Installing Moodle On DigitalOcean Servers

Moodle is a popular web-based learning management system that is open source (LMS). Moodle also allows for the control of user roles, allowing various users to have varying levels of access to resources. Anyone with access to the site can develop and participate in browser-based learning when we install Moodle on our DigitalOcean server.

In this article, we will provide you with the steps to setup Moodle on a DigitalOcean Ubuntu 16.04 server.

Prerequisites: A 1GB Ubuntu 16.04 server with a minimum of 200MB of disk space for the Moodle code, a non-root user with sudo privileges & a firewall and the LAMP stack (Apache, MySQL, and PHP) installed

  1. Firstly, ensure we have the latest list of packages using the code:
    sudo apt-get update
  2. Now install Moodle’s dependencies:
    sudo apt-get install aspell graphviz php7.0-curl php7.0-gd php7.0-intl php7.0-ldap php7.0-mysql php7.0-pspell php7.0-xml php7.0-xmlrpc php7.0-zip
  3. Restart the Apache web server to load the modules:
    sudo systemctl restart apache2
  4. Now download and install Moodle using curl command:
    curl -L https://download.moodle.org/download.php/direct/stable32/moodle-latest-32.tgz > moodle.tgz
  5. Then uncompress the file with the tar program and place the resulting files in the web document root:
    sudo tar -xvzf moodle.tgz -C /var/www/html
  6. Confirm the Moodle directory is in the server’s web root directory:
    ls /var/www/html
  7. We can see the Moodle directory listed:
    Output

    index.html moodle

     

  8. To view the files within the Moodle directory:
    ls /var/www/html/moodle
  9. A list of all the Moodle files and directories that are just downloaded and uncompressed will appear.
  10. To create a directory outside the web root for Moodle to store all the course-related data that will be stored on the server, but not in the database, run the command:
    sudo mkdir /var/moodledata
  11. Then set its ownership to make sure that the web service user www-data can access the directory:
    sudo chown -R www-data /var/moodledata
  12. Then change the permissions on the folder so that only the owner has full permissions:
    sudo chmod -R 0770 /var/moodledata
  13. Now Moodle is installed on the server, so we have to set up the database it’ll use. Firstly, we need to make a few changes to the MySQL configuration file to make it Moodle compatible. Open the MySQL configuration file and run the command:
    sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
  14. Then add the following lines to the ‘Basic Settings’ area, which configure the storage type that new databases should use:
    default_storage_engine = innodb
    innodb_file_per_table = 1
    innodb_file_format = Barracuda

     

  15. Save this file and then restart the MySQL server to reload the configuration with the new settings.
    sudo systemctl restart mysql
  16. With MySQL command-line interface, create the Moodle database with the command:
    mysql -u root -p
  17. When prompted, supply the root password we set when we installed MySQL.
  18. Once logged in, we can see the mysql prompt. Run the following command to create the database:
    CREATE DATABASE moodle DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
  19. Then create a Moodle user with the command:
    create user 'yourusername'@'localhost' IDENTIFIED BY 'yourpassword';
  20. Give the Moodler user permission to edit the database.
    GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,CREATE TEMPORARY TABLES,DROP,INDEX,ALTER ON moodle.* TO 'yourusername'@'localhost' IDENTIFIED BY 'yourpassword';
  21. Now exit the MqSQL command-line interface:
    mysql> quit;
  22. To complete the Moodle configuration, we’ll open the site in a web browser and provide it with some further configuration information. We must temporarily change the permissions for the Moodle web root in order for the web server to save the configuration.
    sudo chmod -R 777 /var/www/html/moodle
  23. Now open up a browser and go to http://your_server_ip/moodle. We will see a page where we can configure the settings for Moodle. Follow the above instructions while configuring Moodle on DigitalOcean Server:
    • Select the language and then click Next.
    • Set the Data Directory to /var/moodledata and click Next.
    • Set the Database driver to Improved MySQL on the Choose Database Driver screen (native mysqli). Then press the Next button.
    • Enter the username and password for the Moodle MySQL user created in Step 3 on the Database settings page. The other fields can be left alone. To proceed, click Next.
    • Examine the licencing agreement and click Continue to confirm the agreement.
    • Examine the Server Checks page for any potential concerns. Check that the statement “Your server environment meets all basic requirements” appears at the bottom, then click Continue.
    • Moodle will install multiple components, each with a “Success” message. Continue after scrolling to the bottom.
    • Now a page where we can create our Moodle administrator account will appear. Set the fields to appropriate values. Then click Update profile.
    • Fill in the Full site name, Short site name, location, and whether we want to allow self-registration by email on the Front Page Settings screen. Then press the Save changes button.
  24. Now we are on the dashboard of the new Moodle installation, logged in as the admin user.
  25. Back in the terminal, execute the following command to restrict permissions to the Moodle web root again:
    sudo chmod -R 0755 /var/www/html/moodle
  26. To improve Moodle’s security, we need to change default permissions Moodle uses. Open the Moodle configuration file in the editor and run the below command:
    sudo nano /var/www/html/moodle/config.php
  27. Now Locate this line:
    $CFG->directorypermissions = 0777;
  28. Change it to the following:
    $CFG->directorypermissions = 0770;

     

  29. Finally, save the file and exit the editor. Also reset the permissions on the /var/moodledata directory itself, as Moodle already created some world-writeable folders and during the installation process:
    sudo chmod -R 0770 /var/moodledata

Now the Moodle is installed and configured successfully on the DigitalOcean Ubuntu platform.

[Looking for a solution to another query? We are just a click away.]

Conclusion

To sum up, our Support team went over the installation details of Moodle on DigitalOcean Ubuntu Server.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.