Short answer: install NGINX on a cPanel host through WHM’s built-in NGINX Manager (or Engintron), which runs it alongside Apache — cPanel’s own documentation covers the install path. For the config that usually follows: restrict HTTP methods with limit_except GET HEAD POST rather than an if block, and rate-limit with limit_req_zone plus limit_req.
An earlier version of this page’s table of contents jumped from “Step 8: Enhancing Security” straight to “Step 10: Monitoring NGINX Performance.” There was no Step 9. That’s not a typo you make by hand — it’s the kind of gap that shows up when generated text is never read back before publishing. This rewrite is shorter than the original for the same reason: most of what was in the missing steps couldn’t be verified on this machine anyway, so it isn’t republished as if it had been.
The method-restriction snippet, and a correction to this page’s own research
The security section’s HTTP-method restriction used nginx’s if directive:
server {
location / {
if ($request_method !~ ^(GET|HEAD|POST)$) {
return 405;
}
}
}
The brief for this rewrite said to check nginx’s own “If Is Evil” guidance and quote it accurately — so here’s the correction to that premise: the live page is gone. nginx.com/resources/wiki/start/topics/depth/ifisevil/ now redirects to a generic docs landing page; F5 took the wiki down after acquiring nginx. The content survives at the Internet Archive’s 2023 snapshot and as source in nginx’s own GitHub mirror, titled “If is Evil… when used in location context.” Its actual rule: the only 100% safe things inside an if in a location block are return and rewrite ... last — “anything else may possibly cause unpredictable behaviour, including potential SIGSEGV.” The snippet above only uses return, so it’s on the documented safe list, not the danger list this rewrite was briefed to find.
It’s still not the right tool for the job, because nginx ships a directive built specifically for this:
location / {
limit_except GET HEAD POST {
deny all;
}
}
limit_except (documented at nginx.org) does the same restriction without a regex or a conditional, and it’s the form nginx recommends over reaching for if whenever a purpose-built directive already exists.
The rate-limiting snippet checks out
The earlier version’s rate-limiting example matches nginx’s documented syntax for limit_req_zone and limit_req exactly, verified against the current module docs — no correction needed there:
limit_req_zone $binary_remote_addr zone=one:10m rate=10r/s;
server {
location / {
limit_req zone=one burst=20 nodelay;
}
}
What this page can’t verify
Installing nginx alongside Apache on a cPanel/WHM host (via Engintron or WHM’s built-in manager), the performance-tuning steps, and the SEO/caching claims all require a live cPanel install that doesn’t exist here. Rather than republish those steps as if they’d been checked, this rewrite defers to cPanel’s own NGINX Manager documentation for the install path, and to Apache vs. nginx for PHP for what actually changes on a server when you add nginx in front of Apache.
Check this yourself. Every command and every block of output on this page is reproduced by /verify/how-to-install-nginx-cpanel.sh. Download it and run it: it creates its own scratch files, prints one line per claim, cleans up after itself, and exits non-zero if any claim here turns out to be wrong. If it disagrees with this page, the page is wrong.