How to Install Joomla with Apache and Let’s Encrypt SSL on Debian 11

0

Joomla! is a popular Content Management system (CMS) that comes to mind when you are looking for an alternative to WordPress. With Joomla, you can create blogs, discussion forums, and other websites.

It is free, open-source, and works well on almost any web hosting service, making it one of the easiest to install and use.

If you do not have any web hosting yet, you can install Joomla on your local Debian system or VPS.

Here, we will see how to install Joomla with Apache and Let’s Encrypt SSL on Debian 11.

Prerequisites

Install LAMP Stack

Follow the below link to install the LAMP stack on your Debian system for Joomla installation.

Install AMP (Apache, MariaDB, and PHP) on Debian 11

Install PHP Extensions

Use the apt command to install PHP extensions required for Joomla.

sudo apt update

sudo apt install -y php-gd php-xmlrpc php-curl php-intl php-imagick php-mysql php-zip php-xml php-mbstring php-bcmath

Configure PHP Settings for Joomla

Joomla requires a few PHP configurations like PHP temporary directory, maximum allowed size for uploaded files to work correctly. So, add the below values in /etc/php/7.4/apache2/php.ini file. You may increase or decrease values as per your requirements.

output_buffering = off # Required for Joomla

upload_tmp_dir = “/tmp”

upload_max_filesize = 64M

post_max_size = 64M

sudo sed -i 's/output_buffering = .*/output_buffering = off/' /etc/php/7.4/apache2/php.ini

sudo sed -i 's/\;upload_tmp_dir =/upload_tmp_dir = "\/tmp"/' /etc/php/7.4/apache2/php.ini

sudo sed -i 's/post_max_size = .*/post_max_size = 64M/' /etc/php/7.4/apache2/php.ini

sudo sed -i 's/upload_max_filesize = .*/upload_max_filesize = 64M/' /etc/php/7.4/apache2/php.ini

Setup Apache Virtual Host for Joomla

We will start with creating a virtual host for a Joomla installation. You can find all Apache’s virtual host files under /etc/apache2/sites-available/ directory.

Typically the virtual host file contains a ServerName, ServerAlias, Port number, Document root, log location, etc.

For this article, I am assuming the following:

Domain name: www.itzgeek.net
Port No: 80
Document root: /var/www/html/www.itzgeek.net/

First, create a virtual host file.

sudo nano /etc/apache2/sites-available/www.itzgeek.net.conf

Then, add the following content into the above configuration file. Change the values as per your requirement.

<VirtualHost *:80>

   ServerName itzgeek.net
   ServerAlias www.itzgeek.net
   ServerAdmin admin@itzgeek.net
   DocumentRoot /var/www/html/www.itzgeek.net


   ErrorLog ${APACHE_LOG_DIR}/www.itzgeek.net_error.log
   CustomLog ${APACHE_LOG_DIR}/www.itzgeek.net_access.log combined


   <Directory /var/www/html/www.itzgeek.net>
      Options FollowSymlinks
      AllowOverride All
      Require all granted
   </Directory>

</VirtualHost>

Create a directory to place Joomla files.

sudo mkdir -p /var/www/html/www.itzgeek.net/

Enable the Joomla site and Apache modules (SSL and rewrite).

sudo a2ensite www.itzgeek.net

sudo a2enmod rewrite ssl

Restart the Apache service.

sudo systemctl restart apache2

Install Let’s Encrypt SSL Certificate

Create DNS Record

Go to your domain registrar and create a DNS record [A and CNAME (optional if you do not want to use www subdomain)] record for your domain.

  1. Non-www Domain Name (Ex. itzgeek.net) >> A record point to your server IP
  2. www Domain Name (Ex. www.itzgeek.net) >> CNAME record point to itzgeek.net

For this demo, I created two records so that my Joomla website will be accessible at www.itzgeek.net.

DNS Records
DNS Records

Install Certbot client

The Certbot client, which helps to generate and install the SSL certificate, is now available as a snap package for Debian operating system. So, first, you will need to install snapd on your system.

sudo apt update

sudo apt install -y snapd

After the installation, update snapd to the latest version.

sudo snap install core && sudo snap refresh core

Finally, install the Certbot using the snap command.

sudo snap install --classic certbot

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

Install SSL Certificate

Use the certbot command to generate and install the Let’s Encrypt SSL certificate on the Apache webserver.

sudo certbot --apache
1. Enter email address to receive notification on urgent renewal and security notices
2. Type Y and press Enter to register with the ACME server
3. Type Y or N to receive emails about EFF news, campaigns, newsletter.
4. Certbot will automatically detect the website(s) you created and ask you to activate HTTPS for it. Type 1 or appropriate numbers separated by a comma in case you have multiple websites.
Which names would you like to activate HTTPS for?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: itzgeek.net
2. www.itzgeek.net
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter 'c' to cancel): 1,2

Wait for the SSL installation to complete.

Redirect non-www HTTP requests to www HTTPS with Apache

The Certbot client will place the required redirect rules to redirect the traffic from HTTP to the HTTPS website.

1. http://itzgeek.net >> https://itzgeek.net

2. http://www.itzgeek.net >> https://www.itzgeek.net

As you can see, with rules placed by Certbot, the first domain is not reaching the www HTTPS website. So, you will have to add a rule manually to redirect traffic from non-www HTTP to www HTTPS domain, I.e., http://itzgeek.net >> https://www.itzgeek.net if required.

Auto-Renew SSL Certificate

The Certbot client includes a systemd service and it takes care of automated certificate renewals. So, you will not have to renew the certificates manually.

Install Joomla with Apache

Create Database for Joomla Installation

First, login into MariaDB/MySQL database server.

sudo mysql -u root -p

Then, create a database for Joomla installation with the database user and password.

CREATE DATABASE joomladb;

CREATE USER 'joomlauser'@'localhost' IDENTIFIED BY 'password';

GRANT ALL PRIVILEGES ON joomladb.* TO 'joomlauser'@'localhost';

EXIT

Download Joomla Package

Download the latest version of the Joomla package using the following command in the terminal.

mkdir /tmp/joomla && cd /tmp/joomla

wget https://downloads.joomla.org/cms/joomla4/4-0-3/Joomla_4-0-3-Stable-Full_Package.tar.gz?format=gz -O Joomla_4-0-3-Stable-Full_Package.tar.gz

Then, extract the downloaded file.

tar -zxvf Joomla_4-0-3-Stable-Full_Package.tar.gz

And then, move the files to the website root directory.

sudo mv * /var/www/html/www.itzgeek.net/

Update the ownership and a group of the Joomla website directory.

sudo chown -R www-data:www-data /var/www/html/www.itzgeek.net/

Install Joomla CMS

Open your browser and visit your website to perform the Joomla installation.

https://your-joomla-website

1. Select Language for the installer and type the Site Name for your Joomla website and then click Setup Login Data

2. Enter Joomla Administrator name, username, password, and email address, and then click Setup Data Connection

3. Select the database type as MySQL (PDO) and then enter Joomla database details [Leave the table prefix and Connection Encryption as it is] and then click Install Joomla

4. You will now get Congratulations! Your Joomla site is ready. You can access the website by clicking on Complete & Open Site or Joomla back-end by clicking on Complete & Open Admin. If you want, you can also add additional language to your website’s front-end and back-end by clicking on Install Additional Languages.

5. You can access the Joomla back-end any time by going to https://your-joomla-website/administrator

Access Joomla Website

Now, you will be able to access the site with your domain name.

https://your-joomla-website
Joomla Website
Joomla Website

Screenshot of Joomla back-end:

Joomla Website Back-end
Joomla Website Back-end

Conclusion

That’s All. I hope you have learned how to install Joomla with Apache and Let’s Encrypt SSL on Debian 11.

You might also like