Skip to content
Follow
CMS

Install Contao CMS with Nginx on Ubuntu 24.04

Richard
Written by
Richard
Nov 10, 2024 Updated Sep 15, 2026 7 min read
Install Contao CMS with Nginx on Ubuntu 24.04
Install Contao CMS with Nginx on Ubuntu 24.04

Contao 5.x is a content management system (a tool that lets you build and run websites) that pairs with the Nginx web server on Ubuntu 24.04 to give you a fast, reliable platform for your web projects.

Advertisement

Running this setup on your server takes about 30 minutes and requires root access to your Ubuntu 24.04 server along with basic command line skills.

⚡ Quick Answer

Install Nginx via `sudo apt install nginx`, then MariaDB with `sudo apt install mariadb-server`. Create a Contao database and user in MariaDB, and install PHP using `sudo apt install php-fpm` and other required extensions.

Advertisement

Install Nginx HTTP server on Ubuntu

Nginx is a web server that makes your Contao CMS Nginx Ubuntu website visible online. Installing Nginx on Ubuntu 24.04 takes just a couple of commands in your terminal to get the web server running. Open your terminal and run the update and install commands to set up Nginx.

To do that, open the Ubuntu terminal and run the commands below to install the Nginx web server.

🐧Bash / Shell
sudo apt update
sudo apt install nginx

Once Nginx is installed, the commands below can start, stop, and enable the Nginx web server to start automatically when your server boots up.

🐧Bash / Shell
sudo systemctl stop nginx
sudo systemctl start nginx
sudo systemctl enable nginx

You can test the Nginx web server is running by opening your web browser and browsing to the server’s localhost or IP address.

Advertisement

http://localhost

Nginx welcome page displayed after successful installation on Ubuntu 24.04
Nginx welcome page displayed after successful installation on Ubuntu 24.04

When you see the Welcome to nginx!, it means the Nginx HTTP server is successfully installed.

Additional help on installing Nginx on Ubuntu is in the link below.

How to install Nginx on Ubuntu

Advertisement

Install the MariaDB database server on Ubuntu

MariaDB is a database server that stores all your Contao CMS Nginx Ubuntu website information. Installing the MariaDB database server on Ubuntu is a necessary step before you can run the installer. Open the Ubuntu terminal and run the server installation command to get started.

To install and use the MariaDB database server, use the instructions below.

Open the Ubuntu terminal and run the commands below to install the MariaDB database server.

🐧Bash / Shell
sudo apt update
sudo apt install mariadb-server

Once the MariaDB database server is installed, use the commands below to stop, start, and enable the MariaDB server to start automatically when the server boots.

Advertisement
🐧Bash / Shell
sudo systemctl stop mariadb
sudo systemctl start mariadb
sudo systemctl enable mariadb

Run the following commands to validate and test if the MariaDB database server is installed successfully.

🐧Bash / Shell
sudo mariadb

Once you run the commands above, it will log you onto the MariaDB console and display a message similar to the one below.

💻Code
Welcome to the MariaDB monitor.  Commands end with ; or g.
Your MariaDB connection id is 32
Server version: 10.11.2-MariaDB-1 Ubuntu 23.04

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

MariaDB [(none)]> 

The message tells you that the server is installed successfully.

Additional help on installing MariaDB.

Advertisement

Create a Contao database

Creating a dedicated database and user account gives Contao CMS Nginx Ubuntu secure access to store its data. You need to log into the MariaDB shell and run SQL commands to make a new database and a user with full control over it.

As part of the setup, we will create a contaodb database and a user account called contaodbuser.

Finally, we'll grant the contaodbuser full access to the contaodb database.

All the database steps above can be done using the commands below:

Advertisement

But first, log on to the MariaDB database server:

🐧Bash / Shell
sudo mariadb

Then run the commands below to complete the steps:

💻Code
CREATE DATABASE contaodb CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
CREATE USER contaodbuser@localhost IDENTIFIED BY 'type_your_password_here';
GRANT ALL ON contaodb.* TO contaodbuser@localhost WITH GRANT OPTION;
FLUSH PRIVILEGES;
exit
⚠️WarningEnsure to replace 'type_your_password_here 'with your password.

Install PHP on Ubuntu Linux

PHP is the programming language required to run Contao CMS Nginx Ubuntu on your server. You must install PHP along with helpful extensions like php-fpm and php-intl using the terminal. Run the package manager command to download and set up the latest PHP version.

Advertisement

Then, run the commands below to install the latest PHP version.

🐧Bash / Shell
sudo apt install php-fpm php-intl php-mysql php-curl php-cli php-zip php-xml php-gd php-common php-mbstring php-xmlrpc php-bcmath php-json php-sqlite3 php-soap php-zip

Additional help on installing PHP

How to install PHP on Ubuntu Linux

Download Contao files

Downloading the official Contao CMS Nginx Ubuntu application files gets the core software onto your server. You can fetch the latest release package directly into a temporary folder on your server and then move the files into your web root directory.

To always install the latest version, check the download page for Contao. The Contao Managed Edition is a pre-configured application that can be installed and managed with the Contao Manager.

First, navigate to the /tmp/ directory and download Contao files. Next, move the content into the Contao folder in the Nginx root directory.

The final step is to change the permissions. This will allow the Nginx web server to interact safely with the files, ensuring a secure environment for your Contao installation.

⬛Command Prompt
cd /tmp/
wget https://download.contao.org/contao-manager/stable/contao-manager.phar
sudo mkdir -p /var/www/contao/web
sudo mv contao-manager.phar /var/www/contao/web/contao-manager.phar.php
sudo chown -R www-data:www-data /var/www/contao

Once you have completed all the above steps, continue configuring the Nginx web server below to serve the Contao content.

Run the commands below to create a Nginx virtual host file for Contao.

🐧Bash / Shell
sudo nano /etc/nginx/sites-available/contao.conf

Then, copy and paste the content block below into the Nginx server block.

🐘PHP
server {
listen 80;
listen [::]:80;
root /var/www/contao/web;
index index.php;
server_name contao.example.com;

access_log /var/log/nginx/example.com.access.log;
error_log /var/log/nginx/example.com.error.log;

location / {
try_files $uri /index.php$is_args$args;
}


location ~ ^/index.php(/|$) {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.3-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}


location ~ ^/(preview|contao-manager.phar).php(/|$) {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.3-fpm.sock;
include fastcgi_params;
}
}

Save the file.

The Nginx virtual host file, located at `/etc/nginx/sites-available/contao.conf`, can be enabled by creating a symbolic link to `/etc/nginx/sites-enabled/` using the command `sudo ln -s /etc/nginx/sites-available/contao.conf /etc/nginx/sites-enabled/`. After enabling the virtual host, you must restart the Nginx server for these changes to take effect.

🐧Bash / Shell
sudo ln -s /etc/nginx/sites-available/contao.conf /etc/nginx/sites-enabled/
sudo systemctl restart nginx.service

Setup Let’s Encrypt SSL/TLS for Contao

Let's Encrypt provides free SSL/TLS certificates to secure your Contao CMS Nginx Ubuntu site with HTTPS and protect visitor data. Setting up these security certificates for Nginx on Ubuntu makes your website trusted and encrypted for all users.

Please read the post below for additional resources on installing and creating Let’s Encrypt SSL certificates for Nginx.

How to set up Let’s Encrypt SSL certificate for Nginx on Ubuntu Linux

Once you have restarted the Nginx web server, open your browser and browse to the server hostname or IP address defined in the Nginx server block.

🐘PHP
http://contao.example.com/contao-manager.phar.php

A Contao installation wizard page should appear. To manage your installation, please create an account for the Contao Manager. This account is unrelated to the Contao back or front end.

Contao user account
Contao user account

Next, click the Setup button to begin.

Contao user setup
Contao user setup

Accept the defaults and continue.

Contao user setup directories updated
Contao user setup directories updated

Click Install

Contao user setup install
Contao user setup install

Type in the database connection details created above.

Contao user setup database
Contao user setup database

Import the theme database, update the schema, and continue.

Contao user setup database import
Contao user setup database import

After that, the setup should be completed.

Contao user setup complete
Contao user setup complete

That should do it!

Conclusion:

This guide explored installing Contao CMS with Nginx on Ubuntu 24.04. Key takeaways include configuring Nginx to serve your Contao website efficiently. You can now use Contao's content management features on your Ubuntu 24.04 server.

  • Contao CMS is a powerful, open-source, user-friendly, flexible content management system.
  • Installing Nginx provides a lightweight, high-performance web server environment for hosting Contao.
  • MariaDB serves as an efficient database solution, enabling effective data management for the Contao application.
  • Ensuring you have PHP installed with the necessary extensions is crucial for Contao's functionality.
  • Following detailed steps for configuring Nginx ensures your Contao installation runs smoothly and securely.
  • Setting up an SSL/TLS certificate enhances the security of your Contao website, protecting user data and improving SEO.
  • The Contao Manager allows for easy administration and control over your Contao installation.

With these steps completed, you're now ready to utilize the full potential of Contao CMS for your website projects. Enjoy building and managing your content!

Was this guide helpful?

Was this helpful?
Richard

About the Author

Richard

Tech Writer, IT Professional

Richard is a writer at Geek Rewind who turns complex IT tasks into clear, step-by-step guides. He draws on years of hands-on experience in system administration and enterprise IT operations, focusing on Windows, Linux and WordPress: the problems people actually run into, and the fixes that work. His server and WordPress guides come from systems he runs himself. Richard builds and maintains the platform behind Geek Rewind, from its Ubuntu servers and Nginx configuration to its custom WordPress plugins. Many new tutorials start with readers' questions, and he's always glad to answer them in the comments.

Advertisement

📚 Related Tutorials

How to Install Nginx on Ubuntu Linux
Ubuntu Linux How to Install Nginx on Ubuntu Linux
Install MySQL and MariaDB on Ubuntu: A Step-by-Step Guide
Ubuntu Linux Install MySQL and MariaDB on Ubuntu: A Step-by-Step Guide
Install Contao CMS with Apache on Ubuntu 24.04
CMS Install Contao CMS with Apache on Ubuntu 24.04
How to Install Ubuntu Linux
Ubuntu Linux How to Install Ubuntu Linux

No comments yet — be the first to share your thoughts!

Leave a Comment

Your email address will not be published. Required fields are marked *