Control panels

Tune Apache settings in WHM Global Configuration

Adjust KeepAlive, Timeout, ServerLimit and MaxRequestWorkers in WHM, and add custom Apache directives with the Include Editor so they survive rebuilds.

AdvancedLinux server4 min read

On a cPanel server you should never edit httpd.conf directly. cPanel rebuilds that file from templates, and your change disappears at the next account creation or update. Instead, WHM gives you Global Configuration for the common settings and the Include Editor for anything else. This guide covers both and how to test changes before they go live.

Note: You buy one from cPanel or a partner and install it on your Linux VPS.

Before you start

  • Root access to WHM and SSH.
  • Know your MPM. Run /usr/sbin/httpd -V | grep -i mpm. Worker limits mean different things under prefork and event.
  • A copy of the current configuration:
Bash
  cp -a /etc/apache2/conf/httpd.conf /root/httpd.conf.$(date +%F)

Open Global Configuration

In WHM, go to Service Configuration » Apache Configuration and click Global Configuration. Each field maps to an Apache directive. When you click Save, WHM rebuilds httpd.conf, checks the syntax and restarts Apache. If the check fails, WHM keeps the old configuration.

Settings worth reviewing

KeepAlive

  • Keep-Alive: lets a browser reuse one connection for several files. Leave it On.
  • Keep-Alive Timeout: seconds Apache keeps an idle connection open. Under prefork, each idle connection holds a whole process, so keep this short, for example 2 to 5. Under event, idle connections are cheap and a slightly longer value is fine.
  • Max Keep-Alive Requests: requests allowed per connection. A value of 100 or more is normal.

Timeout

Timeout is how long Apache waits on a slow client or backend. The Apache default is high. A value such as 60 to 120 stops stuck connections from piling up, but long uploads or slow reports may need more. Match it to your longest legitimate PHP request.

ServerLimit and Max Request Workers

  • Max Request Workers: the maximum number of requests served at the same time. Requests above this wait in a queue.
  • Server Limit: the maximum number of Apache processes.

Under prefork, MaxRequestWorkers equals the number of processes, so it is limited by RAM. Under event or worker, MaxRequestWorkers is ServerLimit multiplied by ThreadsPerChild. Size it against your PHP-FPM capacity, as explained in switch Apache MPM to event.

Warning: Setting MaxRequestWorkers far above what memory allows under prefork can make the server swap and stop responding under load. Raise it in small steps.

Other useful fields

  • Server Tokens and Server Signature: set to the least revealing options so Apache does not advertise its version.
  • Trace Enable: set to Off.

Add custom directives with the Include Editor

For directives without a field, open Service Configuration » Apache Configuration » Include Editor. There are three include points:

  • Pre Main Include: at the top of httpd.conf, before the main settings. Use it for global directives such as ThreadsPerChild or extra modules settings.
  • Pre VirtualHost Include: after the main settings and before the virtual hosts. Use it for directives that every site should inherit.
  • Post VirtualHost Include: at the end of the file.

Choose All Versions from the menu, add your lines and click Update. For example, to add a security header to every site:

Apache
<IfModule mod_headers.c>
    Header always set X-Content-Type-Options "nosniff"
</IfModule>

The include files are stored in /etc/apache2/conf.d/includes/, such as pre_virtualhost_global.conf. They survive rebuilds.

Per-domain custom directives

To change one site only, create a file in the userdata include folder for that domain, then rebuild:

Bash
mkdir -p /etc/apache2/conf.d/userdata/ssl/2_4/USER/example.com
nano /etc/apache2/conf.d/userdata/ssl/2_4/USER/example.com/custom.conf
/scripts/rebuildhttpdconf
/usr/sbin/httpd -t && /scripts/restartsrv_httpd

Use the std folder instead of ssl for plain HTTP. Replace USER with the cPanel username.

Check it works

Test the syntax and confirm a directive is active:

Bash
/usr/sbin/httpd -t
grep -n "KeepAliveTimeout\|MaxRequestWorkers" /etc/apache2/conf/httpd.conf
curl -sI https://example.com | grep -i x-content-type

Syntax OK and your new values in the output show the change is live.

Troubleshooting

  • Change lost after an update: you edited httpd.conf directly. Move the change into Global Configuration or an include file.
  • WHM refuses to save: the syntax check failed. Read the error, fix the include and save again.
  • "server reached MaxRequestWorkers" in /etc/apache2/logs/error_log: raise it gradually and check that memory and PHP-FPM can keep up.
  • Slow uploads cut off: Timeout is too short for large uploads. Raise it for the whole server or in a per-domain include.

Next steps

Was this guide helpful?

Still stuck?

Ask MdmHost AI for a quick answer, or open a ticket and our team will take a look. We are here 24/7.