How to install Moodle on Ubuntu 16.04

Introduction

Moodle is a popular, open source, web-based learning management system (LMS) that anyone can install and use for free. With Moodle, you can create and provide learning resources such as courses, readings and discussion boards for the learner community. Moodle also allows you to manage user roles, so students and teachers can have different levels of material access. After installing Moodle on the web server, anyone with access to your website can create and participate in browser-based learning.

In this tutorial, you will install and set up Moodle on an Ubuntu 16.04 server. You will install and configure all the software needed for Moodle, run the setup wizard, select a theme and create your first course.

Preparation

Before starting this tutorial, you need the following:

Step one-install Moodle and dependencies

Moodle relies on some software, including spell check library and graphics library. Moodle is a PHP application and it has some additional PHP library dependencies. Before we install Moodle, let's install all the necessary libraries using the package manager. First, make sure you have the latest package list:

sudo apt-get update

Then 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

Next, restart the Apache web server to load the module just installed:

sudo systemctl restart apache2

Now we are ready to download and install Moodle itself. We will use curl to download Moodle from the official distribution server.

The following command will go to the Moodle website and put the compressed package containing the entire current stable version of Moodle into the moodle.tgz file. The -L flag tells curl to follow the redirection.

curl -L https://download.moodle.org/download.php/direct/stable32/moodle-latest-32.tgz > moodle.tgz

Now we can use the tar program to decompress the file and place the generated file in the root directory of the web document:

sudo tar -xvzf moodle.tgz -C /var/www/html

Verify that the moodle directory is in the web root directory of the server:

ls /var/www/html

You should see the directories listed by moodle:

Outputindex.html  moodle

Now look at the files in the moodle directory:

ls /var/www/html/moodle

You will see all the Moodle files and directories you just downloaded and unzipped:

admin           composer.json     grade          message                    README.txt
auth            composer.lock     group          mnet                       report
availability    config-dist.php   Gruntfile.js   mod                        repository
backup          config.php        help_ajax.php  my                         rss
badges          CONTRIBUTING.txt  help.php       notes                      search
behat.yml.dist  COPYING.txt       index.php      npm-shrinkwrap.json        tag
blocks          course            install        package.json               tags.txt
blog            dataformat        install.php    phpunit.xml.dist           theme
brokenfile.php  draftfile.php     INSTALL.txt    pix                        TRADEMARK.txt
cache           enrol             iplookup       plagiarism                 user
calendar        error             lang           pluginfile.php             userpix
cohort          file.php          lib            portfolio                  version.php
comment         files             local          PULL_REQUEST_TEMPLATE.txt  webservice
competency      filter            login          question
completion      githash.php       media          rating

Now we need to create a directory outside the web root directory so that Moodle will store all course-related data that will be stored on the server but not in the database. It is safer to create this directory outside the web root directory, so it cannot be accessed directly from the browser. Execute the following commands:

sudo mkdir /var/moodledata

Then set its ownership to ensure that the web service user www-data can access the directory:

sudo chown -R www-data /var/moodledata

Then change the permissions of the folder so that only the owner has full permissions:

sudo chmod -R 0770/var/moodledata

Now that you have installed Moodle on the server, it is time to set up the database it will use.

Step 2-Configure the database

We need to create a MySQL database, and Moodle will store most of its data. We will create the structure expected by the Moodle code, and we will create a user that Moodle will use to connect to the database.

But first we need to make some changes to the MySQL configuration file so that our MySQL installation is compatible with Moodle. Open the MySQL configuration file:

sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf

Then add the following highlighted line to the "Basic Settings" area, which configures the type of storage that the new database should use:

...[ mysqld]
#
# * Basic Settings
#
user            = mysql
pid-file        =/var/run/mysqld/mysqld.pid
socket          =/var/run/mysqld/mysqld.sock
port            =3306
basedir         =/usr
datadir         =/var/lib/mysql
tmpdir          =/tmp
lc-messages-dir =/usr/share/mysql
skip-external-locking
default_storage_engine = innodb
innodb_file_per_table =1
innodb_file_format = Barracuda
## Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure....

Save this file, then restart the MySQL server to reload the configuration with the new settings.

sudo systemctl restart mysql

Now we can create the Moodle database. To do this, you will interact with the MySQL command line interface. Execute the following commands:

mysql -u root -p

When prompted, provide the root password you set when you installed MySQL.

After logging in, you will 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 so that we don't have to tell the Moodle application our root password. Execute the following commands:

**Note: **In the next two commands, moodler is replaced with your Moodle username and the password chosen by moodlerpassword.

create user 'moodler'@'localhost' IDENTIFIED BY 'moodlerpassword';

And grant the moodler user permission to edit the database. The user needs to create tables and change permissions:

GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,CREATE TEMPORARY TABLES,DROP,INDEX,ALTER ON moodle.* TO 'moodler'@'localhost' IDENTIFIED BY 'moodlerpassword';

Now exit the MqSQL command line interface:

quit;

This will be responsible for database configuration. Now we can start Moodle in the browser and continue setting up there.

Step 3-Configure Moodle in the browser

To complete the configuration of Moodle, we will display the site in a web browser and provide it with some other configuration details. In order for the web server to save the configuration, we need to temporarily change the permissions of the Moodle web root directory.

**Warning: ** The permission can open this folder at most. If you are not satisfied with this, just do not change the permissions. The web interface will provide instructions for manually modifying the configuration file.

If you do change the permission, it is important to revoke this permission immediately after completing the setup. This step is included in this tutorial.

sudo chmod -R 777/var/www/html/moodle

Now open the browser and go to http://your_server_ip/moodle. You will see the following page.

Please follow the steps below to configure Moodle:

  1. Set the language you want to use and click "Next".

  2. On the next screen, set Data Directory to /var/moodledata and click Next.

  3. On the Choose Database Driver page, set Database driver to Improved MySQL (native mysqli). Then click Next.

  4. On the "Database Settings" page, enter the username and password of the Moodle MySQL user you created in step 3. The other fields can be left as they are. Click "Next" to continue.

  5. Press "Continue" to view the license agreement and confirm that you agree to its terms.

  6. Check the "Server Check" page for any possible issues, make sure that there is a message "Your server environment meets all minimum requirements" at the bottom, and then press ** to continue. **

  7. Moodle will install several components and display a "success" message for each component. Scroll to the bottom and press ** to continue. **

  8. Then, you will see a page where you can set up an administrator account for Moodle.

  9. For Username, enter whatever you want and accept the default value.

  10. For Choose Authentication Method, please keep the default value.

  11. For New Password, please enter the password you want to use.

  12. For email, please enter your email

  13. Set the remaining fields to appropriate values.

  14. Click Update Personal Information.

  15. On the "Homepage Settings" screen, fill in "Full Site Name", "Short Name of Site", set the location, and then choose whether to allow self via email registered. Then click ** to save the changes. **

Once you have completed this. You will be taken to the dashboard of the new Moodle installation and log in as the admin user.

Now that your settings are complete, it is important to restrict the permissions of the Moodle Web root directory again. Return to the terminal and execute the following command:

sudo chmod -R 0755/var/www/html/moodle

Let's make a small change to improve the security of Moodle. By default, Moodle creates files in the folder /var/moodledata with global writable permissions. Let's strengthen it by changing the default permissions used by Moodle.

Open the Moodle configuration file in the editor:

sudo nano /var/www/html/moodle/config.php

Find this line:

$CFG->directorypermissions =0777;

Change it to the following:

$CFG->directorypermissions =0770;

Then save the file and exit the editor.

Finally, reset the permissions of the /var/moodledata directory itself, because Moodle has created some world-writable folders and during the installation process:

sudo chmod -R 0770/var/moodledata

Now that Moodle is configured, let's make some customizations and create a test course to learn about the Moodle web interface.

Step 4-Customize Moodle and create your first course

Now that your website is running, the first thing you need to do that night is to register your Moodle website. This will subscribe to the Moodle mailing list to keep you informed about security alerts and new versions.

To register, click the "Site Management" link in the left frame, and then click "Register". Then fill out the web form with the appropriate details. You can also choose to publish your Moodle website so that others can find it.

Next, let us change the theme of the Moodle website. Select Site Management, select the Appearance tab, and then select Theme Selection. You will see a page as shown in the figure below, indicating that you are currently using the "Boost" theme on the default device, which refers to modern web browsers:

Click the "Change Theme" button and you will enter a screen showing other available themes. When you click the Use Theme button under the theme name, your Moodle website will use that theme to display all the content of your website. You can also choose different themes for different devices such as tablets or phones.

Now that you have made your Moodle website closer to what you want it to be, it's time to create your first dish. Select Site home from the navigation menu. You will see an empty course list and an Add New Course button. Click this button to display the form shown in the figure below:

Fill in the information about the course, including name, abbreviation, description and any other relevant details. Then scroll to the bottom and click "Save and display".

Your first Moodle course is now ready. You can use the Moodle interface to start adding courses and activities to the course items.

But before you start getting people to register for new courses, you should make sure that your Moodle installation is ready for production. First, you need to set up a TSL/SSL certificate for Apache to encrypt the traffic between the server and the client. To ensure that your data is protected, please make sure to Backup MySQL database regularly. You should also back up the files on the server, including the /var/moodledata/ folder.

in conclusion

In this article, you installed and set up Moodle on an Ubuntu 16.04 server. Moodle is a powerful and highly configurable web application. Be sure to check the Moodle documentation and connect with the global community of Moodle users and administrators for ideas on how to make the most of it.

To learn more about Ubuntu's open source information tutorial, please go to [Tencent Cloud + Community] (https://cloud.tencent.com/developer?from=10680) to learn more.

Reference: "How To Install Moodle on Ubuntu 16.04"

Recommended Posts

How to install Moodle on Ubuntu 16.04
How to install Ruby on Ubuntu 20.04
How to install Memcached on Ubuntu 20.04
How to install Java on Ubuntu 20.04
How to install MySQL on Ubuntu 20.04
How to install VirtualBox on Ubuntu 20.04
How to install Elasticsearch on Ubuntu 20.04
How to install Protobuf 3 on Ubuntu
How to install Nginx on Ubuntu 20.04
How to install Apache on Ubuntu 20.04
How to install Git on Ubuntu 20.04
How to install Node.js on Ubuntu 16.04
How to install MySQL on Ubuntu 20.04
How to install Vagrant on Ubuntu 20.04
How to install Bacula-Web on Ubuntu 14.04
How to install PostgreSQL on Ubuntu 16.04
How to install Git on Ubuntu 20.04
How to install Anaconda3 on Ubuntu 18.04
How to install Memcached on Ubuntu 18.04
How to install Jenkins on Ubuntu 16.04
How to install MemSQL on Ubuntu 14.04
How to install Go on Ubuntu 20.04
How to install MongoDB on Ubuntu 16.04
How to install Mailpile on Ubuntu 14.04
How to install PrestaShop on Ubuntu 16.04
How to install Skype on Ubuntu 20.04
How to install Jenkins on Ubuntu 20.04
How to install Python 3.8 on Ubuntu 18.04
How to install KVM on Ubuntu 18.04
How to install opencv3.0.0 on ubuntu14.04
How to install Anaconda on Ubuntu 20.04
How to install Prometheus on Ubuntu 16.04
How to install Jenkins on Ubuntu 18.04
How to install Apache on Ubuntu 20.04
How to install Solr 5.2.1 on Ubuntu 14.04
How to install Teamviewer on Ubuntu 16.04
How to install MariaDB on Ubuntu 20.04
How to install Nginx on Ubuntu 20.04
How to install Mono on Ubuntu 20.04
How to install Go on Ubuntu 20.04
How to install Zoom on Ubuntu 20.04
How to install Nginx on Ubuntu 16.04
How to install OpenCV on Ubuntu 20.04
How to install Spotify on Ubuntu 20.04
How to install Postman on Ubuntu 18.04
How to install Go 1.6 on Ubuntu 16.04
How to install Go on Ubuntu 18.04
How to install MySQL on Ubuntu 14.04
How to install PostgreSQL on Ubuntu 20.04
How to install VLC on Ubuntu 18.04
How to install TeamViewer on Ubuntu 20.04
How to install Webmin on Ubuntu 20.04
How to install Docker Compose on Ubuntu 18.04
How to install Ubuntu on Raspberry Pi
How to install MySQL on Ubuntu 18.04 (linux)
How to install Ubuntu 19.10 on Raspberry Pi 4
How to install Apache Kafka on Ubuntu 18.04
How to install Apache Maven on Ubuntu 20.04
How to install Apache Tomcat 8 on Ubuntu 16.04
How to install Python2 on Ubuntu20.04 ubuntu/focal64
How to install GCC compiler on Ubuntu 18.04