Optimized WordPress setup running on a DirectAdmin VPS server

The Ideal WordPress Performance Stack for a DirectAdmin VPS

, , ,

Series: WordPress Performance on DirectAdmin (Rocky Linux 9)

Phase 8: Authority & Wrap-Up — Part 30 of 30

The Ideal WordPress Performance Stack for a DirectAdmin VPS

Running WordPress efficiently on a DirectAdmin VPS with Rocky Linux 9 requires a carefully tuned stack. This article provides actionable steps and configurations tailored for sysadmins, with focus on the specifics of DirectAdmin’s management of PHP-FPM pools, NGINX/Apache integration, and per-domain tuning. All commands use Rocky Linux 9 paths and package management. We cover install, configuration, testing, and validation with safe, reproducible steps.

Stack Overview

  • OS: Rocky Linux 9 (EL9)
  • Control Panel: DirectAdmin (latest stable)
  • Web Server: Apache 2.4 with mod_php (default), or NGINX as reverse proxy (recommended for performance)
  • PHP Handler: PHP-FPM (per-user pool, DirectAdmin-managed)
  • Database: MariaDB 10.5+ (DirectAdmin default)
  • Cache Layer: Opcache, Redis (php-redis), and full-page caching plugin (e.g., WP Super Cache)
  • SSL: Let’s Encrypt (via DirectAdmin integration)

DirectAdmin-Specific Considerations

  • PHP-FPM pools are managed per-user or per-domain. Editing /usr/local/directadmin/data/users/<user>/php-fpmXX.conf is standard. Always use DirectAdmin’s custom templates for persistent changes.
  • Web server configs are built from templates in /usr/local/directadmin/data/templates/. After editing templates, run sudo /usr/local/directadmin/custombuild/build rewrite_confs.
  • Per-domain tuning should use DirectAdmin’s panel overrides or user-level custom configs to persist after updates.

Step 1: Base System Preparation

  1. Update OS and Packages
    sudo dnf update -y
    sudo dnf install epel-release -y
  2. Install DirectAdmin (if not already provisioned)

    Follow the official DirectAdmin install docs for Rocky Linux 9. Do not run on production without backups.

  3. Check for Existing Services
    sudo systemctl status httpd
    sudo systemctl status nginx
    sudo systemctl status php-fpm
  4. Firewall Configuration
    • Open HTTP/HTTPS ports:
    • sudo firewall-cmd --permanent --add-service=http
      sudo firewall-cmd --permanent --add-service=https
      sudo firewall-cmd --reload

Step 2: PHP-FPM and Opcache Tuning

Checklist

  • Use DirectAdmin’s PHP selector to install PHP 8.1 or 8.2 (current stable).
  • Enable Opcache and adjust settings for WordPress workloads.
  • Apply changes via DirectAdmin’s custom templates for persistence.

Example Opcache Configuration (/usr/local/phpXX/lib/php.ini):

[opcache]
opcache.enable=1
opcache.memory_consumption=192
opcache.interned_strings_buffer=16
opcache.max_accelerated_files=10000
opcache.validate_timestamps=1
opcache.revalidate_freq=60

Reload PHP-FPM after changes:

sudo systemctl reload php-fpmXX

Note: Replace XX with your PHP version.

Step 3: Install and Configure Redis for Object Caching

  1. Install Redis
    sudo dnf install redis -y
    sudo systemctl enable --now redis
  2. Install PHP Redis Extension (using CustomBuild):
    cd /usr/local/directadmin/custombuild
    sudo ./build set php_redis yes
    sudo ./build php_redis
  3. Restart PHP-FPM:
    sudo systemctl restart php-fpmXX

Testing Redis and WordPress Integration

  • Install a Redis object cache plugin (e.g., Redis Object Cache) via WP-CLI:
  • cd /home/<user>/domains/<domain>/public_html
    wp plugin install redis-cache --activate
    wp redis enable
  • Check Redis status:
  • wp redis status

Step 4: Web Server Mode and Caching

DirectAdmin Web Server Options

  • Apache Only: Simple, but less efficient for static assets.
  • NGINX as Reverse Proxy (recommended): Use DirectAdmin’s web server settings to enable NGINX in front of Apache for better concurrency and static file serving.

Enabling NGINX Reverse Proxy

  1. Switch in DirectAdmin: Admin Level → Service Configuration → Web Server Settings
  2. Choose “nginx_apache” and apply changes (downtime: a few seconds while services restart).
  3. Verify service status:
  4. sudo systemctl status nginx
    sudo systemctl status httpd

Static Asset Caching (NGINX Template Customization)

Customize /usr/local/directadmin/data/templates/nginx_server.conf with:

location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
    expires 30d;
    add_header Pragma public;
    add_header Cache-Control "public";
}

After changes, rebuild configs:

sudo /usr/local/directadmin/custombuild/build rewrite_confs

Step 5: Database Tuning (MariaDB)

  • Edit /etc/my.cnf.d/server.cnf (or /etc/my.cnf on some installs):
[mysqld]
innodb_buffer_pool_size=512M
innodb_log_file_size=128M
max_connections=100
query_cache_type=0

Restart MariaDB after changes:

sudo systemctl restart mariadb

Step 6: WordPress-Level Caching and Optimizations

  • Install a proven full-page cache plugin (WP Super Cache, W3 Total Cache, or similar):
  • wp plugin install wp-super-cache --activate
  • Ensure all caching layers (object + full-page) are tested for synergy and do not conflict.
  • Disable unnecessary plugins and themes:
  • wp plugin deactivate plugin-name
    wp theme delete unused-theme

Step 7: Monitoring and Testing

Checklist

  • Test site response time:
  • curl -I https://yourdomain.com
  • Load test with wrk or k6 (install as needed):
  • sudo dnf install wrk -y
    wrk -t4 -c40 -d30s https://yourdomain.com/
  • Monitor logs for errors:
  • sudo tail -f /var/log/nginx/error.log
    sudo tail -f /var/log/httpd/error_log
    sudo tail -f /var/lib/php-fpm/XX.log
  • Check WordPress status with WP-CLI:
  • wp plugin status
    wp cache flush

Step 8: Maintenance and Hardening

  • Keep DirectAdmin, PHP, and MariaDB up to date via CustomBuild and dnf.
  • Regularly audit performance and error logs.
  • Automate backups (DirectAdmin backup manager or external solutions).

Sample Quick Reference Checklist

  • OS and DirectAdmin up to date
  • PHP-FPM + Opcache tuned
  • Redis installed and active for object caching
  • NGINX reverse proxy enabled and properly caching static assets
  • MariaDB tuned for available RAM
  • WordPress-level caching plugin active
  • All changes tested with WP-CLI and HTTP load tools

Summary

The best WordPress stack for DirectAdmin on Rocky Linux 9 uses NGINX in front of Apache, PHP-FPM with Opcache, Redis for object caching, and MariaDB with tuned buffers. Customize templates for persistence. Always test changes with WP-CLI and HTTP benchmarking tools. Monitor logs and automate updates for ongoing stability.

Note: This article offers general technical guidance. Validate all configurations in a safe environment before applying them to production.

Previous: The Complete WordPress Performance Checklist

Smart reads for curious minds

We don’t spam! Read more in our privacy policy