How to Setup Joomla on Ubuntu with Nginx & Cloudflare
You can set up Joomla on Ubuntu with Nginx and Cloudflare by configuring each component to work together efficiently.
Joomla is a powerful open-source content management system (CMS) for building websites. Nginx is a high-performance web server known for its speed, and Cloudflare adds a layer of security, DNS management, and content delivery network (CDN) services.
This guide focuses on integrating these tools, likely using Ubuntu Server 22.04 LTS, to create a fast and secure website. You’ll leverage Nginx’s efficient request handling and Cloudflare’s global network to protect and accelerate your Joomla site.
To set up Joomla on Ubuntu with Nginx and Cloudflare, first configure Cloudflare DNS and SSL settings. Then, install Nginx, MariaDB, and PHP on your Ubuntu server. Finally, install Joomla and configure Nginx to serve your Joomla site.
Setting up Cloudflare
Setting up Cloudflare is your first step to securing and speeding up your website, especially when using Joomla with Nginx.
https://dash.cloudflare.com/sign-up
Enter your email and click Create Account.

Once logged in, click the “Add a Site” button.

Type in your domain name. registered

Cloudflare will scan your domain for existing records.

Select the free plan.

Cloudflare will give you two nameservers. Log in to your domain registrar (where you bought your domain) and replace your current nameservers with these two.

Example: If your domain is at Google Domains, select “use custom nameservers” and save the new addresses.

It can take up to an hour for these changes to take effect. Check your Cloudflare dashboard until the status says “Active.”

Your DNS entries should now appear in the Cloudflare dashboard.

Go to the SSL/TLS tab and set it to “Full (Strict).”

Scroll down to “Origin Certificates” and click “Create Certificate.”

Let Cloudflare generate the key and click Next.

You will need to create three files on your server using these commands. (Requires admin privileges)
sudo nano /etc/ssl/private/cloudflare_key_example.com.pem
sudo nano /etc/ssl/certs/cloudflare_example.com.pem
Download the Cloudflare Origin Pull certificate here: Set up authenticated Origin pulls · Cloudflare SSL docs
sudo nano /etc/ssl/certs/origin-pull-ca.pem
You now have three files: cloudflare_key_example.com.pem, cloudflare_example.com.pem, and origin-pull-ca.pem.

In the Cloudflare dashboard, turn on “Always Use HTTPS.”

Turn on “Authenticated Origin Pulls” and “Opportunistic Encryption.”

Turn on “Automatic HTTPS Rewrites.”

Go to “Page Rules” and create a rule to always use HTTPS for your domain.

Install and Configure Joomla
Log in to your server. (Requires admin privileges)
Install Nginx:
sudo apt update
sudo apt install nginx
Use these commands to manage the service:
sudo systemctl stop nginx.service
sudo systemctl start nginx.service
sudo systemctl enable nginx.service
Test your server by visiting your site address in a browser.

Install MariaDB Database
Joomla needs a database to keep all your website’s information, so we’ll install MariaDB, a popular database system, on your Ubuntu server.
sudo apt-get install mariadb-server mariadb-client
Set the service to run on boot:
sudo systemctl stop mysql.service
sudo systemctl start mysql.service
sudo systemctl enable mysql.service
sudo systemctl stop mariadb.service
sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service
Secure your database:
sudo mysql_secure_installation
Follow the on-screen prompts to set a password and remove test settings.
sudo mysql -u root -p

Install PHP
Joomla is built using PHP, a programming language that makes websites dynamic, so we need to install it on your Ubuntu system.
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install php7.2-fpm php7.2-common php7.2-gmp php7.2-curl php7.2-intl php7.2-mbstring php7.2-xmlrpc php7.2-mysql php7.2-gd php7.2-xml php7.2-cli php7.2-zip
Edit the configuration file:
sudo nano /etc/php/7.2/fpm/php.ini
Update settings and save:
file_uploads = On
allow_url_fopen = On
short_open_tag = On
memory_limit = 256M
cgi.fix_pathinfo = 0
upload_max_filesize = 100M
max_execution_time = 360
date.timezone = America/Chicago
Restart Nginx:
sudo systemctl restart nginx.service
Create a test file to verify PHP:
sudo nano /var/www/html/phpinfo.php
Visit your site address followed by /phpinfo.php to see the test page.

Create Joomla Database
Log in to the database:
sudo mysql -u root -p
Create the database and user:
CREATE DATABASE joomla;
CREATE USER 'joomlauser'@'localhost' IDENTIFIED BY 'new_password_here';
GRANT ALL ON joomla.* TO 'joomlauser'@'localhost' IDENTIFIED BY 'user_password_here' WITH GRANT OPTION;
FLUSH PRIVILEGES;
EXIT;
Install Joomla
Now it’s time to install Joomla itself, the content management system that will power your website, onto your Ubuntu server.
cd /tmp
wget https://downloads.joomla.org/cms/joomla3/3-9-5/joomla_3-9-5-stable-full_package-zip
sudo unzip -d /var/www/html/example.com /tmp/joomla_3-9-5-stable-full_package-zip
Set permissions:
sudo chown -R www-data:www-data /var/www/html/example.com/
sudo chmod -R 755 /var/www/html/example.com/
Configure Nginx for your site:
sudo nano /etc/nginx/sites-available/example.com
Add your domain settings and certificate references:
server {
listen 80;
listen [::]:80;
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name example.com www.example.com;
root /var/www/html/example.com;
index index.php;
ssl_certificate /etc/ssl/certs/cloudflare_example.com.pem;
ssl_certificate_key /etc/ssl/private/cloudflare_key_example.com.pem;
ssl_client_certificate /etc/ssl/certs/origin-pull-ca.pem;
ssl_verify_client on;
client_max_body_size 100M;
autoindex off;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ .php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}Enable the site:
sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
sudo systemctl restart nginx.service
Visit your domain in a browser to finish the setup wizard.

Enter your database info:

Confirm settings and install:

Remove the installation folder:

Log in to your dashboard:


sudo rm -rf /var/www/html/joomla/installation
Summary
You have successfully installed Joomla on an Ubuntu server protected by Nginx and Cloudflare. You configured a database, added SSL encryption for security, and set up a custom domain. Your site is now ready for content.
[Y/n]
[Y/n]
[Y/n]
[Y/n]
[Y/n]
Was this guide helpful?
About the Author
Richard
Tech Writer, IT Professional
Richard, a writer for Geek Rewind, is a tech enthusiast who loves breaking down complex IT topics into simple, easy-to-understand ideas. With years of hands-on experience in system administration and enterprise IT operations, he’s developed a knack for offering practical tips and solutions. Richard aims to make technology more accessible and actionable. He's deeply committed to the Geek Rewind community, always ready to answer questions and engage in discussions.
No comments yet — be the first to share your thoughts!