Read in 6 minutes

last updated 

How to Install Joomla with Apache on Ubuntu 18.04

Joomla is one of the most popular open source content management systems that powers hundreds of thousands of websites. It is written in PHP and packs a ton of features that can be extended with free and premium extensions and themes. With Joomla, you can easily build your eCommerce store, personal website, social site or blog.

In this tutorial, we will explain how to install Joomla on Ubuntu 18.04. We’ll be using a LAMP stack with Apache as a web server, SSL certificate, the latest PHP 7.2 and MySQL/MariaDB as a database server.

Prerequisites

Ensure the following prerequisites are met before continuing with this tutorial:

  • Have a domain name pointing to your server public IP. We will use example.com.
  • Logged in as a user with sudo privileges.
  • Apache installed by following these instructions.
  • You have an SSL certificate installed for your domain. You can install a free Let’s Encrypt SSL certificate by following these instructions.

Creating a MySQL database

Joomla can store its data such as articles, categories, users, extensions and themes settings in a MySQL, PostgreSQL or MS SQL database.

We’ll use MySQL as the back-end database. If you don’t have MySQL installed on your Ubuntu server you can install it by typing:

sudo apt-get update
sudo apt-get install mysql-server

Login to the MySQL console by typing:

sudo mysql

From within the MySQL shell, run the following SQL statement to create a database:

CREATE DATABASE joomla CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;

Next, create a new MySQL user and grant privileges to this user on the new database:

GRANT ALL ON joomla.* TO 'joomlauser'@'localhost' IDENTIFIED BY 'change-with-strong-password';

Once done, exit the mysql console by typing:

EXIT

Installing PHP

PHP 7.2 which is the default PHP version in Ubuntu 18.04 is fully supported and recommended for Joomla.

Install PHP all required PHP extensions with the following command:

sudo apt update
sudo apt install php7.2 php7.2-cli php7.2-mysql php7.2-json php7.2-opcache php7.2-mbstring php7.2-intl php7.2-xml php7.2-gd  php7.2-zip php7.2-curl php7.2-xmlrpc php7.2-xmlrpc

Set the recommended PHP options:

sudo sed -i "s/memory_limit = .*/memory_limit = 512M/" /etc/php/7.2/apache2/php.ini
sudo sed -i "s/upload_max_filesize = .*/upload_max_filesize = 256M/" /etc/php/7.2/apache2/php.ini
sudo sed -i "s/post_max_size = .*/post_max_size = 256M/" /etc/php/7.2/apache2/php.ini
sudo sed -i "s/output_buffering = .*/output_buffering = Off/" /etc/php/7.2/apache2/php.ini
sudo sed -i "s/max_execution_time = .*/max_execution_time = 300/" /etc/php/7.2/apache2/php.ini
sudo sed -i "s/;date.timezone.*/date.timezone = UTC/" /etc/php/7.2/apache2/php.ini

Restart apache so the newly installed PHP extensions are loaded:

sudo systemctl restart apache2

Downloading Joomla

At the time of writing this article, the latest version of Joomla is version 3.9.4.

Before downloading the Joomla archive, first create a directory that will hold the Joomla files and navigate to it:

sudo mkdir -p /var/www/example.com
cd /var/www/example.com

Next, download the current release of Joomla from the Joomla downloads page using the following wget command:

sudo wget https://downloads.joomla.org/cms/joomla3/3-9-4/Joomla_3-9-4-Stable-Full_Package.zip

Once the download is complete, unzip the archive and move the files into the domain’s document root directory:

sudo unzip Joomla_3-9-4-Stable-Full_Package.zip

Change the directory’s owner to www-data using the chown command so that the web server can have full access to the site’s files and directories:

sudo chown -R www-data: /var/www/example.com

Configuring Apache

By now, you should already have Apache with SSL certificate installed on your system, if not check the prerequisites for this tutorial.

The next step is to edit the Apache virtual hosts configuration:

sudo nano /etc/apache2/sites-available/example.com.conf

The following Apache configuration redirects http to https and www to non-www version of your domain and enables HTTP2. Don’t forget to replace example.com with your Joomla domain and set the correct path to the SSL certificate files.

/etc/apache2/sites-available/example.com.conf
<VirtualHost *:80>
  ServerName example.com
  ServerAlias www.example.com

  Redirect permanent / https://example.com/
</VirtualHost>

<VirtualHost *:443>
  ServerName example.com
  ServerAlias www.example.com

  Protocols h2 http:/1.1

  <If "%{HTTP_HOST} == 'www.example.com'">
    Redirect permanent / https://example.com/
  </If>

  DirectoryIndex index.html index.php
  DocumentRoot /var/www/example.com

  ErrorLog ${APACHE_LOG_DIR}/example.com-error.log
  CustomLog ${APACHE_LOG_DIR}/example.com-access.log combined

  SSLEngine On
  SSLCertificateFile /etc/letsencrypt/live/example.com/cert.pem
  SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
  SSLCertificateChainFile /etc/letsencrypt/live/example.com/chain.pem

  <Directory /var/www/example.com>
      Options FollowSymLinks
      AllowOverride All
      Require all granted
  </Directory>

</VirtualHost>

If not enabled, enable the virtual host for the domain. This command will create a symbolic link from the sites-available to the sites-enabled directory:

sudo a2ensite example.com

For the new configuration to take effect, restart the Apache service by typing:

sudo systemctl restart apache2

Completing the Joomla Installation

Now that Joomla is downloaded and the server configuration is complete, it is time to finalize the Joomla installation using the web interface.

Open your browser, type your domain and a screen similar to the following will appear:

Select the language you would like to use and fill in the following information:

  • Site Name - The name of your new Joomla website.
  • Description - Description of the website. This is a fallback meta description that will be used on every page without a specific description.
  • Admin Email Address - The administrative user email address. Use a valid email. In case you forget your password you’ll receive a link to change the password at this email address.
  • Admin Username - The username of the administrative user. For security purposes, set the username to something else than “admin”.
  • Admin Password - The administrative user password. Make sure you use a strong password. Enter the same password in the Confirm Admin Password field.
  • Site Offline - Leave the default “No”. If you select “Yes”, once the installation is complete, the website will show “Site is offline”.

When finished, click on the “Next” button.

On the next screen, the setup wizard will ask you to enter your database connection details.

  • Database Type - Leave the default “MySQLi”.
  • Hostname - Leave the default “localhost”. If this tutorial the database is located on the same server.
  • Username, Password, Database Name - Enter the MySQL user and database details you previously created.
  • Table Prefix - Leave the automatically generated prefix.
  • Old Database Process - Leave the default “Backup” option.

Once you click on the “Next” button you’ll be redirected to the Overview page:

Here you can select to install sample data and verify that all checks are passed. Click on the Install button and once the installation is completed you will be taken to a page informing you that Joomla has been installed.

If you want to install additional languages click on the “Extra steps: Install languages” button.

For security reasons, you’ll need to delete the installation directory. To do so, go back to the terminal and enter the following command:

sudo rm -rf /var/www/example.com/installation

To access your Joomla back-end click on the Adminstrator button. From here you can start customizing your Joomla installation by installing new themes and plugins.

Conclusion

Congratulations, you have successfully installed Joomla with Apache on your Ubuntu 18.04 server. Joomla Documentation is a good starting place to learn more about how to get started with your new Joomla site.

If you have questions feel free to leave a comment below.