How to Install Joomla on Ubuntu 22.04

Joomla is a free and open-source content management system for publishing web content on websites. Web content applications include discussion forums, photo galleries, e-Commerce, and user communities, and numerous other web-based applications.

Let us first check for any pending updates in the Ubuntu server and install if any are available.

apt update

apt upgrade

LAMP Stack Configuration

Joomla like any other CMS application, will require a web server with Database running on the system to support it. And since Joomla is built on PHP, we will need to install PHP as well.

Install Apache and PHP

We will now install Apache and PHP and other supporting packages by running the below command,

apt install apache2 libapache2-mod-php openssl php-imagick php-gd php-imap php-intl php-json php-ldap php-mbstring php-mysql php-pgsql php-smbclient php-ssh2 php-sqlite3 php-xml php-zip

Verify apache version using below command,

apache2 -version

Output:

root@crown:~# apache2 -version
Server version: Apache/2.4.52 (Ubuntu)
Server built:   2022-03-25T00:35:40

Now start and enable the Apache Web server,

systemctl start apache2 
systemctl enable apache2

Verify Apache is up and running using below command,

systemctl status apache2

Output:

root@crown:~# systemctl status apache2
● apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: active (running) since Fri 2022-04-08 18:34:36 UTC; 2h 21min ago
       Docs: https://httpd.apache.org/docs/2.4/
   Main PID: 659 (apache2)
      Tasks: 7 (limit: 1034)
     Memory: 14.0M
        CPU: 669ms
     CGroup: /system.slice/apache2.service
             ├─ 659 /usr/sbin/apache2 -k start
             ├─ 680 /usr/sbin/apache2 -k start
             ├─ 681 /usr/sbin/apache2 -k start
             ├─ 682 /usr/sbin/apache2 -k start
             ├─ 690 /usr/sbin/apache2 -k start
             ├─ 691 /usr/sbin/apache2 -k start
             └─1603 /usr/sbin/apache2 -k start

Open server IP address on your browser(http://Server_Ip) to see default Apache page.

Note: Replace "Server_Ip" with actual Ip address of the server.

images

Verify PHP using below command

php -v  

Output:

root@crown:~# php -v
PHP 8.1.4 (cli) (built: Apr  4 2022 13:36:22) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.4, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.4, Copyright (c), by Zend Technologies

Install MariaDB

Let us install MariaDB on the server now with the following command,

apt install mariadb-server

MariaDB is not secured by default, As a precaution, we are secure the database engine using below command.

mysql_secure_installation

Create a Joomla Database

Login to MariaDB using the command

mysql -u root -p

Let us configure the Database so Joomla can connect to it and store the data.

For this, we will create a Database, create a User and grant certain Privileges to the User. Refer the below commands for the usecase.

MariaDB [(none)]> CREATE DATABASE joomla;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON joomla.* TO 'joomla'@'localhost' IDENTIFIED BY  'StrongPassword';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;

Download and Extract Joomla

We will now download the latest version of Joomla from the Official site.

Download Joomla in Ubuntu using below command,

wget https://github.com/joomla/joomla-cms/releases/download/4.1.2/Joomla_4.1.2-Stable-Full_Package.zip

Once the download is complete. We need to unzip this to the /var/www/html/ directory. Make the directory called Joomla.

mkdir /var/www/html/joomla

Unzip the zipped Joomla file to ‘Joomla’ directory created above.

unzip Joomla_4.1.2-Stable-Full_Package.zip -d /var/www/html/joomla

After unzip, Set the directory ownership of the directory to Apache user and change the permissions using below command,

chown -R www-data:www-data /var/www/html/joomla
chmod -R 755 /var/www/html/joomla

Restart Apache Web server using following command,

systemctl restart apache2 

Configuring Apache for Joomla

Configure the Apache webserver to serve Joomla webpages. For this create a virtual host's file for Joomla and name it joomla.conf,

nano /etc/apache2/sites-available/joomla.conf

Add the following content into the file

<VirtualHost *:80>
 ServerAdmin admin@example.com
 DocumentRoot /var/www/html/joomla/
 ServerName example.com
 ServerAlias www.example.com

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

 <Directory /var/www/html/joomla/>
        Options FollowSymlinks
        AllowOverride All
        Require all granted
 </Directory>
</VirtualHost>

Save and exit the file,

Replace example.com with your actual domain name.

Enable the virtual host file,

a2ensite joomla.conf
a2enmod rewrite

After this Restart Apache Webserver using below command,

systemctl restart apache2

Open your browser to load the site, http://example.com.

Install SSL Certificate

Let us install the SSL Certificate from Let's Encrypt. For this, you will need to install certbot via snapd.

Installing snapd,

apt install snapd

Check the snapd for updates,

snap install core; sudo snap refresh core

Install Certbot

snap install --classic certbot

ln -s /snap/bin/certbot /usr/bin/certbot

Since we're using Apache web server, run the below command to get the certificate,

certbot --apache

The Certbot will take care of your renewal automatically before they expire, you would have to run the certbot again only if you make changes to your configuration. You can perform a test run with below command,

certbot renew --dry-run

Next, reload the page on the browser and it should then redirect and load the HTTPS site https://example.com.

Joomla Configuration

On the browser, we will configure the remaining aspects of getting our Joomla CMS up and running

Upon loading the domain, you will be prompted with setting up Language and Site Name

images

Enter the required details such as Username, User Account, Super User Password, and Email Address, and click on Setup Database Connection button

images

Enter the Database information that was configured earlier,

images

images

Enter the username and password which was set earlier,

images

View of the Dashboard after loggin in,

images

Done! This concludes the topic of installing latest version of Joomla on Ubuntu 22.04.