How to install MODX CMS with Nginx on Ubuntu 24.04
You install MODX CMS with Nginx on Ubuntu 24.04 to set up a powerful, flexible website managed by a fast, efficient web server.
MODX is an open-source content management system great for building dynamic websites, while Nginx is a lightweight web server celebrated for its performance.
This tutorial guides you through combining MODX’s user-friendly CMS capabilities with Nginx’s speed on Ubuntu 24.04.
By following these steps, you’ll create a robust and high-performing hosting environment for your website.
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
Install the Nginx web server on Ubuntu by opening your terminal and running a couple of simple commands to update your software list and then install Nginx.
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 need a database for MODX, and installing the MariaDB database server on Ubuntu is easy using your terminal.
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
After installing MariaDB, you’ll create a new database for MODX, including a username and password for it.
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
Ensure to replace ‘type_your_password_here ‘with your password.
Install PHP-FPM on Ubuntu Linux
MODX needs PHP-FPM to work, so you’ll install it on your Ubuntu Linux system using a simple terminal command.
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
Get MODX ready by downloading the latest files from their website and moving them to the right folder for your Nginx server.
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.
First, navigate to the /tmp/ directory and download MODX files. 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.
Then, run the commands below to enable the virtual host and restart the Nginx server.
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
Securing your MODX website with HTTPS is important, and you can easily set up a free SSL certificate using Let’s Encrypt on Ubuntu.
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.
Is modx a good CMS?
The MODX content management system (CMS) is our holy grail for building websites, web shops, intranets and other digital products. This CMS is a bit more unknown than CMSs like WordPress, Joomla and Drupal, but its online performance certainly doesn't fall short of that.
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!