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 nameTo 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.: 188.8.131.52 cham1.beeznest.com
Step 3: Connect and install software stackUbuntu 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
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 HostSince 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 184.108.40.206 (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://220.127.116.11 (the IP of this virtual machine) and follow the installation process (see your chamilo user, password and database name in the "GRANT" command above)
Extra: Setting it up with NginxIf 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
Other Cloud providersThe 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.10Installing 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-apcuAnd replace the Allow lines of Apache2 by "Require all granted", as commented above.
If you want to host PHP based sites on Digitalocean, I would recommend you to try out Cloudways PHP website hosting (https://www.cloudways.com/en/php-cloud-hosting.php ) on cloud. This platform is quite fast and secure. Also, you can deploy PHP apps on the server in one click using this platform.