How to Install Moodle on CentOS Server

Moodle is a course management system (CMS), also known as a learning management system (LMS) or a virtual learning environment (VLE). It is a free web application that educators can use to create effective online learning sites.

PHP Requirements for Moodle

  • The iconv extension is required.
  • The mbstring extension is recommended.
  • The curl extension is required
  • The openssl extension is recommended
  • The soap extension is recommended
  • The ctype extension is required.
  • The zip extension is required.
  • The gd extension is required
  • The simplexml extension is required.
  • The spl extension is required.
  • The pcre extension is required.
  • The dom extension is required.
  • The xml extension is required.
  • The json extension is required.

You can install all required PHP extensions by the following command

yum -y install  php-common php-cli php-pear php php-pdo php-mysql libXpm php-gd php-xml php-mbstring php-xmlrpc php-intl php-soap

LAMP or LEMP Setup

Make sure you have LAMP or LEMP setup ready on your webserver.

Download Moodle

Download moodle into /usr/local/src

#cd  /usr/local/src


Extract moodle and move into DocumentRoot

#tar xvzf moodle-latest-26.tgz #mv moodle /var/www/html/moodle

Create Database and User in mysql

Enter into mysql as root

You need to enter mysql root password to enter in to mysql.

#mysql -u root -p

Enter password:

You will get mysql command terminal. We need to create Database and User for moodle.

I'm going to set database name, username, and password as 'moodle'.You can change it as per your wish.

Create database

mysql> create database moodle;

Create User

mysql> create user moodle@localhost;

Set password for mysql user

mysql> set password for moodle@localhost = password ('moodle');

Allow Grant privileges to the user

mysql>GRANT ALL PRIVILEGES ON moodle.* to moodle@localhost identified by 'moodle';

Flush privileges

mysql> flush privileges;

Now all the Activities in mysql is completed. You can simply logout from the mysql using quit


Set Ownership and permission in DocumentRoot

We need to set the Owner and group of moodle as apache.Set 755 permission to the /var/www/html/moodle folder

#chown -R apache:apache /var/www/html/moodle
#chmod -R 755 /var/www/html/moodle

Installation of moodle from the browser

You can start the installation of moodle via browse http://Public_IP/moodle You will get a language selection page. You can set language as per your wish.

Cick Next button.You will get a page which will explain all details about Web address, Moodle directory, Data Directory

Then Click Next button. There is a probability of getting an error like Data directory (/var/www/moodledata) cannot be created by the installer.So We need to create /var/www/moodledata . This directory should be readable and writable by the web server user ('apache').

# mkdir /var/www/moodledata
# chown -R apache:apache /var/www/moodledata

Now the problem will solve and you can select database driver on here. We are using mysql as database. So don't need to change any option.

Click Next button, You need to input database details here.

 Click Next button, Then you will get a page, which will describe license of moodle, 

Click Continue to accept License. Then you will get a Server check page. If you are missing any packages here need to install it. If all requirements are okay, Then you will get a message "Your server environment meets all minimum requirements." in the bottom of the next page. Click Continue. Now installation is complete. You can setup admin details and use moodle site.

Moodle is successfully installed. You can use this as a course management system.

Leave a Comment