Skip to content

Plesk's Apache + nginx dual stack — when it helps, when it hurts, how to tune it

Plesk runs nginx in front of Apache by default. Sometimes that helps. Sometimes Apache should be skipped entirely. Here's how to decide and tune each tier.

A Plesk host serves traffic through nginx, which terminates TLS and either serves static files itself or proxies dynamic requests back to Apache running on 127.0.0.1:7080. On most hosting workloads this is fine. On a fleet with high concurrent traffic and small static surface, Apache becomes the bottleneck because every dynamic request burns an MPM worker, and the default MPM tuning was designed for a server doing maybe a dozen requests per second, not five hundred. The right tuning depends on whether you actually need Apache in the path.

What’s happening

Plesk’s default web stack on AlmaLinux 9 / Ubuntu 22.04 is:

  1. nginx on ports 80/443, with TLS termination, static file serving, gzip, and proxy_pass back to Apache for anything dynamic.
  2. Apache on 127.0.0.1:7080 (and :7081 for HTTPS internally), with the event or prefork MPM and mod_php or mod_proxy_fcgi to PHP-FPM.
  3. PHP-FPM in per-domain pools, listening on Unix sockets.

The dual stack exists because Plesk has historically supported .htaccess (which is an Apache feature) and wanted to keep that compatibility while also benefiting from nginx’s speed on static files and TLS. On a typical shared-hosting workload with many small PHP sites, that’s a reasonable default.

It hurts when:

  • You’re serving a single large application with no .htaccess requirements. The Apache layer adds latency on every dynamic request for no benefit.
  • The MPM worker pool isn’t sized for your actual concurrency. Default MaxRequestWorkers is often 256, which sounds high until you realize it’s the cap on concurrent dynamic requests, not the cap on connections.
  • Apache’s keepalive settings cause connection exhaustion. nginx has its own keepalive to backends, and if you stack default settings on default settings, the backend connection pool can saturate before the worker pool does.

It helps when:

  • You inherit applications that depend on .htaccess features nginx doesn’t fully emulate (mod_rewrite edge cases, mod_security rules, mod_pagespeed). Apache stays.
  • The site uses Apache-specific authentication modules. nginx-only can’t easily replicate mod_auth_kerb or mod_auth_form.

How to verify

Identify what your stack is actually doing under load. Start with the nginx configuration:

# Plesk's per-domain nginx config
ls /var/www/vhosts/system/example.com/conf/
cat /var/www/vhosts/system/example.com/conf/last_nginx.conf

# Confirm Apache is in the chain
grep -i proxy_pass /var/www/vhosts/system/example.com/conf/last_nginx.conf
# proxy_pass http://127.0.0.1:7080;  <- this means Apache is in the path

Check Apache MPM settings:

# Which MPM is loaded
httpd -M 2>/dev/null | grep -i mpm
# Or on Ubuntu/Debian:
apachectl -M 2>/dev/null | grep -i mpm

# Current settings
grep -E 'StartServers|MinSpare|MaxSpare|MaxRequestWorkers|ThreadsPerChild|MaxConnectionsPerChild' \
  /etc/httpd/conf.modules.d/00-mpm.conf \
  /etc/httpd/conf/httpd.conf 2>/dev/null

# Live status
apachectl status 2>/dev/null || curl -s http://127.0.0.1:7080/server-status?auto

Watch the worker pool under live traffic:

# Active workers per state
watch -n2 'curl -s http://127.0.0.1:7080/server-status?auto | head -20'

# Or from the process list
watch -n2 'ps aux | grep -c "[h]ttpd"'

Check nginx-to-Apache connection state:

# Connections waiting on Apache backend
ss -tan state established '( dport = :7080 or sport = :7080 )' | wc -l

# nginx active connections
curl -s http://127.0.0.1/nginx_status 2>/dev/null
# Or read the access logs and count concurrent requests
awk '{print $4}' /var/log/nginx/access.log | tail -1000 | sort | uniq -c

The fix

Two paths depending on whether Apache is helping or just adding latency.

Path A — Apache helps, tune the MPM

If .htaccess and Apache modules are in use, keep Apache, but right-size the MPM. For the event MPM on a host with 8 GB RAM:

# /etc/httpd/conf.modules.d/00-mpm.conf (RHEL/Alma)
cat > /etc/httpd/conf.modules.d/99-mpm-tuning.conf <<'EOF'
LoadModule mpm_event_module modules/mod_mpm_event.so

<IfModule mpm_event_module>
  StartServers             4
  MinSpareThreads         50
  MaxSpareThreads        150
  ThreadsPerChild         50
  MaxRequestWorkers      400
  ServerLimit              8
  MaxConnectionsPerChild 10000
</IfModule>

KeepAlive On
KeepAliveTimeout 2
MaxKeepAliveRequests 100
EOF

# Disable the prefork module if it's loaded
sed -i 's|^LoadModule mpm_prefork|#LoadModule mpm_prefork|' /etc/httpd/conf.modules.d/00-mpm.conf

# Validate config and restart
apachectl -t && systemctl restart httpd

Calculation: MaxRequestWorkers = ServerLimit * ThreadsPerChild. The default 256 was 16 * 16 prefork; on event you can get 400 concurrent with 8 children of 50 threads each, using a fraction of the memory.

For mod_php (in-process), the math is different — each Apache worker holds an entire PHP interpreter, so memory scales with worker count. Better to use PHP-FPM via mod_proxy_fcgi:

# In Plesk: panel → Service Plans → PHP settings → PHP handler type → "FPM application served by Apache"
# Or CLI:
plesk bin domain --update example.com -php_handler_type fpm

PHP-FPM pool tuning on Plesk:

# Per-domain pool config
ls /opt/plesk/php/8.2/etc/php-fpm.d/
cat /opt/plesk/php/8.2/etc/php-fpm.d/example.com.conf

# Default values are often pm.dynamic with low max_children. For a busy WordPress site:
plesk bin domain --update example.com \
  -php_settings 'pm=dynamic;pm.max_children=30;pm.start_servers=8;pm.min_spare_servers=4;pm.max_spare_servers=12;pm.max_requests=500'

systemctl reload plesk-php82-fpm

Path B — Skip Apache, nginx-only

If your application has no .htaccess dependency (modern WordPress with a static permalink config, a Laravel/Symfony app with proper rewrite rules, a Node.js app proxied directly), you can switch the domain to “Smart static files processing by nginx, PHP via nginx + PHP-FPM” mode:

# In the panel: domain → Apache & nginx Settings → uncheck "Proxy mode"
# CLI:
plesk bin site --update example.com -nginx_php_handler true

When proxy mode is off, nginx talks directly to PHP-FPM. Apache is no longer in the request path for this domain. Test:

# Confirm Apache is no longer being hit for dynamic requests
curl -s -o /dev/null -w "%{http_code} %{time_total}\n" https://example.com/some-php-page.php
ss -tan state established '( dport = :7080 )' | grep example.com
# Should show no Apache connections from this domain

You must port any .htaccess rewrite rules to the nginx config — there’s a Plesk UI for “Additional nginx directives” on the domain. Translate:

# .htaccess
RewriteEngine On
RewriteRule ^api/v1/(.*)$ /api.php?route=$1 [L,QSA]
# Additional nginx directives
location /api/v1/ {
  rewrite ^/api/v1/(.*)$ /api.php?route=$1 last;
}

Common mistake: forgetting WordPress permalink rewrites:

location / {
  try_files $uri $uri/ /index.php?$args;
}

Tune nginx itself

Regardless of path A or B, the nginx defaults are conservative for a busy Plesk host. Plesk lets you edit /etc/nginx/nginx.conf directly but it will rewrite per-domain configs from templates on reconfigure. Edits to the global nginx.conf survive.

# /etc/nginx/nginx.conf
worker_processes auto;
worker_rlimit_nofile 65535;

events {
  worker_connections 4096;
  use epoll;
  multi_accept on;
}

http {
  client_body_buffer_size 256k;
  client_max_body_size 64m;
  client_header_buffer_size 1k;
  large_client_header_buffers 4 16k;

  keepalive_timeout 30;
  keepalive_requests 100;

  gzip on;
  gzip_types text/plain text/css application/json application/javascript text/xml application/xml;

  # Upstream keepalive to Apache (Path A only)
  upstream apache_backend {
    server 127.0.0.1:7080;
    keepalive 32;
  }
}

Reload:

nginx -t && systemctl reload nginx

Verify the tuning helped

Re-run the load metrics and compare. A measurable win shows up as:

  • Lower p95 latency on dynamic requests (look at nginx access logs with $request_time).
  • Fewer requests waiting on Apache backend connections (ss -tan dport :7080).
  • Lower memory per request (ps aux | grep httpd average RSS).

Without a synthetic load tool, watch one peak hour and compare to the prior week:

# Average request time per minute
awk '{print substr($4,1,17), $NF}' /var/log/nginx/access.log | \
  awk -F'[][]' '{print $2, $3}' | sort | uniq -c | head

Stack Harbor tunes Plesk hosting stacks under environment management — including the decision of whether Apache stays in the path per-domain, MPM right-sizing, and PHP-FPM pool tuning that doesn’t get clobbered on panel reconfigure. Pair it with monitoring and support so capacity is tracked against actual traffic curves — or contact us if your Plesk fleet is hitting worker exhaustion under peak.