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

Joomla! is one of the most popular Content Management Systems (CMSs) next to WordPress. With Joomla, you can create blogs, discussion forums, and other websites.

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

If you do not have any web hosting yet, we recommend installing Joomla on your local Debian system or VPS.

Here, we will see how to install Joomla with Nginx on Debian 11.

Prerequisites

Install LEMP Stack

Follow the below links to install the LEMP stack on your Debian system for Joomla installation.

Install EMP (Nginx, 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, edit the php.ini file.

sudo nano /etc/php/7.4/fpm/php.ini

Then, update the below values as per your requirement.

output_buffering = off # Required for Joomla

upload_tmp_dir = "/tmp"

upload_max_filesize = 64M

post_max_size = 64M

Setup Nginx Virtual Host for Joomla

We will start with creating a virtual host for a Joomla installation. You can find all Nginx’s virtual host configuration files under /etc/nginx/conf.d directory.

Typically the virtual host file contains a domain name, port number, document root, log location, fast CGI, etc.

For this article, I am assuming the following:

Domain name: itzgeek.net, www.itzgeek.net
Port No: 80
Document root: /usr/share/nginx/www.itzgeek.net/html
Logs: /usr/share/nginx/www.itzgeek.net/logs

First, create a virtual host configuration.

sudo nano /etc/nginx/conf.d/www.itzgeek.net.conf

Then, place the following content into the above configuration file. You will need to change server_name as per your requirement.

server {
	server_name itzgeek.net www.itzgeek.net;
	root /usr/share/nginx/www.itzgeek.net/html;

	index index.php index.html;

	access_log /usr/share/nginx/www.itzgeek.net/logs/access.log;
	error_log /usr/share/nginx/www.itzgeek.net/logs/error.log;

	# Prevent access to certain file extensions
	location ~\.(ini|log|conf)$ {
		deny all;
	}

	location ~ \.php$ {
        # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
        include fastcgi_params;
        fastcgi_intercept_errors on;
        fastcgi_pass unix:/run/php/php7.4-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
	}

}

Create a document root and logs directory.

sudo mkdir -p /usr/share/nginx/www.itzgeek.net/html/

sudo mkdir -p /usr/share/nginx/www.itzgeek.net/logs/

Verify the Nginx configuration file with the below command.

sudo nginx -t

If you get the following, it means that the virtual host configuration is correct.

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Restart the Nginx and PHP-FPM services.

sudo systemctl reload nginx php7.4-fpm

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

Install Certbot client

The Certbot client, which helps us generate and install the Let’s Encrypt SSL certificate, is now available as a snap package for Debian operating system. So, first, install snapd on your system.

sudo apt update

sudo apt install -y snapd

Then, update snapd to the latest version.

sudo snap install core && sudo snap refresh core

Finally, install the Certbot client 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 for the Nginx web server.

sudo certbot --nginx
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 Joomla domain and ask you permission to activate HTTPS for your Joomla website. 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. You will now be able to access the website with HTTPS.

Note: If you access the website now, you will get a 403 forbidden error because you are yet to place the Joomla installer filer.

Redirect non-www HTTP requests to www HTTPS with Nginx

You may like to configure the Nginx server to redirect the traffic from the non-www HTTP site to the WWW HTTPS site, I.e., http://itzgeek.net >> https://www.itzgeek.net. You can skip this if you do not use www in your domain.

Auto-Renew SSL Certificate

The Certbot client now includes auto-renewal of SSL certificates through the systemd. So, you will not have to renew the certificates manually.

Install Joomla with Nginx

Create Database for Joomla Installation

First, login into MariaDB/MySQL database server.

sudo mysql -u root -p

Then, create the database for Joomla installation along 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 your website document root directory.

sudo mv * /usr/share/nginx/www.itzgeek.net/html/

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

sudo chown -R www-data:www-data /usr/share/nginx/www.itzgeek.net/

Install Joomla CMS

Open your browser and visit your Joomla website domain 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 for 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

Conclusion

That’s All. I hope you have learned how to install Joomla with Nginx on Debian 11.

cmsdebian 11Joomlaletsencryptnginxssl
Comments (0)
Add Comment