How to Install MODX CMS with Nginx on Ubuntu 24.04
MODX CMS with Nginx on Ubuntu 24.04 runs as a fast website setup that lets you build pages and manage text or images with total control over your site design. MODX is a content management system, and Nginx works as the web server that loads your pages quickly for visitors.
Getting this server stack running on Ubuntu 24.04 (released in April 2024) requires installing Nginx version 1.26.1 alongside PHP and a database so all the parts work together smoothly.
Install Nginx using `sudo apt install nginx`, then install MariaDB with `sudo apt install mariadb-server`. Configure PHP-FPM and create a MODX database and user. Finally, download and extract MODX files to your web server’s document root.
Install Nginx HTTP server on Ubuntu
You can install the Nginx HTTP server on Ubuntu 24.04 by opening your terminal and running the apt package manager commands. Nginx is the web server software that handles incoming visitor traffic to your MODX website. To get started, run the update command and then install Nginx directly on your system.
To do that, open the Ubuntu terminal and run the commands below to install the Nginx web server.
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.
sudo systemctl stop nginx
sudo systemctl start nginx
sudo systemctl enable nginx
You can test the Nginx web server by opening your web browser and browsing to the server’s localhost or IP address.
http://localhost

When you see the "Welcome to nginx!" page, it means the Nginx HTTP server is successfully installed.
Additional help on installing Nginx on Ubuntu is in the link below.
Install the MariaDB database server on Ubuntu
You can install the MariaDB database server on Ubuntu by using the terminal to download and set up the required database packages. MariaDB acts as the relational database management system that stores all your MODX website content, user accounts, and system settings securely.
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.
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.
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.
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.
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.
- How to install MariaDB on Ubuntu Linux
- MariaDB without password prompt
Create a MODX database
You can create a MODX database by logging into the MariaDB command line interface as the root user and running SQL queries. This process involves setting up a dedicated database name along with a secure database user account that has full permissions to manage your site data.
As part of the setup, we will create a modxdb database and a user account called modxdbuser.
Finally, we'll grant the modxdbuser full access to the modxdb database.
All the database steps above can be done using the commands below:
But first, log on to the MariaDB database server:
sudo mariadb
Then run the commands below to complete the steps:
CREATE DATABASE modxdb CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
CREATE USER modxdbuser@localhost IDENTIFIED BY 'type_your_password_here';
GRANT ALL ON modxdb.* TO modxdbuser@localhost WITH GRANT OPTION;
FLUSH PRIVILEGES;
exit
Install PHP-FPM on Ubuntu Linux
You can install PHP-FPM on Ubuntu Linux by running a single terminal command that includes the required PHP modules for your CMS. PHP-FPM processes the dynamic PHP code that MODX needs to run properly alongside your Nginx web server.
Run the commands below to install PHP-FPM.
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-json php-sqlite3 php-soap php-ldap php-zip
Additional help on installing PHP-FPM
Download MODX files
You can download MODX files directly from the official website using the terminal and place them into your web server directory. This archive contains all the core PHP files, assets, and installation scripts required to set up your new content management system.
To always install the latest version, check the MODX's download page. If a new version is available, replace the version number in the link below.
After unzipping the file, move the content into the MODX 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 MODX installation.
cd /tmp
wget https://modx.s3.amazonaws.com/releases/3.0.5/modx-3.0.5-pl.zip
unzip modx-*.zip
sudo mv modx-*/ /var/www/modx
sudo chown -R www-data:www-data /var/www/modx
Once you have completed all the above steps, continue configuring the Nginx web server below to serve the MODX content.
Run the commands below to create a Nginx virtual host file for MODX.
sudo nano /etc/nginx/sites-available/modx.conf
Then, copy and paste the content block below into the Nginx server block.
server {
listen 80;
listen [::]:80;
server_name modx.example.com;
root /var/www/modx;
index index.php;
client_max_body_size 30M;
# the MODX part
location @modx-rewrite {
rewrite ^/(.*)$ /index.php?q=$1&$args last;
}
location / {
absolute_redirect off;
try_files $uri $uri/ @modx-rewrite;
}
location ~ ^/(.(?!well_known)|_build|_gitify|_backup|core|config.core.php) {
rewrite ^/(.(?!well_known)|_build|_gitify|_backup|core|config.core.php) /index.php?q=doesnotexist;
}
location ~ .php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.3-fpm.sock;
include fastcgi_params;
fastcgi_intercept_errors on;
fastcgi_ignore_client_abort on;
fastcgi_param SERVER_NAME $http_host;
}
location ~ /.ht {
deny all;
}
}Save the file.
You can enable the virtual host for your MODX CMS site by running the command `sudo a2ensite modx.conf` and then restart the Nginx server with `sudo systemctl restart nginx` to apply these changes.
sudo ln -s /etc/nginx/sites-available/modx.conf /etc/nginx/sites-enabled/
sudo systemctl restart nginx.service
Setup Let's Encrypt SSL/TLS for MODX
You can set up a Let's Encrypt SSL/TLS certificate for MODX on Ubuntu using Certbot to secure your website traffic with HTTPS. This encryption protects sensitive visitor data and improves your search engine rankings by ensuring a secure connection between the browser and your Nginx server.
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.
http://modx.example.com/setup
A MODX installation wizard page should appear. Select the installation language and click Continue.

Then, select MODX installation type. For this post, we're choosing "New Installation."

Next, enter the database name, account, and password and click Test. Create an admin account on the same page and continue.

Next, click the Install button to begin the installation.

On the next screen, ensure all the tests are successful and click Continue.

Your MODX site should be set up and ready to use.

That should do it!
Conclusion
- In conclusion, this article has provided a comprehensive guide for installing MODX CMS with Nginx support on Ubuntu 24.04, a robust platform for website development.
- Following the step-by-step instructions, users can successfully set up Nginx, MariaDB, PHP-FPM, and Let's Encrypt SSL/TLS for MODX.
- Leveraging the benefits of MODX CMS and Nginx web server, users can create and manage websites efficiently and securely on Ubuntu 24.04.
- The seamless integration of MODX with Nginx, MariaDB, and PHP-FPM ensures a reliable and high-performance website hosting and management environment.
- The addition of the Let's Encrypt SSL/TLS certificate provides an extra layer of security, ensuring the safety of the MODX site and its users.
Was this guide helpful?
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.
No comments yet — be the first to share your thoughts!