Objective

The objective of this tutorial is to obtain a working Joomla installation based on a Lamp environment built on Ubuntu 18.04 Bionic Beaver.

Requirements

  • Root permissions

Difficulty

MEDIUM

Conventions

  • # - requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
  • $ - requires given linux commands to be executed as a regular non-privileged user

Introduction

joomla-logoJoomla is one of the most famous CMS (Content Management System): it is an open source project, released under the GPL license and, according to its developers, it powers over 2 Million websites, and it is translated in 74 languages. In this tutorial we will walk through the Joomla installation in a LAMP environment, built on Ubuntu 18.04 Bionic Beaver.

Preparing the Lamp environment

Before installing Joomla itself, we must install the needed packages to create and setup the LAMP environment. Let's proceed:
# apt-get update && apt-get install apache2 mariadb-{server,client} php php-xml php-mysql php-zip
The apache2 and mariadb services should be automatically enabled and started by the Ubuntu installation scripts. You can, however, verify that the services are active by running the following linux command:
$ systemctl is-active <service>
If the command above returns active, it means that the service is currently running.

SUBSCRIBE TO NEWSLETTER
Subscribe to Linux Career NEWSLETTER and receive latest Linux news, jobs, career advice and tutorials.


Setup a database

Our Joomla project needs a database to work. We are going to create it from mysql shell. First we login as the mysql root user:
# mysql -u root
At this point the mariadb shell prompt should appear. It's time to create our database, we will call it joomladb:
Mariadb [(none)]> CREATE DATABASE joomladb;
The database should have been created successfully, now we have to create an user and grant him the necessary privileges on it. We can do both things with just one instruction:
MariaDB [(none)]> GRANT SELECT,
    -> INSERT,
    -> UPDATE,
    -> DELETE,
    -> CREATE,
    -> DROP,
    -> INDEX,
    -> ALTER,
    -> CREATE TEMPORARY TABLES,
    -> LOCK TABLES
    -> ON joomladb.* TO 'testuser'@'localhost' IDENTIFIED BY 'testpassword';
We assigned the privileges listed above to the user testuser which is identified by the testpassword password: we will need those values during the Joomla guided setup. For the privileges to be effective we should reload their setup from the grant table in the mysql database. We can use the FLUSH statement to accomplish this task:
MariaDB [(none)]> FLUSH PRIVILEGES;
Finally we can exit mysql shell:
 MariaDB [(none)]> EXIT;

Change php settings

Joomla recommends to change some php settings in order to ensure the maximum compatibility and performance. Almost all of this recommendation are already fulfilled by the default php setup; the only thing we have to change is the state of the output_buffering option: by default it is set to 4096, but Joomla suggests to turn it off.

To change this setting we must operate on the /etc/php/7.1/apache2/php.ini file. We can open the file with an editor, find the setting and change its value, or we can do the needed modification using sed:
# sed -i 's/output_buffering = 4096/output_buffering = Off/' /etc/php/7.1/apache2/php.ini
For the change to become effective, we should now restart the apache2 daemon:
# systemctl restart apache2


Installing Joomla

Now that the LAMP environment is set, we can proceed with the actual Joomla installation. We are going to install the files in to the default VirtualHost document root, /var/www/html: this way, our site will be reachable at http://localhost address, or, if navigating from another machine in the same lan, by using the server ip address.

You can, of course, decide to install Joomla in a subdirectory of the path above, or to use a dedicated VirtualHost. Now, let's grab Joomla tarball and extract it into the said location:
$ wget https://downloads.joomla.org/cms/joomla3/3-8-3/Joomla_3-8-3-Stable-Full_Package.tar.gz?format=gz
# tar -C /var/www/html -xvzf Joomla*
The Joomla directory tree should have been extracted into /var/www/html. As a next step we should now delete the index.html file inside the same directory. This is the default apache welcome page used by Ubuntu: we don't need it anymore, and Joomla won't work if we don't remove it.
# rm /var/www/html/index.html
Now we should setup files and directories permissions. During the development stage we can just assign the ownership of the files to www-data:www-data: this way the web server will become the owner of all files and directories of the project. It's the easiest and fastest way to have the site up and running, however it's not a secure setup. The ideal thing would be to give the web server write privileges only where they are actually needed to minimize security risks.
# chown www-data:www-data -R /var/www/html
Now, launch your favorite browser and navigate to http://localhost, the Joomla installer should appear:

joomla-welcome

Joomla installer - Step 1: preliminary configuration

In this first page of the Joomla installer we should provide some preliminary information as the site language, the site name, and the site administrator details (email, username and password). We could also put a brief description of the site, however this is not mandatory. Once provided the needed information, we could click on the Next button to proceed further.

Joomla installer - Step 2: database information

The first thing we are prompted to choose is the mysql database driver: the Joomla default is MySQLi, however PDO can be used as an alternative. We must also provide the necessary information for Joomla to access the database we created earlier in this tutorial (hostname, username, password and database name):

joomla-db-setup

With the Old Database Process setting at the bottom of the page, we can choose whether to backup or remove any existing table from former Joomla installations; however, since this is the first time we use the CMS, it will make no difference to us. Time to move on, click on the "Next" button again.


Joomla installer - Step 3: finalization

In the third step of the Joomla installer we can select if we want to install some sample data (recommended) and if we want to receive an email containing our configuration settings:

joomla-overview

Further on, in the page, we will be presented with an overview of our setup choices and with the results of some pre-installation checks, which, if you followed this tutorial, should have all returned positive results (green), as you can see in the screenshot below:

joomla-overview-b

Last step is to click on the Install button. If all goes as expected, after the installation is finished, you should see a confirmation page, which will let you perform few remaining extra-steps like installing other languages, and, very important, removing the installation directory.

joomla-installed

Have fun with Joomla!
ARE YOU LOOKING FOR A LINUX JOB?
Submit your RESUME, create a JOB ALERT or subscribe to RSS feed on LinuxCareers.com.
LINUX CAREER NEWSLETTER
Subscribe to NEWSLETTER and receive latest news, jobs, career advice and tutorials.
DO YOU NEED ADDITIONAL HELP?
Get extra help by visiting our LINUX FORUM or simply use comments below.

You may also be interested in: