Tutorials  /  Linux Basics

Install MODX on CentOS 7 with Nginx, PHP 7.2 & MariaDB

Ccentron Redaktion · June 2025 ·7 min read ·Linux Basics, Tutorial

MODX is an open-source content management system written in PHP, utilizing MySQL or MariaDB for data storage. It is ideal for businesses where consistent web presence is essential. MODX offers developers the freedom to define the layout and architecture, while also including a WYSIWYG interface for non-technical users. This CMS combines versatility with the potential for high-speed performance.

This walkthrough is built around MODX version 2.6.1, but it should be compatible with newer releases as well.

Requirements

  • A CentOS 7 server
  • User access with sudo privileges
  • A domain configured to direct traffic to your server

Throughout this tutorial, we will refer to modx.example.com as the domain name. Make sure to replace it with your actual domain when following the steps.

VM

Matching infrastructure at centron

No hardware needed to follow along: ccloud³ VMs with full root access start at €3.12 per month, billed by the hour and ready in seconds. Rent a cloud server →

System Preparation

First, update your base system by following the instructions in the guide "How to Update CentOS 7". Once updated, install the necessary packages.

Installing Nginx

Nginx is a high-performance web server suitable for running modern web apps. Begin by installing Nginx:

Console
sudo yum -y install epel-release
sudo yum -y install nginx

Enable and start Nginx so it runs on boot:

Console
sudo systemctl start nginx
sudo systemctl enable nginx

Installing PHP 7.2

MODX supports PHP versions above 5.4. To ensure better performance and security, install PHP 7.2. Since this version isn’t in the default repository, enable the Remi repository first:

Console
sudo rpm -Uvh http://rpms.remirepo.net/enterprise/remi-release-7.rpm
sudo yum -y install yum-utils
sudo yum-config-manager --enable remi-php72

Install PHP 7.2 and the extensions required by MODX:

Console
sudo yum -y install php php-zlib php-mysqli php-curl php-json php-cli php-pear php-gd php-openssl php-xml php-mbstring php-fpm ImageMagick

Edit the PHP configuration file:

Console
sudo nano /etc/php.ini

Uncomment and set the appropriate timezone:

Code
date.timezone = Asia/Kolkata

Set memory limit as follows to allow unlimited memory usage:

Code
memory_limit = -1

Update the following setting to disable path info processing:

Code
cgi.fix_pathinfo=0

Open and modify the PHP-FPM pool configuration file:

Console
sudo nano /etc/php-fpm.d/www.conf

Replace the default listener configuration:

Code
;listen = 127.0.0.1:9000
listen = /var/run/php-fpm/php-fpm.sock

Update the user and group settings:

Code
listen.owner = nginx
listen.group = nginx

user = nginx
group = nginx

Restart PHP-FPM and set it to launch at boot:

Console
sudo systemctl restart php-fpm
sudo systemctl enable php-fpm

Create and set permissions for the session directory:

Console
sudo mkdir /var/lib/php/session
sudo chmod -R 777 /var/lib/php/session

You are now ready to proceed with the MariaDB installation.

Setting Up MariaDB

MariaDB, a community-developed fork of MySQL, requires a newer version than what’s included in CentOS’s default YUM repository. Add the MariaDB repository to begin:

Console
echo "[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.2/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1" | sudo tee /etc/yum.repos.d/mariadb.repo

Proceed with the MariaDB installation:

Console
sudo yum -y install mariadb mariadb-server

Start MariaDB and configure it to run on boot:

Console
sudo systemctl start mariadb
sudo systemctl enable mariadb

Secure the database server with the following command:

Console
sudo mysql_secure_installation

You'll be prompted for the root password—by default, there's none. Press Enter to continue. Set a strong root password and accept all recommended settings by answering "Y" to each prompt.

Next, access the MySQL shell as the root user:

Code
mysql -u root -p

Use the following SQL commands to set up a database and user for MODX:

Code
CREATE DATABASE modx_data CHARACTER SET utf8 COLLATE utf8_general_ci;
CREATE USER 'modx_user'@'localhost' IDENTIFIED BY 'StrongPassword';
GRANT ALL PRIVILEGES ON modx_data.* TO 'modx_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;

You can personalize the database name and credentials. Be sure to use a robust password in place of StrongPassword.

Installing MODX

Download the MODX archive from the official site:

Console
wget https://modx.com/download/direct?id=modx-2.6.1-pl.zip -O modx.zip

To find the latest version, visit the MODX downloads page. Next, install the unzip utility:

Console
sudo yum -y install unzip

Extract the contents to the Nginx web root:

Console
sudo unzip modx.zip -d /usr/share/nginx/

Rename the extracted folder to modx:

Console
cd /usr/share/nginx/
sudo mv modx-*/ modx/

Change the default ht.access file to .htaccess:

Console
sudo mv /usr/share/nginx/modx/ht.access /usr/share/nginx/modx/.htaccess

Create a cache directory and assign it to the nginx user:

Console
sudo mkdir /usr/share/nginx/modx/core/cache
sudo chown nginx:nginx /usr/share/nginx/modx/core/cache

Set up an empty configuration file with the correct ownership:

Console
sudo touch /usr/share/nginx/modx/core/config/config.inc.php
sudo chown -R nginx:nginx /usr/share/nginx/

Finally, adjust the firewall to permit HTTP and HTTPS access:

Console
sudo firewall-cmd --zone=public --permanent --add-service=http
sudo firewall-cmd --zone=public --permanent --add-service=https
sudo firewall-cmd --reload

Configure Nginx Virtual Host

To serve your MODX website through Nginx, set up a new virtual host configuration file:

Console
sudo nano /etc/nginx/conf.d/modx.example.com.conf

Add the following configuration content to the file:

Code
server {
    listen 80;
    server_name modx.example.com;
    root /usr/share/nginx/modx;
    index index.php;
    client_max_body_size 30M;

    location / {
        root /usr/share/nginx/modx;
        if (!-e $request_filename) {
            rewrite ^/(.*)$ /index.php?q=$1 last;
        }
    }

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(.*)$;
        fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
        fastcgi_ignore_client_abort on;
        fastcgi_param SERVER_NAME $http_host;
    }

    location ~ /\.ht {
        deny all;
    }
}

Test Your Configuration

Once you’ve saved the virtual host file, test Nginx to ensure the syntax is correct:

Console
sudo nginx -t

If everything is correctly configured, you’ll see the following messages:

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

Apply the changes by restarting the Nginx service:

Console
sudo systemctl restart nginx

Finalizing the Installation

To finish installing MODX, open your web browser and go to:

http://modx.example.com/setup

The MODX setup wizard will appear, allowing you to choose your preferred language. Click through and select the "New Installation" option. Then, enter your MariaDB or MySQL database information and set up an administrator account.

Once you click "Install," MODX will store the setup data in the database and complete the installation. You’ll then be redirected to the administrative dashboard where you can begin building your site.

Conclusion

With MODX successfully installed on your CentOS 7 server using Nginx, PHP 7.2, and MariaDB, your platform is now ready for content creation and web application development. You’ve configured a secure and flexible environment tailored for both developers and non-technical users. The administrative dashboard provides full control over site customization and content management. From here, you can begin crafting your website to match your business needs.

Jetzt 200 € Guthaben sichern

Testen Sie Ihr Setup auf ccloud³

Registrieren Sie sich in der ccloud³ und erhalten Sie 200 € Startguthaben für Ihr Projekt – z. B. für eine PostgreSQL-VM mit automatischen Backups.

centron Redaktion Technische Redaktion

Das Redaktionsteam von centron schreibt Anleitungen aus dem Betriebsalltag: getestet auf unserer eigenen Plattform, betrieben im Rechenzentrum in Hallstadt bei Bamberg.

Kategorie Linux Basics
Teilen
Noch offene Fragen?

Unser Team hilft Ihnen bei Ihrem konkreten Setup weiter – von Menschen, die die Plattform selbst betreiben.

War dieses Tutorial hilfreich?

Ihre Antwort wird anonym gespeichert und hilft uns, die Tutorials zu verbessern.

Kommentare

Noch keine Kommentare – stellen Sie die erste Frage zu diesem Tutorial.

Zum Kommentieren anmelden

Kommentare stehen centron-Kunden offen. Melden Sie sich in Ihrem Konto an, um eine Frage zu diesem Tutorial zu stellen.

Weiterlesen

Das könnte Sie auch interessieren

Jetzt kostenlos anfangen

Melden Sie sich an und erhalten Sie in den ersten 60 Tagen ein Guthaben von 200 € bei centron.

Dieses Werbeangebot gilt nur für neue Konten. Angebot ausschließlich für Gewerbetreibende.

Jetzt loslegen Sales kontaktieren