Moodle is a free, feature rich, open source learning management system (LMS). The platform is used by many online school and universities as well as private educators.
Moodle is extremely customizable and it is meant to meet the requirements of wide range of users including teachers, students or administrators.
Some of the most noticeable features that Moodle has are:
- Modern and easy to use interface
- Personalized dashboard
- Collaborative tools
- All-in-one calendar
- Easy file management
- Simple text editor
- Progress tracking
- Customizable site design/layout
- Multiple supported languages
- Bulk course creation
- User roles
- Plugins for additional functionalities
- Multimedia integration
Of course the above are just small part of the features that Moodle has. if you want to see the complete list, you can check the Moodle docs.
The latest stable Moodle version (3.0) was released just recently on November 16 2015. The release has the following requirements:
- Apache or Nginx
- MySQL/MariaDB version 5.5.31
- PHP 5.5 and its extensions
In this tutorial, I will show you how to install Moodle LMS (Learning Management System) on RedHat based systems such as CentOS/Fedora and Debian its derivatives using LAMP or LEMP (Linux, Apache/Nginx, MySQL/MariaDB and PHP) stack with subdomain moodle.tecmint.com and IP address 192.168.0.3.
Important: The commands will be executed with root user or sudo privileges, so make sure that you have full access to your system.
Step 1: Installing LAMP or LEMP Environment
LAMP/LEMP is a stack of open source software designed to build and host websites. It uses Apache/Nginx as web server, MariaDB/MySQL for relational database management system and PHP as object oriented programming language.
You can use following one single command to install LAMP or LEMP stack in your respective Linux operating systems as shown:
Installing LAMP Stack
# yum install httpd php mariadb-server [On RedHat/CentOS based systems] # dnf install httpd php mariadb-server [On Fedora 22+ versions] # apt-get install apache2 php5 mariadb-server [On Debian/Ubuntu based systems]
Installing LEMP Stack
# yum install nginx php php-fpm mariadb-server [On RedHat/CentOS based systems] # dnf install nginx php php-fpm mariadb-server [On Fedora 22+ versions] # apt-get install nginx php5 php5-fpm mariadb-server [On Debian/Ubuntu based systems]
Step 2: Installing PHP Extensions and Libraries
Next, you need to install following recommended PHP extensions and libraries to run Moodle error free.
--------------------- On RedHat/CentOS based systems --------------------- # yum install php-iconv php-mbstring php-curl php-opcache php-xmlrpc php-mysql php-openssl php-tokenizer php-soap php-ctype php-zip php-gd php-simplexml php-spl php-pcre php-dom php-xml php-intl php-json php-ldap wget unzip
--------------------- On On Fedora 22+ versions --------------------- # dnf install php-iconv php-mbstring php-curl php-opcache php-xmlrpc php-mysql php-openssl php-tokenizer php-soap php-ctype php-zip php-gd php-simplexml php-spl php-pcre php-dom php-xml php-intl php-json php-ldap wget unzip
--------------------- On Debian/Ubuntu based systems --------------------- # apt-get install graphviz aspell php5-pspell php5-curl php5-gd php5-intl php5-mysql php5-xmlrpc php5-ldap
Step 3: Configure PHP Settings
Now open and modify PHP settings in your
.htaccess (Only if you don’t have access to php.ini) file as shown below.
Important: If you’re using PHP older than 5.5, then some of the following PHP settings removed and you will won’t find in your php.ini file.
register_globals = Off safe_mode = Off memory_limit = 128M session.save_handler = files magic_quotes_gpc = Off magic_quotes_runtime = Off file_uploads = On session.auto_start = 0 session.bug_compat_warn = Off post_max_size = 50M upload_max_filesize = 50M
On Nginx web server, you need to enable following variable in php.ini file as well.
After making above changes, restart the web server as shown:
On Apache Web Server
--------------------- On SysVinit based systems --------------------- # service httpd restart [On RedHat/CentOS based systems] # service apache2 restart [On Debian/Ubuntu based systems]
--------------------- On Systemd based systems --------------------- # systemctl restart httpd.service [On RedHat/CentOS based systems] # systemctl restart apache2.service [On Debian/Ubuntu based systems]
On Nginx Web Server
--------------------- On SysVinit based systems --------------------- # service nginx restart # service php-fpm restart
--------------------- On Systemd based systems --------------------- # systemctl restart nginx.service # systemctl restart php-fpm.service
Step 4: Install Moodle Learning Management System
Now we are ready to prepare our Moodle files for installation. For that purpose, navigate to the web root directory of your Apache or Nginx server. You can do this via:
# cd /var/www/html [For Apache] # cd /usr/share/nginx/html [For Nginx]
Next go the Moodle download page and grab the latest Moodle (i.e. version 3.0 as the time of writing this article) archive or with the help of following wget command.
# wget https://download.moodle.org/download.php/direct/stable30/moodle-3.0.zip
Now unzip the downloaded archive, this will create a new directory called “moodle” and move all of it’s contents to web server’s root web directory (i.e. /var/www/html for Apache or /usr/share/nginx/html for Nginx) using following series of command.
# unzip moodle-3.0.zip # cd moodle # cp -r * /var/www/html/ [For Apache] # cp -r * /usr/share/nginx/html [For Nginx]
Now let’s fix the files ownership to webserver user, depending on your distribution Apache might be running with user “apache” or “www-data” and Nginx running as a user nginx.
To fix the file ownership, run the following command.
# chown -R apache: /var/www/html [On RedHat/CentOS based systems] # chown -R www-data: /var/www/html [On Debian/Ubuntu based systems] OR # chown -R nginx: /usr/share/nginx/html/
Moodle also uses a data directory meant to keep teachers and students data. For example this directory will keep videos, documents, presentations and others.
For security purposes, you should create that directory outside of the web directory root. In this tutorial we will create a separate
# mkdir /var/www/moodledata [For Apache] # mkdir /usr/share/moodledata [For Nginx]
And again fix the folder ownership with:
# chown -R apache: /var/www/moodledata [On RedHat/CentOS based systems] # chown -R www-data: /var/www/moodledata [On Debian/Ubuntu based systems] OR # chown -R nginx: /usr/share/moodledata
Step 5: Create Moodle Database
Moodle uses a relational database to store its data and so we will need to prepare a database for our installation. This can be easily done with the following commands:
# mysql -u root -p
Enter your password and proceed. Now create new database called “moodle”:
MariaDB [(none)]> create database moodle;
Now let’s grant a user “moodle” with all privileges on database moodle:
MariaDB [(none)]> grant all on moodle.* to [email protected]'localhost' identified by 'password';
Step 6: Start the Moodle Installation
We are now ready to continue with the installation of Moodle. For that purpose open your IP address or hostname in a browser. You should see the Moodle’s installer. It will ask you to choose the language for your installation:
On the next step, you will be selecting the path for your Moodle data directory. This directory will contain the files uploaded by teachers and students.
For example vidoes, PDF, PPT and other files you upload on your website. We have already prepared this directory earlier, you just need to set the Moodle data dir to /var/www/moodledata or /usr/share/moodledata.
Next you will be selecting the database driver.
- For MySQL – Select Improved MySQL driver.
- For MariaDB – Select native/mariadb driver.
After that you will be prompted for the MySQL credentials that Moodle will be using. We already prepared those earlier:
Database Name: moodle Database User: moodle Password: password
Once you have filled the details, continue to the next page. The page will show you the copyrights related to Moodle:
Review those and continue to the next page. On the following page, Moodle will perform system checks for your server environment. It will inform you if there are missing modules/extensions on your system. If such are to be found, click on the link next to each extension that is shown as missing and you will be provided with instructions how to install it.
If everything is good, proceed to the next page, where the installer will populate the database. This process may take longer than expected. After that you will be asked to configure the administrative user. You will need to fill in the following details:
- Username – the username with which the user will login
- Password – password for the above user
- Email address for the administrative user
- Description – enter information about yourself
After you have configured your site administrator’s profile, it’s time to setup some info about the site. Fill in the following information:
- Full site name
- Short name for the site
- Front page summary – information that will be displayed on the site frontpage
- Location Settings
- Site registration – choose the registration type be self-registration or via email.
When you have filled all that information, the installation is complete and you will be taken to the administrator profile:
To access the Moodle administrative dashboard go to http://your-ip-address/admin. In my case this is:
Now your Moodle installation is complete and you can start managing your website and create your first courses, users or simply customize your site settings.
In case you have any questions or comments related to Moodle’s installation, please submit them in the comment section below.
We can do it for you !
If you would like to have Moodle installed on a real Linux live server, you can contact us at [email protected] with your requirements and we will provide custom offer just for you.
13 thoughts on “How to Create Own Online Learning Management System Using Moodle in Linux”
Very transparent guide on installing and configuring Moodle on Linux. Courses creation features are also easy to progress. Thanks for great explanation. I was searching for Litmos and came here. Along the search, I came across with Teachr. What is your review on this as many people are saying that it is very good.
In the meantime, I came across a similar product Teachr and it also seems to be good for my requirements.
Hi, Please, I need a complete guide on installing and configuring Moodle on Linux or windows. I intend using it locally for computer based test, however, If I can an idea to run it on the internet that will be fine as intended extending it to distance learning student
This guide is complete with all the steps needed to setup Moodle on a public domain, just check and give it a try to setup.
Many thanks for the information. I will try the procedure.
Please, for now I only need to install and configure Moodle on LAN to be used local for CBT for my student, will this guide help?
Sorry, I really wat to know the advantage or disadvantages of installing Moodle on windows and Linux. Which one do you recommend. Are the installation process the same?
You can check out advantage and disadvantage of Moodle at official site, and about installation instructions, I suggest you to go for Linux, because this article only shows Linux installation, and Windows installation steps are different.
I was not able to create the ‘moodledata’ directory; after setting SELinux to permissive, I was able to. I was getting the following error, “Data directory (/var/www/moodledata) cannot be created by the installer. I had to add SELinux label to the /var/www/moodle directory and I was able to proceed. semanage fcontext -a -t httpd_sys_rw_content_t /var/www/moodledata.
Thank for the tutorial though.
Yes that correct the installer won’t able to create ‘moodledata’ directory if SELinux set to permissive, that’s the reason either you’ve to disable it or set SELinux rule on httpd to allow modifications to directory..
Thanks for the tip..:)
Thanks Ravi, thanks to you I have moodle up and running :)
I am glad that my article helped you to setup moodle without any problems, thanks and keep visiting Tecmint..
Thanks a lot.
STEP five(5) is Missing !
Actually there isn’t any STEP missing, the numbering added wrongly, thanks for pointing out..