Install CMS Moodle on Ubuntu 18.04 Server with Apache2, MariaDB and PHP Support at Cloud Kilat

This is my first time i am completing my learning on OS Linux thing. Usually on my previous job i am only playing with OS Windows, SharePoint, IIS , and so on. Every thing mostly around Microsoft area.

I recently got a Virtual Machine Cloud Kilat Ubuntu 18.04 LTS Server. Just know this OS Server same like OS Windows Core, there are no any GUI UI.  So everything that we can do is do scripting or syntax command.

I decided on this virtual machine, i will install CMS Moodle, Apache2, Mariadb as Database Storage and also PHP 7.1.

Herewith the following steps that i did it to install  Moodle CMS :

1.Install Apache as Web Server

sudo apt update
sudo apt-get install apache2

After installing Apache2, run the commands below to disable directory listing.

sudo sed -i "s/Options Indexes FollowSymLinks/Options FollowSymLinks/" /etc/apache2/apache2.conf

Next, run the commands below to stop, start and enable Apache2 service to always start up with the server boots.

sudo systemctl stop apache2.service
sudo systemctl start apache2.service
sudo systemctl enable apache2.service

2.Install Mariadb Database

sudo apt-get install mariadb-server mariadb-client

After installing, the commands below can be used to stop, start and enable MariaDB service to always start up when the server boots.

sudo systemctl stop mariadb.service
sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service

After that, run the commands below to secure MariaDB server.

sudo mysql_secure_installation

When prompted, answer the questions below by following the guide.

  • Enter current password for root (enter for none): Just press the Enter
  • Set root password? [Y/n]: Y
  • New password: Enter password
  • Re-enter new password: Repeat password
  • Remove anonymous users? [Y/n]: Y
  • Disallow root login remotely? [Y/n]: Y
  • Remove test database and access to it? [Y/n]:  Y
  • Reload privilege tables now? [Y/n]:  Y

After that, open MariaDB default configuration file by running the commands below:

sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf

Then add the below lines just below [mysqld] section.

default_storage_engine = innodb
innodb_file_per_table = 1
innodb_file_format = Barracuda
innodb_large_prefix = 1

Save the file and exit.

Restart MariaDB server

sudo systemctl restart mysql.service

3. Install PHP 7.1 and Related Modules

udo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php

Then update and upgrade to PHP 7.1

sudo apt update

Finally, run the commands below to install PHP 7.1 and related modules..

sudo apt install php7.1 libapache2-mod-php7.1 php7.1-common php7.1-mbstring php7.1-xmlrpc php7.1-soap php7.1-gd php7.1-xml php7.1-intl php7.1-mysql php7.1-cli php7.1-mcrypt php7.1-ldap php7.1-zip php7.1-curl

After install PHP, run the commands below to open PHP-FPM default file.

sudo nano /etc/php/7.1/apache2/php.ini

Then change the following lines below in the file and save. You may increase the value to suite your environment.

file_uploads = On
allow_url_fopen = On
memory_limit = 256M
upload_max_filesize = 100M
max_execution_time = 360
cgi.fix_pathinfo = 0
date.timezone = America/Chicago

4.Create Database Moodle

Run the commands below to logon to MariaDB database server

sudo mysql -u root -p

Then create a database called moodle

CREATE DATABASE moodle;

Create a database user called moodleuser with new password

CREATE USER 'moodleuser'@'localhost' IDENTIFIED BY 'new_password_here';

Then grant the user full access to the database.

GRANT ALL ON moodle.* TO 'moodleuser'@'localhost' IDENTIFIED BY 'user_password_here' WITH GRANT OPTION;

Finally, save your changes and exit.

FLUSH PRIVILEGES;
EXIT;

5. Download Moodle Latest Release

cd /tmp && wget https://download.moodle.org/download.php/direct/stable33/moodle-latest-33.tgz

Then run the commands below to extract the downloaded file to Apache2 default root.

tar -zxvf moodle-latest-33.tgz
sudo mv moodle /var/www/html/moodle
sudo mkdir /var/www/html/moodledata

Change modify the directory permission.

sudo chown -R www-data:www-data /var/www/html/moodle/
sudo chmod -R 755 /var/www/html/moodle/
sudo chown www-data /var/www/html/moodledata

6. Download Moodle Latest Release

cd /tmp && wget https://download.moodle.org/download.php/direct/stable33/moodle-latest-33.tgz

Then run the commands below to extract the downloaded file to Apache2 default root.

tar -zxvf moodle-latest-33.tgz
sudo mv moodle /var/www/html/moodle
sudo mkdir /var/www/html/moodledata

Change modify the directory permission.

sudo chown -R www-data:www-data /var/www/html/moodle/
sudo chmod -R 755 /var/www/html/moodle/
sudo chown www-data /var/www/html/moodledata

 

7. Configure Apache 2 for Moodle

sudo nano /etc/apache2/sites-available/moodle.conf

Then copy and paste the content below into the file and save it. Replace the highlighted line with your own domain name and directory root location.

     ServerAdmin admin@testing.com
     DocumentRoot /var/www/html/moodle/
     ServerName testingjoomla.com
     ServerAlias www.testingjoomla.com
 
     
        Options +FollowSymlinks
        AllowOverride All
        Require all granted
     

     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined


Save the file and exit.

8.Configure Apache 2 for Moodle

sudo a2enmod rewrite
sudo a2ensite moodle.conf

9.  Fix Moodle Database MySQL Version 5.5.31 Is Required

When you install or update Moodle you receive the following error:

Database MySQL Version 5.5.31 Is Required And You Are Running 5.5.5.10.1.17

Moodle will not install or update.

sudo nano /var/www/html/moodle/config.php

Change $CFG->dbtype from mysqli to mariadb

joomla

10. Restart Apache2
sudo systemctl restart apache2.service

After that, open your browser and browse to the server IP address or hostname and you should see Moodle default setup wizard page and do all the wizard joomla installation.

After all installation done, we can see the sample Joomla Dashboard like this :

joomla2

 

Happy sharepoint-ing.

 

One thought on “Install CMS Moodle on Ubuntu 18.04 Server with Apache2, MariaDB and PHP Support at Cloud Kilat

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.