For our Blog Visitor only Get Additional 3 Month Free + 10% OFF on TriAnnual Plan YSBLOG10
Grab the Deal

How to Optimize DirectAdmin on Linux Server – Easy Guide

To optimize DirectAdmin on a Linux server, update your stack with CustomBuild, switch to a modern web server and PHP-FPM, tune PHP, MySQL (MariaDB), and the kernel, enable caching (OPcache/Redis), harden with CSF and ModSecurity, and monitor resource usage. Back up first, test changes incrementally, and automate routine maintenance.

DirectAdmin is a lightweight, reliable control panel, but it needs smart tuning to reach peak performance and security. In this guide, I’ll show you how to optimize DirectAdmin on Linux server environments the way we do it for production sites—clean, safe, and measurable.

What Is DirectAdmin Optimization and Why It Matters

Optimization means configuring your OS, web stack, database, mail, DNS, and DirectAdmin services to reduce latency, handle more concurrent traffic, and stay secure. Done right, you’ll see faster PHP response times, lower CPU and RAM usage, fewer 5xx errors, and smoother email deliverability.

Prerequisites and Safety First

Check Your Environment

  • Linux distro: AlmaLinux/Rocky, CentOS Stream, Debian, or Ubuntu LTS
  • DirectAdmin with CustomBuild 2.x
  • Root or sudo access
  • Minimum 2 CPU cores, 4–8 GB RAM for small multi-site hosting

Backups and Staging

  • Create a full snapshot or image-level backup.
  • Use DirectAdmin > Admin Backup/Transfer for accounts and configs.
  • Apply changes during a maintenance window or on a staging server first.

Update the Stack and Establish a Baseline

System and CustomBuild Updates

# OS packages
sudo dnf -y update || sudo apt -y update && sudo apt -y upgrade

# DirectAdmin CustomBuild
cd /usr/local/directadmin/custombuild
./build update
./build versions

Keep PHP on a currently supported branch (8.2/8.3), Apache 2.4 with MPM Event, or consider OpenLiteSpeed for high concurrency. Always enable OPcache.

Select the Right Web Stack

  • Nginx as reverse proxy + Apache (nginx_apache): balanced, widely compatible.
  • Apache only (apache): simple, fine for low traffic.
  • OpenLiteSpeed (openlitespeed): fast and efficient, easy HTTP/3; great for WordPress.
cd /usr/local/directadmin/custombuild
# Example: Nginx reverse proxy + Apache + PHP-FPM + OPcache
./build set webserver nginx_apache
./build set php1_release 8.2
./build set php1_mode php-fpm
./build set opcache yes
./build set modsecurity yes
./build set modsecurity_ruleset owasp
./build all d
./build rewrite_confs

If you choose OpenLiteSpeed, set webserver to openlitespeed and rebuild. Test site functionality after switching.

Web Server and PHP Optimization

PHP-FPM Pool Tuning

Each DirectAdmin user or domain can have its own PHP-FPM pool. Size pools to avoid CPU thrash or memory exhaustion. Estimate pm.max_children using RAM/avg PHP process size (often 60–90 MB for WordPress).

; Example: /usr/local/php72/etc/php-fpm.d/user.domain.conf
[domain.com]
user = domain
group = domain
listen = /usr/local/php56/var/run/domain.sock
pm = dynamic
pm.max_children = 20
pm.start_servers = 4
pm.min_spare_servers = 4
pm.max_spare_servers = 8
pm.max_requests = 500
pm.process_idle_timeout = 10s
; Adjust per user based on traffic and RAM

For many small sites, pm = ondemand with conservative limits reduces idle memory. For busy sites, pm = dynamic offers more consistent latency.

OPcache Settings for Fast PHP

; php.ini or /usr/local/php*/lib/php.ini
opcache.enable=1
opcache.memory_consumption=192
opcache.interned_strings_buffer=16
opcache.max_accelerated_files=100000
opcache.validate_timestamps=1
opcache.revalidate_freq=60
opcache.save_comments=1

Increase opcache.memory_consumption if you host many sites. Restart PHP-FPM after changes.

Nginx Reverse Proxy Tweaks (if using nginx_apache)

# /etc/nginx/nginx.conf (snippet)
gzip on;
gzip_comp_level 5;
gzip_types text/plain text/css application/javascript application/json image/svg+xml;

# Example SSL server block directive
listen 443 ssl http2;

For HTTP/3, OpenLiteSpeed is the easiest path in DirectAdmin. Enable QUIC/HTTP/3 in the OLS listener and restart.

Database (MariaDB/MySQL) Optimization

Tune MariaDB based on RAM and workload. Focus on InnoDB buffer pool and log file size. Avoid legacy Query Cache on modern MariaDB.

# /etc/my.cnf.d/server.cnf or /etc/mysql/mariadb.conf.d/50-server.cnf
[mysqld]
# Example for 8 GB RAM server hosting WordPress
innodb_buffer_pool_size = 4G
innodb_log_file_size    = 1G
innodb_flush_log_at_trx_commit = 2
innodb_flush_method     = O_DIRECT
max_connections         = 200
tmp_table_size          = 256M
max_heap_table_size     = 256M
thread_cache_size       = 100
table_open_cache        = 4000
performance_schema      = ON
slow_query_log          = 1
slow_query_log_file     = /var/log/mysql-slow.log
long_query_time         = 1

Restart MariaDB after editing, then run a workload for a day and analyze slow queries. Use mysqltuner and pt-query-digest to refine settings and index-heavy queries.

sudo mysqltuner
sudo apt install percona-toolkit || sudo dnf install percona-toolkit
pt-query-digest /var/log/mysql-slow.log | less

Mail, DNS, and Essential Services

Email Stack (Exim/Dovecot) and Spam Control

  • Use Maildir, not mbox (DirectAdmin defaults to Maildir).
  • Enable SpamAssassin or Rspamd via CustomBuild (Rspamd is lighter and more accurate).
  • Limit concurrent SMTP connections to protect CPU/RAM.
# Enable Rspamd in CustomBuild
cd /usr/local/directadmin/custombuild
./build set exim yes
./build set dovecot yes
./build set spamassassin no
./build set rspamd yes
./build rspamd d
./build rewrite_confs

DKIM, SPF, and DMARC

From DirectAdmin > DNS Management, enable DKIM and create SPF and DMARC records for each domain. This improves deliverability and reputation.

DNS Performance: PowerDNS

PowerDNS is faster and uses fewer resources than BIND for most hosting cases.

cd /usr/local/directadmin/custombuild
./build set powerdns yes
./build set bind no
./build powerdns d
./build rewrite_confs

Caching and Acceleration

Redis Object Cache

Install Redis and use it for WordPress object caching. It reduces database load and improves time-to-first-byte.

# Install Redis server
sudo dnf -y install redis || sudo apt -y install redis
sudo systemctl enable --now redis

# In PHP, install redis extension via CustomBuild
cd /usr/local/directadmin/custombuild
./build set redis yes
./build redis d

Use a reputable plugin (e.g., “Redis Object Cache”) and set a unique prefix per site. For WooCommerce, enable session locking.

Static Assets and CDN

  • Leverage browser caching for images, CSS, JS.
  • Serve WebP/AVIF where possible.
  • Offload large assets and use a CDN to shrink TTFB globe-wide.

Security Hardening Without Losing Performance

CSF/LFD Firewall

ConfigServer Security & Firewall (CSF) integrates well with DirectAdmin. Whitelist your IPs, rate-limit login attempts, and block abusive ports.

# Basic CSF workflow
csf -e                # enable
csf -a YOUR_IP        # allowlist admin IP
csf -g 1.2.3.4        # grep IP status
csf -t                # view temp bans

ModSecurity (OWASP CRS) and Exclusions

Enable ModSecurity with the OWASP ruleset via CustomBuild, then add rule exclusions for legitimate apps when false positives occur. Monitor your Apache/Nginx error logs to identify blocked requests.

Let’s Encrypt, TLS 1.2/1.3, and ECDSA

  • Use Let’s Encrypt automation in DirectAdmin.
  • Prefer ECDSA certificates for performance (if clients support it).
  • Disable TLS 1.0/1.1; enforce strong ciphers.

SSH Hardening

  • Move SSH from port 22 (optional), allow only key auth, and disable root login if your workflow allows.
  • Install fail2ban if you’re not using LFD’s SSH protection.

System-Level Tuning (Kernel and Limits)

/etc/sysctl.conf Optimizations

# /etc/sysctl.d/99-directadmin-tuning.conf
fs.file-max = 2097152
net.core.somaxconn = 65535
net.ipv4.tcp_fin_timeout = 15
net.ipv4.tcp_syncookies = 1
net.ipv4.ip_local_port_range = 10240 65535
vm.swappiness = 10
fs.inotify.max_user_watches = 1048576

# apply
sudo sysctl --system

File Descriptors and Systemd Overrides

# Example for Nginx/Apache/MariaDB
sudo systemctl edit nginx
# then add:
# [Service]
# LimitNOFILE=1048576

sudo systemctl daemon-reload
sudo systemctl restart nginx

Logs and Rotation

  • Ensure logrotate is active for Apache/Nginx, PHP-FPM, Exim, Dovecot, and MySQL logs.
  • Limit journald size to prevent disk pressure (/etc/systemd/journald.conf).

Monitoring and Troubleshooting

Find Bottlenecks Quickly

# CPU/RAM
htop
atop

# Disk I/O
iotop -oPa

# Network
ss -tulpn

# Web errors
tail -f /var/log/httpd/error_log       # Apache (path may vary)
tail -f /var/log/nginx/error.log       # Nginx

# PHP-FPM
journalctl -u php-fpm --since "10 min ago"

# Mail
tail -f /var/log/exim/mainlog

Turn on MySQL slow query log and fix the top offenders. For WordPress, use Query Monitor to spot heavy plugins or themes.

Automation, Backups, and Safe Updates

DirectAdmin Admin Backup/Transfer

  • Schedule daily account backups with remote storage (SFTP/FTP/S3 via rclone).
  • Use incremental rsync for large datasets.
  • Test restores quarterly to ensure integrity.

Keep a Controlled Update Cadence

  • Apply OS security updates weekly.
  • Update PHP minor versions promptly; test major upgrades.
  • Track CustomBuild versions and rebuild services after changes.

Quick Wins and Common Pitfalls

  • Enable OPcache and PHP-FPM: easy speed boost.
  • Right-size PHP-FPM pools: prevents “Out of memory” and 502s.
  • Use Redis for WordPress object cache: trims database load.
  • Avoid enabling every ModSecurity rule; tune for your apps.
  • Don’t oversubscribe swap; watch iowait and disk health.

FAQs: Optimize DirectAdmin on Linux Server

What is the best web stack for DirectAdmin performance?

For general hosting, Nginx reverse proxy + Apache + PHP-FPM is a great balance. For maximum performance and simpler HTTP/3 support, OpenLiteSpeed performs exceptionally well, especially for WordPress. Always enable OPcache and size PHP-FPM pools appropriately.

How do I speed up PHP in DirectAdmin?

Use PHP-FPM (not CGI), enable OPcache with enough memory, upgrade to PHP 8.2/8.3, and tune pm.max_children based on RAM and average PHP process size. For dynamic sites, add Redis object cache to reduce database calls.

How should I tune MariaDB for multiple WordPress sites?

Start with InnoDB buffer pool around 50–70% of RAM, set innodb_log_file_size to 512M–1G, keep performance_schema ON for visibility, enable slow query logging, and iterate with mysqltuner and pt-query-digest. Use Redis object cache at the app layer.

Is ModSecurity necessary if I use a CDN/WAF?

Yes, a local WAF like ModSecurity adds protection when CDN/WAF rules miss or when requests bypass the CDN. Use OWASP CRS as a baseline and create exclusions for known safe patterns to keep false positives low and performance healthy.

Can I enable HTTP/3 (QUIC) on DirectAdmin?

Yes. The most straightforward route is OpenLiteSpeed in DirectAdmin, which supports HTTP/3 with simple listener settings. Nginx can support HTTP/3 with specific builds, but it’s more complex. Always test clients and fall back to HTTP/2 seamlessly.

Prahlad Prajapati

Prahlad is a web hosting specialist and SEO-focused organic growth expert from India. Active in the digital space since 2019, he helps people grow their websites through clean, sustainable strategies. Passionate about learning and adapting fast, he believes small details create big success. Discover his insights on web hosting and SEO to elevate your online presence.

Leave a Comment

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

Scroll to Top