This guide will take you through the process of installing the Chamilo e-learning portal, version 1.11.4 on a fresh Digital Ocean instance,on an Ubuntu 17.04 64bit distribution (also works with minor changes with Ubuntu 18.04)
To follow this guide, you should be familiar with the notion of SSH keys and installing/configuring server software on Ubuntu 16.*, 17.* or 18.*.
Previous articles on this blog explain how to install Chamilo 1.9 using Juju Charms, how to install 1.10.2 on Ubuntu 15.10, and 1.10.* on Ubuntu 16.04. The packages available on Ubuntu 17.04 being slightly different, we decided to write this guide to make sure the package could be installed easily by anyone with a minimum of technical skills and a will to learn.
Step 1: Get a Digital Ocean instance
- If you don’t have one, create an account on Digital Ocean
- Give a credit card account or make a payment through PayPal (you might not need it for the first few bucks you’ll need to follow this guide)
- Create a (cheap) instance of 1GB RAM ($10/month) with Ubuntu 17.04 x64.
- Give an SSH key so that you can connect to your instance with “ssh root@[instance-ip]”
Step 2: Setup temporary domain name
To make it short, we’ll just define the new instance’s IP as a local name on our computer only. You can also use the IP directly, but I prefer using a name.
- edit your local computer’s /etc/hosts file (on Windows, C:\Windows\System32\drivers\etc\hosts),
- add the instance IP, a blank space, and a name you want to give it. e.g.: 18.104.22.168 cham1.beeznest.com
In my case, I have IP 22.214.171.124 and name cham1.beeznest.com, but in the following guide we will assume (for simplicity) that we use the IP address directly.
If you later want to add support for HTTPS, you *will* need a domain or sub-domain name.
Step 3: Connect and install software stack
Ubuntu 17.04 now comes officially with PHP 7(.0), so there’s not much to do in that respect, except installing them. Launch the following commands in sequence:
- apt-get update && apt-get -y upgrade
- apt-get install apache2 libapache2-mod-php7.0 mariadb-client mariadb-server php-pear php7.0-dev php7.0-gd php7.0-curl php7.0-mcrypt php7.0-intl php7.0-mysql php7.0-mbstring php7.0-zip php7.0-xml
- For Ubuntu 18.04, PHP 7.2 is the default PHP version, so use the command without version, and remove mcrypt which doesn’t exist anymore:
- apt-get install apache2 libapache2-mod-php mariadb-client mariadb-server php-pear php-dev php-gd php-curl php-intl php-mysql php-mbstring php-zip php-xml
- give a MySQL root password twice (remember it) and confirm every other question asked
This whole step takes about 2.5 minutes in total on Digital Ocean’s super fast infrastructure.
Step 4: Downloading from Github
- cd /var/www
- mkdir chamilo
- cd chamilo
- wget https://github.com/chamilo/chamilo-lms/archive/v1.11.4.tar.gz
- tar zxf v1.11.4.tar.gz
- mv chamilo-lms-1.11.4 www
- cd www
- chmod -R 0777 main/lang main/default_course_document/images/ app web
Step 5: Database
- mysql -u root -p
- [give the mysql root password]
- mysql> GRANT ALL PRIVILEGES ON chamilo.* TO chamilo@localhost IDENTIFIED BY ‘chamilo’;
- mysql> FLUSH PRIVILEGES;
- mysql> exit;
Step 6: Configure Apache’s Virtual Host
Since version 1.10 of Chamilo, it is *mandatory* that your web server handles some redirections, which is done the easiest by doing the following (in the case of Apache).
- cd /etc/apache2/sites-available/
- vim 000-default.conf (or use another editor if you like)
- Under the #ServerName line, add: ServerName 126.96.36.199 (or the IP of this virtual machine, or the name you’ve given it in /etc/hosts)
- [change /var/www by /var/www/chamilo/www everywhere]
- Add the following block anywhere *inside* the VirtualHost block (if using Apache 2.4, use “Require all granted” instead of the “Order allow,deny” and “allow from all” lines.
<Directory /var/www/chamilo/www> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> php_admin_value date.timezone "Europe/London"
- exit (esc + :wq + enter)
- a2enmod rewrite
- service apache2 restart
Step 7: Browser install of Chamilo
- Open your browser on http://188.8.131.52 (the IP of this virtual machine) and follow the installation process (see your chamilo user, password and database name in the “GRANT” command above)
That’s all, folks! Don’t forget this is a development-type installation, meaning that some things will not be tuned for production environments. If you need production-ready installations, the BeezNest team is available for hiring.
Extra: Setting it up with Nginx
If you want to use HTTP2, you will have to use Nginx. Using Nginx adds a few complicated steps to this procedure, so let’s see what can be done here…
- apt-get remove apache2
- apt-get install nginx-full php7.0-fpm
- vim /etc/nginx/sites-available/default
- change “root” from /var/www/html to /var/www/chamilo/www
- use https://campus.chamilo.org/documentation/installation_guide.html to copy-paste the configuration block for Nginx, only replacing /var/run/php5-fpm.sock by /var/run/php/php7.0-fpm.sock
- vim /etc/php/7.0/fpm/pool.d/www.conf
- add “php_admin_value[date.timezone] = “Europe/Paris” at the end
- vim /etc/php/7.0/fpm/conf.d/10-opcache.ini
- add a line “opcache.enable 1”
- service nginx restart
- service php7.0-fpm restart
To enable HTTP2 support (which, by the way, will only work with HTTPS at this time), change “listen 443 ssl” to “listen 443 ssl http2”. This also means that your server will be *required* to have a domain name (in this guide we essentially used an IP address to install Chamilo), and that you will *need* an SSL certificate (you can get one for free from letsencrypt.org, but that’s not very easy with Nginx as of April 2016).
Because of the inherent restrictions of HTTP2 in terms of security, it is mandatory to configure the port 443 section of your Nginx config in a highly-secured manner. You can use the cipherli.st page to copy-paste most of the config (you’ll need to adjust to your Nginx version, though).
In any case, HTTP2 will require TLS >= 1.2. Just remember that.
Other Cloud providers
The procedure above (with some minor changes) is pretty much the same on a Google Cloud Compute instance and (to some extent) on an AWS EC2 instance, on Azure, etc.
Installing on Ubuntu 17.10
Installing on the next version of Ubuntu is almost the same. Just replace the apt-get install command by this one:
apt-get install apache2 libapache2-mod-php mariadb-client mariadb-server php-pear php-dev php-gd php-curl php-mcrypt php-intl php-mysql php-mbstring php-zip php-xml php-apcu
And replace the Allow lines of Apache2 by “Require all granted”, as commented above.