Deploy Chamilo LMS on Ubuntu 18.04 LTS

Chamilo is a widely adopted open-source learning management system (LMS) designed to facilitate e-learning and team-based collaboration globally.

This tutorial outlines the steps for installing the latest stable version of Chamilo on a server running Ubuntu 18.04 LTS.

System Requirements

  • A newly created Ubuntu 18.04 LTS 64-bit server instance. For production, at least 8GB of RAM is recommended. Example IP address: 203.0.113.1.
  • An account with sudo privileges.
  • The server has been fully updated to its latest stable release. For guidance, refer to official instructions.
  • A domain name such as chamilo.example.com correctly pointed to your server’s IP address.

Configure UFW Firewall Rules

In a production setting, it is essential to configure your UFW firewall to allow only incoming TCP connections on SSH, HTTP, and HTTPS ports. Use the following commands:


sudo ufw allow in ssh
sudo ufw allow in http
sudo ufw allow in https
sudo ufw enable


Install and Configure Apache 2.4 on Ubuntu 18.04

To set up the Apache web server on Ubuntu 18.04 LTS, use APT to install the most recent stable version with the command below:

sudo apt install -y apache2

Next, remove the default Apache welcome page to avoid exposing unnecessary content:

sudo mv /var/www/html/index.html /var/www/html/index.html.old

To enhance security, prevent Apache from displaying indexes of files and folders within the default web root directory /var/www/html:

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

Activate Apache’s rewrite module to support URL rewriting features required by many web applications:

Start Apache and enable it to automatically launch whenever the server boots up:

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

Install and Secure MariaDB 10.3 on Ubuntu 18.04

To begin, install the required packages and add the MariaDB repository to your system:

sudo apt install -y software-properties-common
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
sudo add-apt-repository 'deb [arch=amd64,arm64,ppc64el] http://mirrors.accretive-networks.net/mariadb/repo/10.3/ubuntu bionic main'
sudo apt update
sudo apt install -y mariadb-server

During the setup, you’ll be asked to define a strong password for the root user of MariaDB. Choose a secure one to ensure database safety.

Now start the MariaDB service and make sure it launches automatically on every reboot:

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

Run the MariaDB secure installation script to strengthen your database configuration:

sudo /usr/bin/mysql_secure_installation

When prompted by the script, answer each question as recommended below:

  • Enter current password for root (enter for none): your-MariaDB-root-password
  • Change the root password? [Y/n]: n
  • 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

Install PHP 7.2 and Required Extensions on Ubuntu 18.04

For optimal performance with Chamilo LMS, it’s best to use PHP 7.2 instead of older 5.x versions. A third-party PPA repository can be used to install the necessary PHP 7.2 components.

Begin by adding the ondrej/php PPA and updating the system packages:

sudo add-apt-repository -y ppa:ondrej/php
sudo apt update
sudo apt upgrade -y
sudo apt autoremove -y

Then install the PHP 7.2 core packages and required modules:

sudo apt install -y php7.2 php7.2-opcache php7.2-cli php7.2-curl php7.2-common php7.2-gd php7.2-intl php7.2-mbstring php7.2-mysql libapache2-mod-php7.2 php7.2-soap php7.2-xml php7.2-xmlrpc php7.2-zip php7.2-ldap php-apcu-bc

Next, create a backup of the Apache PHP configuration file and set the appropriate timezone setting:

sudo cp /etc/php/7.2/apache2/php.ini /etc/php/7.2/apache2/php.ini.bak
sudo sed -i 's#;date.timezone =#date.timezone = America/Los_Angeles#' /etc/php/7.2/apache2/php.ini

Note: Adjust the timezone value (e.g., America/Los_Angeles) to match your own region. A full list of supported timezones is available online.

Deploy Chamilo LMS on LAMP Stack

With your LAMP environment ready, you can now install Chamilo. This includes creating a dedicated MariaDB database, preparing Chamilo’s source files, tuning PHP, setting up a virtual host, completing browser-based configuration, and applying security hardening measures.

Create MariaDB Database and User

Access the MariaDB shell using the root account:

Inside the shell, create the Chamilo database and a user with full privileges:

CREATE DATABASE chamilo;
CREATE USER 'chamilouser'@'localhost' IDENTIFIED BY 'yourpassword';
GRANT ALL PRIVILEGES ON chamilo.* TO 'chamilouser'@'localhost' IDENTIFIED BY 'yourpassword' WITH GRANT OPTION;
FLUSH PRIVILEGES;
EXIT;

Note: Replace chamilo, chamilouser, and yourpassword with your own secure values.

Download and Prepare Chamilo LMS Files

Fetch the latest PHP 7.x-compatible Chamilo version from the official GitHub repository:

cd
wget https://github.com/chamilo/chamilo-lms/releases/download/v1.11.8/chamilo-1.11.8-php7.tar.gz

Extract the archive into the /opt directory:

sudo tar -zxvf chamilo-1.11.8-php7.tar.gz -C /opt

Create a symbolic link in the Apache web root directory to simplify future upgrades:

sudo ln -s /opt/chamilo-1.11.8-php7 /var/www/html/chamilo

Finally, change ownership of the Chamilo files to Apache’s default user and group to ensure proper permissions:


sudo chown -R www-data:www-data /opt/chamilo-1.11.8-php7


Install PHP 7.2 and Required Extensions

To ensure optimal performance of the Chamilo LMS, it’s advised to use PHP 7.2 instead of older PHP 5 versions. You can use a third-party repository to install the necessary packages.

First, add the ondrej/php repository and update your system:

sudo add-apt-repository -y ppa:ondrej/php
sudo apt update
sudo apt upgrade -y
sudo apt autoremove -y

Now install all required PHP 7.2 packages for Chamilo:

sudo apt install -y php7.2 php7.2-opcache php7.2-cli php7.2-curl php7.2-common php7.2-gd php7.2-intl php7.2-mbstring php7.2-mysql libapache2-mod-php7.2 php7.2-soap php7.2-xml php7.2-xmlrpc php7.2-zip php7.2-ldap php-apcu-bc

Create a backup of the PHP configuration file used by Apache and adjust the timezone setting:

sudo cp /etc/php/7.2/apache2/php.ini /etc/php/7.2/apache2/php.ini.bak
sudo sed -i 's#;date.timezone =#date.timezone = America/Los_Angeles#' /etc/php/7.2/apache2/php.ini

Note: Replace America/Los_Angeles with the correct timezone for your location. You can find the list of supported values online.

Create Chamilo Database and User

Login to MariaDB and create the Chamilo database and its dedicated user:

Inside the MariaDB shell, enter the following commands:

CREATE DATABASE chamilo;
CREATE USER 'chamilouser'@'localhost' IDENTIFIED BY 'yourpassword';
GRANT ALL PRIVILEGES ON chamilo.* TO 'chamilouser'@'localhost' IDENTIFIED BY 'yourpassword' WITH GRANT OPTION;
FLUSH PRIVILEGES;
EXIT;

Note: Replace chamilo, chamilouser, and yourpassword with your actual database details.

Download and Set Up Chamilo Files

Grab the latest Chamilo PHP 7 version from GitHub and extract it:

cd
wget https://github.com/chamilo/chamilo-lms/releases/download/v1.11.8/chamilo-1.11.8-php7.tar.gz
sudo tar -zxvf chamilo-1.11.8-php7.tar.gz -C /opt

Create a symbolic link to the Chamilo folder within Apache’s web root:

sudo ln -s /opt/chamilo-1.11.8-php7 /var/www/html/chamilo

Assign ownership of Chamilo files to Apache’s default user and group:

sudo chown -R www-data:www-data /opt/chamilo-1.11.8-php7

Adjust PHP 7.2 Configuration for Chamilo

Edit the same PHP config file and update several key settings:

sudo vi /etc/php/7.2/apache2/php.ini

Locate the following parameters:

  • session.cookie_httponly =
  • upload_max_filesize = 2M
  • post_max_size = 8M

And change them to:

  • session.cookie_httponly = 1
  • upload_max_filesize = 100M
  • post_max_size = 100M

Save the file and exit by typing :wq!.

Create Apache Virtual Host for Chamilo

Set up a new Apache virtual host configuration for the Chamilo site:

Be sure to replace example.com with your actual domain name.

 

Disable the default site and enable your new Chamilo site configuration:

sudo rm /etc/apache2/sites-enabled/000-default.conf
sudo ln -s /etc/apache2/sites-available/chamilo.conf /etc/apache2/sites-enabled/

Restart Apache to apply all changes:

sudo systemctl restart apache2.service

Complete the Chamilo Web Installation

Open your browser and visit http://chamilo.example.com. Follow the on-screen wizard:

  1. Installation Language: Choose your preferred language, like English, and click Next.
  2. Requirements: Ensure all requirements are fulfilled and click New Installation.
  3. License: Accept the GPL license, enter your contact info, and continue.
  4. Database Settings: Input your database details, check the connection, and proceed.
  5. Configuration: Update the admin password and fill in other fields as needed.
  6. Final Check: Confirm everything and click Install Chamilo.
  7. Finish: Click “Go to your newly created portal.”

Secure Chamilo Post Installation

Apply the following security measures after installation:

sudo chmod -R 0555 /var/www/html/chamilo/app/config
sudo rm -rf /var/www/html/chamilo/main/install

 

Conclusion

By following this detailed guide, you have successfully installed and configured Chamilo LMS on an Ubuntu 18.04 LTS server. From setting up the Apache web server and securing the MariaDB database, to tuning PHP 7.2 for optimal performance and finalizing the Chamilo installation via a web browser, every critical step has been covered.

This deployment not only ensures a robust and scalable e-learning platform, but also maintains security best practices and system efficiency. You are now ready to leverage Chamilo’s full potential for managing online courses, virtual classrooms, and collaborative learning environments.

Source: vultr.com

Create a Free Account

Register now and get access to our Cloud Services.

Posts you might be interested in: