How to install Joomla 3 on Ubuntu 16.04

In this article, we will explain how to install Joomla on Ubuntu 16.04 with MariaDB 10.2, PHP-FPM 7.1 and Nginx. Joomla is an open source content management system (CMS) for publishing web content written in PHP. Joomla is one of the most popular CMS and is used worldwide to power millions of websites of all shapes and sizes. This guide should work just as well on other Linux VPS systems, but has been tested and written for an Ubuntu 16.04 VPS.

Before you start

Updating the system and installing the required packages

sudo apt update && sudo apt -y upgrade
sudo apt install software-properties-common nano

Installing MariaDB 10.2

If you already have MySQL or MariaDB installed, you can skip this step and move on to the next section.

To add the MariaDB repository to the source list and install the latest MariaDB server, run the following commands:

sudo apt-key adv --recv-keys --keyserver hkp:// 0xF1656F24C74CD1D8
sudo add-apt-repository 'deb [arch=amd64,i386,ppc64el] xenial main'
sudo apt update
sudo apt install -y mariadb-server

Installation protection

When the installation is complete, run the following command to ensure protection:


Creating a new database

Create a new database and user for Joomla installation using the following commands:

mysql -uroot -p
MariaDB [(none)]> CREATE DATABASE joomla;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON joomla.* TO 'joomla'@'localhost' IDENTIFIED BY 'strongpassword';
MariaDB [(none)]> q

Install PHP 7.1

PHP version 7.1 is not available in the default Ubuntu16.04 repository, so we will be using Ondrej’s PPA.

sudo add-apt-repository ppa:ondrej/php
sudo apt update

After you enable Ondrej’s PPA, you can proceed and install PHP 7.1 and all required PHP modules using the following command:

sudo apt install php7.1-fpm php7.1-cli php7.1-gd php7.1-opcache php7.1-mysql php7.1-json php7.1-mcrypt php7.1-xml php7.1-curl

Installing Joomla

Installing Joomla is pretty easy and straightforward, first download the Joomla zip archive from the Joomla download page:


After the download is complete, unzip the archive and move the extracted files to the directory /var/www/my.joomla.sitewhich will be the root directory of your new Joomla site:

sudo mkdir -p /var/www/
sudo unzip -d /var/www/

Finally change ownership of the directory /var/www/ per user www-data:

sudo chown -R www-data: /var/www/

Installing and configuring Nginx

If you don’t have Nginx installed on your server, you can install the latest stable version from the official Ubuntu repositories:

sudo apt -y install nginx

Then create a new Nginx server block:

sudo nano /etc/nginx/sites-available/
server {
    listen 80;
    root /var/www/;

    index index.html index.htm index.php;

    charset utf-8;

    access_log /var/log/nginx/;
    error_log /var/log/nginx/ info;

    location / {
        try_files $uri $uri/ /index.php?$args;

    location ~* /(images|cache|media|logs|tmp)/.*.(php|pl|py|jsp|asp|sh|cgi)$ {
        return 403;
        error_page 403 /403_error.html;

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    error_page 404 /index.php;

    location ~ .php$ {
        fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include /etc/nginx/fastcgi.conf;

    location ~ /.(?!well-known).* {
        deny all;

Activate the server block by creating a symbolic link:

sudo ln -s /etc/nginx/sites-available/ /etc/nginx/sites-enabled/

Checking the Nginx configuration and restarting Nginx:

sudo nginx -t
sudo service nginx restart

Open the address your favorite web browser and follow the onscreen instructions to complete the Joomla installation.

That’s all. You have successfully installed Joomla on Ubuntu 16.04. For more information on how to manage your Joomla installation, please refer to the official Joomla documentation (

Related Posts