Moodle is a free and open source Learning Platform or course management system (CMS) written in PHP. It is used for creating E-learning websites, online tests, course materials and discussion boards.
You can also add extra functionality via plugins. Moodle is a web based, so it can be used by everyone for the schools, businesses, colleges, charities, universities, and the public sector to manage their account creation, enrollments and permissions etc.
You can easily scale moodle to very large deployments and hundreds of thousands of students.
Moodle comes with lots of features such as Personalized Dashboards, Supports blogs, forums etc, User friendly web interface, simple text editor and many more.
In this guide, we will learn how to install and set up Moodle on Ubuntu 16.04 server.
- A Ubuntu 16.04 server with minimum 1GB RAM installed on your system.
- A non sudo user with root privileges setup on your server.
Update the System
First, you will need to update your system package repository with the latest stable version.
You can do this by running the following command:
sudo apt-get update -y
sudo apt-get upgrade -y
Once your system package repository is up to date, you can proceed to the next step.
Install LAMP Server
First, you will need to install Apache, PHP and MySQL on your server. You can install it with the following command:
sudo apt-get install apache2 mysql-server php7.0 -y
Once installation is complete, start Apache and MySQL service and enable them to start at boot with the following command:
sudo systemctl start apache2
sudo systemctl start mysql
sudo systemctl enable apache2
sudo systemctl enable mysql
Once you are finished, you can proceed to install Moodle.
Before installing Moodle, you will need to install all of the prerequisite libraries using the package manager.
You can do this with the following command:
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 -y
Once all the packages are installed, restart apache service to load the modules.
Next, you will need to download the latest stable version of the Moodle. You can download it with the following command:
curl -L https://download.moodle.org/download.php/direct/stable32/moodle-latest-32.tgz
Once the download is complete, extract the downloaded file in to apache web root directory:
sudo mkdir /var/www/html/moodle
sudo tar -xvzf moodle-latest-32.tgz -C /var/www/html/moodle
Next, give proper permission to the moodle:
sudo chown -R www-data:www-data /var/www/html/moodle
Next, you will need to create a directory for Moodle to store all the course-related data that will be stored on the server:
sudo mkdir /var/moodledata
sudo chown -R www-data /var/moodledata
sudo chmod -R 0770 /var/moodledata
Configure Database for Moodle
Before configuring your database, you will need to secure it first. You can secure it by running the mysql_secure_installation script:
Answer all the questions as shown below:
Set root password? [Y/n] n Remove anonymous users? [Y/n] y Disallow root login remotely? [Y/n] y Remove test database and access to it? [Y/n] y Reload privilege tables now? [Y/n] y
Once MySQL is secured, log in to the MySQL shell and create a database for moodle:
mysql -u root -p
Enter your root password when prompted, then create a database for moodle. It is recommended to set secure password:
`mysql>CREATE DATABASE moodledb DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci; Query OK, 1 row affected (0.00 sec)`
`mysql>CREATE USER 'moodler'@'localhost' IDENTIFIED BY 'password'; Query OK, 1 row affected (0.00 sec)`
Next, grant all privileges with the following command:
`mysql>GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,CREATE TEMPORARY TABLES,DROP,INDEX,ALTER ON moodle.* TO moodle@localhost IDENTIFIED BY 'password'; Query OK, 1 row affected (0.00 sec)`
Next, flush all privileges so that the privileges table will be reloaded by MySQL and we can use new credentials:
`mysql>FLUSH PRIVILEGES; Query OK, 1 row affected (0.00 sec)` ````
Then, exit from the MySQL shell:
```language-bash `mysql>exit; Query OK, 1 row affected (0.00 sec)`
Next, you will need to configure the default storage engine to innodb. You can do this by editing the my.cnf file:
sudo nano /etc/mysql/my.cnf
Add the following lines under [mysqld] section:
default_storage_engine = innodb innodb_file_per_table = 1 innodb_file_format = Barracuda
Save the file and restart MySQL web server so that the changes take place:
sudo systemctl restart mysql
Configure Apache web server for Moodle
Next, you will need to create a new virtual host directive in Apache. You can do this by creating moodle.conf file inside /etc/apache2/sites-available/ directory:
sudo nano /etc/apache2/sites-available/moodle.conf
Add the following lines:
<VirtualHost *:80> ServerAdmin firstname.lastname@example.org DocumentRoot /var/www/html/moodle ServerName 192.168.15.189 ServerAlias www.yourdomain.com <Directory /var/www/html/moodle/> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> ErrorLog /var/log/httpd/moodle-error_log CustomLog /var/log/httpd/moodle-access_log common </VirtualHost>
Save and close the file, then restart Apache web server so that the changes take place:
sudo systemctl restart apache2
Next, enable rewrite module and virtual host by running the following command:
sudo a2enmode rewrite
sudo a2ensite moodle
Once you are done, you can proceed to the next step.
Once everything is configured, it's time to access the Moodle web interface.
Open your web browser and type the URL http://192.168.15.193, you should see the moodle installation page in below image:
Choose the English language and click on the Next button, you should see the following page:
Here, confirm moodle web address, moodle directory and moodle data directory, then click on the Next button. You should see the following page:
Here, select MySQL database and click on the Next button you should see the following page:
Here, provide all database information like database name, username and password, then click on the Next button you should see the following page:
Here, confirm the Moodle copyright condition then click on the Next button you should see the following page:
Here, you will be shown a large number of server requirements, scroll down to see a message and complete all the requirements then click on the Continue button, you should see the lot's of success messages. Then click on the Continue button you should see the following page:
Here, you will need to provide ab administrative username, email and password. Click on Update profile button. You should see the following page:
Here, you will be asked to provide a title and short title for your website and other required information. Once you have done click on the Save changes button. You should see the Moodle dashboard as below:
Congratulations! moodle is now successfully installed on your Ubuntu 16.04 server.