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://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
sudo add-apt-repository 'deb [arch=amd64,i386,ppc64el] http://mirror.jaleco.com/mariadb/repo/10.2/ubuntu 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:

mysql_secure_installation

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)]> FLUSH PRIVILEGES;
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:

wget https://downloads.joomla.org/us/cms/joomla3/3-8-5/Joomla_3-8-5-Stable-Full_Package.zip

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/my.joomla.site
sudo unzip Joomla_3-8-5-Stable-Full_Package.zip -d /var/www/my.joomla.site

Finally change ownership of the directory /var/www/my.joomla.site per user www-data:

sudo chown -R www-data: /var/www/my.joomla.site

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/my.joomla.site
server {
    listen 80;
    server_name my.joomla.site;
    root /var/www/my.joomla.site;

    index index.html index.htm index.php;

    charset utf-8;

    access_log /var/log/nginx/my.joomla.site.access.log;
    error_log /var/log/nginx/my.joomla.site.error.log 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/my.joomla.site /etc/nginx/sites-enabled/my.joomla.site

Checking the Nginx configuration and restarting Nginx:

sudo nginx -t
sudo service nginx restart

Open the address http://my.joomla.site/in 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 (https://docs.joomla.org/).

Sidebar