Install Moodle 3.0 on a Linux VPS

moodleMoodle is an all-in-one learning platform which is very flexible and highly customisable. It is robust and secure which is the main reason why it is trusted by institutions and organizations worldwide. In this tutorial, we will explain how to install Moodle 3.0 on a Linux VPS.

Login to your server via SSH and update your system.

For Ubuntu:

sudo apt-get update && sudo apt-get -y upgrade

For CentOS:

sudo yum -y update

Moodle 3.0 requires LAMP to be installed on your server. Make sure that you have Apache web server, MySQL database server and PHP already installed. In addition, Moodle requires a number of PHP extensions like mbstring, curl, gd, xml, simplexml, zip, soap etc. to be already installed on your Linux VPS, so make sure that all of the required PHP extensions are installed on your server. You can find the full list of required PHP extensions as well as all the recommended PHP settings at https://docs.moodle.org/30/en/PHP.

Once your server is ready, you can proceed with the installation of Moodle 3.0.

Navigate the the ‘/var/www/html/’ directory:

cd /var/www/html/

Download the latest stable release:

wget https://download.moodle.org/download.php/direct/stable30/moodle-latest-30.tgz

Extract the archive:

tar -xzvf moodle-latest-30.tgz

Change the ownership of the files.

For Ubuntu:

chown -R www-data: /var/www/html/moodle

For CentOS:

chown -R apache: /var/www/html/moodle

Next, create a MySQL database for Moodle. Log into MySQL as root:

mysql -u root -p

Create a new database and use ‘utf8_unicode_ci’ for collation:

mysql> CREATE DATABASE moodle DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;

Add a database user and set up a password:

mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,CREATE TEMPORARY TABLES,DROP,INDEX,ALTER ON moodle.* TO moodle_user@localhost IDENTIFIED BY 'YoUrPaSsWoRd';
mysql> FLUSH PRIVILEGES;
mysql> \q

Feel free to add a database user and set up a password that matches your needs.
Now, create an Apache virtual host for Moodle 3.0 and add the following content:

<VirtualHost *:80>
 ServerAdmin admin@yourdomain.com
 DocumentRoot /var/www/html/moodle
 ServerName yourdomain.com
 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/yourdomain.com-error_log
 CustomLog /var/log/httpd/yourdomain.com-access_log common
</VirtualHost>

Make sure that ‘yourdomain.com’ is replaced with your actual domain name. Once you make the changes, save the file and restart your Apache web server for the changes to take effect.

To continue with the online installation of Moodle, you should open your favorite web browser and enter your domain name into the address bar.

Once Moodle is completely installed on your Linux VPS, you will need to set up a cron job. Here is a typical cron entry:

* * * * *    /usr/bin/php /var/www/html/moodle/admin/cli/cron.php >/dev/null

In order Moodle to be able to send you emails, you need to have a working mail server installed on your VPS, or, you should have access to an SMTP mail server.

Of course you don’t have to do any of this if you use one of our Linux VPS hosting services, in which case you can simply ask our expert Linux admins to install Moodle 3.0 for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

Leave a Comment