Moodle is a popular opensource learning platform that allows anyone to create personalized learning environment for teachers and students. This opensource content management system is great for schools, colleges and universities that want to expand their curriculum online.
Moodle is free to use and it’s released under the GNU general public license. With its global community based, anyone can learn and create online training classes easily
This brief tutorial is going to show students and new users how to easily install Moodle on Ubuntu 17.04 / 17.10.
Moodle relies on the opensource LAMP stack to function. If you’re going to be running Moodle, make sure you’re aware of LAMP.
To install Moodle, follow the steps below:
Step 1: Install and Update Ubuntu
Since we’re going to be running Ubuntu, lets install and update it. This post assumes that you’ve already installed Ubuntu and that you have administrative rights to the systems to install packages and make changes.
After installing Ubuntu, run the commands below to update it.
sudo apt-get update && sudo apt-get dist-upgrade && sudo apt-get autoremove
After updating Ubuntu, you may have to reboot the system.
Step 2: Install Apache2
Now that the Ubuntu machine is updated, run the commands below to install Apache2.
sudo apt-get install apache2
After installing Apache2, the commands below can be used to stop, start and enable Apache2 to always start up when the system boots.
sudo systemctl stop apache2.service sudo systemctl start apache2.service sudo systemctl enable apache2.service
Step 3: Install MySQL
After installing Apache2, run the commands below to install MySQL database server.
sudo apt-get install mysql-server mysql-client
During MySQL installation, you’ll get a prompt to create and confirm a new password for MySQL root user. Please do.
After installing, the commands below can be used to stop, start and enable MySQL
sudo systemctl stop mysql.service sudo systemctl start mysql.service sudo systemctl enable mysql.service
When you’re done, run the commands below to secure MySQL server.
The commands above should prompt you to answer series of questions.. follow the guide below to answer them.
Enter password for user root: TYPE CURRENT ROOT PASSWORD VALIDATE PASSWORD PLUGIN can be used to test passwords and improve security. It checks the strength of password and allows the users to set only those passwords which are secure enough. Would you like to setup VALIDATE PASSWORD plugin? Press y|Y for Yes, any other key for No: y There are three levels of password validation policy: LOW Length >= 8 MEDIUM Length >= 8, numeric, mixed case, and special characters STRONG Length >= 8, numeric, mixed case, special characters and dictionary file Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2 Using existing password for root. Estimated strength of the password: 50 Change the password for root ? ((Press y|Y for Yes, any other key for No) : n ... skipping. By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? (Press y|Y for Yes, any other key for No) : y Success. Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y Success. By default, MySQL comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y - Dropping test database... Success. - Removing privileges on test database... Success. Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y Success. All done!
Next, run the commands below to open MySQL default configuration file.
sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
Then add the below lines just below [mysqld] section.
default_storage_engine = innodb innodb_file_per_table = 1 innodb_file_format = Barracuda
When you’re done, save the file.
Step 4: Create Moodle MySQL Database and User
At this point, you’ll want to create a database and user for Moodle. To do that, run the commands below to logon to the database server
sudo mysql -u root -p
Type the root password you created during MySQL installation.
Next, run the commands below to create a database called moodledb
CREATE DATABASE moodledb;
Next, run the commands below to create a database user called moodleuser and set a new password
CREATE USER 'moodleuser'@'localhost' IDENTIFIED BY 'new_password_here';
Next, grant the new user full access to the database
GRANT ALL ON moodledb.* TO 'moodleuser'@'localhost';
Finally, save your changes to disk.
FLUSH PRIVILEGES; exit;
After creating the database and user, continue below to install PHP
Step 5: Install PHP and Related Modules
Now that Nginx and MySQL are installed, run the commands below to install PHP and other PHP modules.
sudo apt-get install php graphviz aspell php-pspell php-curl php-gd php-intl php-mysql php-xml php-xmlrpc php-ldap php-zip php-soap php-mbstring
The commands above will install all PHP and related modules to help Moodle function efficiently.
STEP 6: DOWNLOADING MOODLE
Now that Nginx, MySQL and PHP are installed, continue below to download Moodle. You may need git package. Run the commands below to install it.
sudo apt-get install git
The change into the /html directory and download Moodle.
cd /var/www/html sudo git clone git://git.moodle.org/moodle.git
Change into the moodle directory.. then run the commands below to see the latest moodle packages. At the time of this post, the latest version was at 33..
cd moodle sudo git branch -a sudo git branch --track MOODLE_33_STABLE origin/MOODLE_33_STABLE
Now, after see the latest, run the commands below to check it out the current latest.
sudo git checkout MOODLE_33_STABLE
Moodle latest version should now be downloaded into the /var/www/html/moodle directory.
Next, run the commands below to create moodledata directory.
sudo mkdir -p /var/www/html/moodledata
Next, run the commands below to set good permissions on moodle folder
sudo chown -R www-data:www-data /var/www/html sudo chmod -R 755 /var/www/html
Continue below to configure Nginx site.
Finally, update Apache2 configuration file and point the default root directory to be /var/www/html/moodle as specified above
sudo nano /etc/apache2/sites-available/000-default.conf
Then make the highlighted change below.
# The ServerName directive sets the request scheme, hostname and port that # the server uses to identify itself. This is used when creating # redirection URLs. In the context of virtual hosts, the ServerName # specifies what hostname must appear in the request's Host: header to # match this virtual host. For the default virtual host (this file) this # value is not decisive as it is used as a last resort host regardless. # However, you must set it for any further virtual host explicitly. #ServerName www.example.com ServerAdmin webmaster@localhost DocumentRoot /var/www/html/moodle
Save the file
Next, run the commands below to enable these Apache2 modules.
sudo a2enmod rewrite sudo a2enmod env sudo a2enmod dir sudo a2enmod mime
Then restart Apache2
sudo systemctl restart apache2.service
Finally open your browser and browse to the server hostname of IP address
You should see Moodle setup wizard.
Accept the default location and continue.
Continue and select MySQL database server.
Then enter the database name, database user and password and continue.
Continue and make sure there are no errors, until you’re done.
This is how to install Moodle CMS.
This post shows students and new users easy way to install Moodle on Ubuntu 17.04 / 17.10. If you follow the steps above, in no time you should have a fully functioning Moodle website.
You may also like the post below:
- Installing Moodle on Ubuntu 17.04 with Nginx Support
- Install Moodle 3.3.2 on Ubuntu 17.04 / 17.10 with Apache2, MariaDB and PHP Support
- Install Moodle 3.3.2 on Ubuntu 17.04 / 17.10 with Nginx, MariaDB and PHP Support
- Install Moodle on Ubuntu 17.04 / 17.10 with Nginx, MariaDB, PHP and Let’s Encrypt SSL
- Install Moodle on Ubuntu 16.04 LTS with Nginx, MariaDB, PHP 7.1 and Let’s Encrypt free SSL/TLS
- Install Moodle CMS on Ubuntu 18.04 LTS with Nginx, MariaDB and PHP 7.1 Support
- Moodle 3.5.1 Released — Here’s How to Install on Ubuntu 16.04 / 18.04 LTS
- Moodle 3.5.2 is now Available — Here’s How to Install / Upgrade on Ubuntu 16.04 / 18.04 LTS
- Install / Upgrade Moodle Latest from Github on Ubuntu 16.04 / 18.04 LTS with Apache2, MariaDB, PHP 7.2 Support