Wednesday, 13 February 2013

Installing Moodle in RHEL, CentOS



Greetings Everyone,

I am pretty sure that most of us know what moodle is and what it does. 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.

I will now start with the installation process.

  • First of all we need to have a clean RHEL, CentOS, Scientific Linux or Fedora machine with Apache server installed and you can refer it from my earlier blog LAMP or Apache Server installtion
  • Once you have finished installing Apache server we should proceed with moodle installation. Now, we need to download moodle and downloading moodle can be done in various ways but I would prefer downloading it from git. And, yes latest version currently that's the most stable and latest.
# cd /var/www/html

# git clone git://git.moodle.org/moodle.git

# cd moodle
# git branch -a
# git branch --track MOODLE_25_STABLE origin/MOODLE_25_STABLE
# git checkout MOODLE_25_STABLE  
  •  Now, lets create a data root for moodle and change permission and ownership
# mkdir /var/www/moodledata
# chown root:apache /var/www/moodledata
# chmod 770 /var/www/moodledata 
  •  We will be creating a utf8 database and yes, we are still using mysql 
# mysql -u root -p
# your-password
mysql> CREATE DATABASE moodle DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
mysql> GRANT ALL PRIVILEGES ON moodle.* to 'root'@'localhost' IDENTIFIED BY 'yourpassword';  
mysql> FLUSH PRIVILEGES;
mysql> quit 
  •  Lets navigate to /var/www/html/moodle and now we can do it in 2 different ways but I would prefer just copying config-dist.php to config.php or you could php install.php
  • Please do search in config.php and modify the place which are marked in RED below
# cd /var/www/html/moodle
          # cp config-dist.php config.php
# vim config.php
=========================================================================
// 1. DATABASE SETUP
//=========================================================================
// First, you need to configure the database where all Moodle data //
// will be stored. This database must already have been created //
// and a username/password created to access it. //
$CFG->dbtype = 'mysqli'; // 'pgsql', 'mysqli', 'mssql', 'sqlsrv' or 'oci'
$CFG->dblibrary = 'native'; // 'native' only at the moment
$CFG->dbhost = 'localhost'; // eg 'localhost' or 'db.isp.com' or IP
$CFG->dbname = 'moodle'; // database name, eg moodle
$CFG->dbuser = 'root'; // your database username
$CFG->dbpass = 'xxxxxx'; // your database password
$CFG->prefix = 'mdl_'; // prefix to use for all table names
$CFG->dataroot = '/var/www/moodledata';
$CFG->wwwroot = 'http://localhost/moodle';
  •  Once you have finished modifying /var/www/html/moodle/config.php. I am pretty sure everything is now ready to roll but lets fix permission before we browse and check it.
# chown -R root:apache /var/www/html/moodle
# chmod -R 770 /var/www/html/moodle 
  •  Now open your favorite browser and type in http://localhost/moodle, I am sure you should be seeing 
  • But in case you get "403 Forbidden Error", then try setting SELinux to permissive mode or Disable it

# setenforce 0
# getenforce (to check if its in permissive or enforcing mode)
 
  • Once you press continue, don't you worry it will perform server check and php extension and if you don't have you go back to terminal and install it


  • So let's install php extension (soap, xmlrpc and intl) and restart apache server
# yum install php-soap php-xmlrpc php-intl
# /etc/init.d/httpd restart 
  • Once these extensions are installed we are ready to rumble and the browser would look like this

  •  Finally, it will check if everything is working regarding moodle installation and create an account then your done.
  • Happy working with MOODLE


1 comment:

  1. Thanks a lot. Your blog has saved my One-Week time in trial and error.

    ReplyDelete