How to Create Own Online Learning Management System Using Moodle in Linux
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]
# 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 moodle@'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.