HOW TO: Install Moodle 3.0 - 3.5 in CentOS 6/7

Here are the commands for installing Moodle 3.0 - 3.5 in CentOS 6/7.

1. Update your System

$ yum update -y$ sudo yum update -y  (for Ubuntu 16.04/18.04)
2. Install required LAMP(Linux, Apache, MySQL, phpmyadmin) version on CentOS 6/7

$ yum install httpd mariadb mariadb-server php php-mysql $ sudo
yum install httpd mariadb mariadb-server php php-mysql (for Ubuntu 16.04/18.04) $ yum install php-iconv php-mbstring php-curl php-openssl php-tokenizer php-xmlpc php-soap php-ctype php-zip php-gd php-simplexml php-spl php-pcre php-dom php-xml php-intl php-json php-ldap php-pecl-apc
(use sudo for Ubuntu 16.04/18.04)
Start httpd and mysql services for CentOS
$ systemctl enable httpd
$ systemctl start  httpd
$ systemctl enable mariadb
$ systemctl start MariaDB
(use sudo for Ubuntu 16.04/18.04)

$ sudo service httpd restart
$ sudo service MariaDB restart

Create root admin password of MySQL, or later you can configure the path,  username and password of DB in Moodle/config.php. Also, you need to create a config.php file if it's not created during Moodle installation. The file will be available as config-dist.php. At the end of the commands you can find the config.php file and edit them according to the path and other credentials.
# mysqladmin -u  root password password


Create a database and a database user and assign all privileges to that newly created database user.
Sample output
# mysql -u root -p 
MariaDB [(none)]> create database moodle;
MariaDB [(none)]> create user 'unixmen'@'localhost' identified by 'password';
MariaDB [(none)]> grant all priviledges on moodle.* to 'unimxmen'@'localhost';
MariaDB [(none)]> flush privileges;
MariaDB [(none)]> exit
Bye



Download latest version of Moodle, replace accordingly like 3.0 - 3.5. Here I've installed Moodle 3.4v.
$ cd  /var/www/html
$ wget https://download.moodle.org/stable34/moodle-3.4.tgz
$ tar -xvf moodle-3.4.tgz
$ chown -R apache:apache /var/www/html/moodle
$ chmod -R 755 /var/www/html/moodle

(use sudo for Ubuntu 16.04/18.04)
In next step you've to create moodledata folder which will be used by Moodle to store caches and data for later migration usage. Under /var/www/ make a folder as  ‘moodledata’ which will be used by moodle, change permissions (chmod) and ownership (chown) for that directory as required.
$ cd /var/www/
$ mkdir moodledata 
$ chmod -R 755 /var/www/moodledata
$ chown -R apache:apache /var/www/html/moodledata


Restart httpd services or apache
$ systemctl restart httpd
$ sudo service apache2/httpd restart ----> for Ubuntu
/var/www/html/moodle/config.php
<?php  // Moodle configuration file
unset($CFG);
global $CFG;
$CFG = new stdClass();
$CFG->dbtype    = 'mysqli';
$CFG->dblibrary = 'native';
$CFG->dbhost    = 'localhost';
$CFG->dbname    = moodle;
$CFG->dbuser    = 'username';
$CFG->dbpass    = 'password';
$CFG->prefix    = 'mdl_';
$CFG->dboptions = array (
  'dbpersist' => 0,
  'dbport' => '',
  'dbsocket' => '',
  'dbcollation' => 'utf8mb4_general_ci',
);
$CFG->wwwroot   = 'http://localhost/moodle';
$CFG->dataroot  = '/var/www/moodledata';
$CFG->admin     = 'admin';
$CFG->directorypermissions = 0777;
require_once(__DIR__ . '/lib/setup.php');
// There is no php closing tag in this file,
// it is intentional because it prevents trailing whitespace problems!

Comments

Popular Posts