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
- Firstly, ensure we have the latest list of packages using the code:
sudo apt-get update
- 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
- Restart the Apache web server to load the modules:
sudo systemctl restart apache2
- Now download and install Moodle using curl command:
curl -L https://download.moodle.org/download.php/direct/stable32/moodle-latest-32.tgz > moodle.tgz
- 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
- Confirm the Moodle directory is in the server’s web root directory:
ls /var/www/html
- We can see the Moodle directory listed:
Output
index.html moodle
- To view the files within the Moodle directory:
ls /var/www/html/moodle
- A list of all the Moodle files and directories that are just downloaded and uncompressed will appear.
- 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
- 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
- Then change the permissions on the folder so that only the owner has full permissions:
sudo chmod -R 0770 /var/moodledata
- 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
- 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
- Save this file and then restart the MySQL server to reload the configuration with the new settings.
sudo systemctl restart mysql
- With MySQL command-line interface, create the Moodle database with the command:
mysql -u root -p
- When prompted, supply the root password we set when we installed MySQL.
- 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;
- Then create a Moodle user with the command:
create user 'yourusername'@'localhost' IDENTIFIED BY 'yourpassword';
- 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';
- Now exit the MqSQL command-line interface:
mysql> quit;
- 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
- 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.
- Now we are on the dashboard of the new Moodle installation, logged in as the admin user.
- 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
- 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
- Now Locate this line:
$CFG->directorypermissions = 0777;
- Change it to the following:
$CFG->directorypermissions = 0770;
- 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.
var google_conversion_label = "owonCMyG5nEQ0aD71QM";
0 Comments