What is Nginx and why use it with cPanel?
Nginx is a high-performance web server that can function as a reverse proxy in front of Apache on cPanel servers. This configuration allows Nginx to handle static files (images, CSS, JavaScript) while Apache processes dynamic content (PHP), leveraging the strengths of both servers.
Prerequisites
- Server with cPanel/WHM and root access
- EasyApache 4 installed
- At least 2GB of available RAM
- 10GB of free space in /var for cache
Step-by-step installation
Step 1: Access EasyApache 4
- Log in to WHM as root
- Navigate to Software → EasyApache 4
- Click "Customize" on your current profile
Step 2: Install Nginx packages
In the "Additional Packages" tab, search for and install:
- ea-nginx - The base Nginx server
- ea-nginx-http2 - Support for HTTP/2 protocol
- ea-nginx-gzip - Gzip compression to reduce transfer size
Click "Next" then "Provision" to apply changes. The process will take 5-10 minutes.
EA-Nginx default configuration
Ports used
EA-Nginx automatically configures the following ports:
json{
"apache_port": "81",
"apache_port_ip": "127.0.0.1",
"apache_ssl_port": "444",
"apache_ssl_port_ip": "127.0.0.1"
}
- Nginx listens on ports 80 (HTTP) and 443 (HTTPS)
- Apache moves to ports 81 and 444 internally
Default cache configuration
nginxproxy_cache_valid 200 301 302 60m; # Successful responses: 60 minutes
proxy_cache_valid 404 1m; # 404 errors: 1 minute
Cache files are stored in /var/cache/ea-nginx/proxy/
Configuration file locations
- Global configuration:
/etc/nginx/nginx.conf - Per-user configuration:
/etc/nginx/conf.d/users/[username].conf - Templates:
/etc/nginx/ea-nginx/ - Logs:
/var/log/nginx/
Common issues and considerations
1. Dynamic content caching
Problem: The 60-minute cache can cause website changes to not appear immediately.
Symptoms:
- Clients report their changes don't appear
- Updated content doesn't reflect
- Forms seem to not work correctly
Solution: Clear cache from WHM → Nginx Manager → Clear Cache
2. .htaccess compatibility
Problem: Nginx doesn't process .htaccess files. Rewrite rules, redirects, and security configurations in .htaccess won't work for static files.
Impact:
- Custom redirects may fail
- Directory protection may not apply
- Custom cache rules ignored
3. Disk space usage
Cache can grow considerably:
- 100 sites ≈ 5GB
- 500 sites ≈ 25GB
This space is NOT counted in cPanel user quotas.
4. Duplicate logs
Logs are generated in both Nginx and Apache, duplicating space usage and complicating analysis.
How to uninstall Nginx
If you need to revert changes:
- In WHM → EasyApache 4 → Additional Packages
- Uncheck ea-nginx packages
- Provision to apply changes
- Clean residual cache:
bashrm -rf /var/cache/ea-nginx/
Monitoring and maintenance
Verify HTTP/2 status
bashcurl -I --http2 -s https://your-domain.com | grep HTTP
# Should show: HTTP/2 200
Clear cache manually
bash# For all sites
rm -rf /var/cache/ea-nginx/proxy/*
# Restart Nginx
systemctl restart nginx
When is implementing Nginx worth it?
Ideal scenarios:
- Sites with lots of static content (images, videos)
- Servers with high concurrency (>100 simultaneous visitors)
- When server CPU constantly exceeds 70%
- Well-optimized sites needing that extra speed boost
Scenarios where it's NOT recommended:
- Sites requiring frequent changes and real-time updates
- Applications heavily dependent on .htaccess configurations
- When support team isn't familiar with Nginx
- Sites with slow backends (the problem will persist)
Important considerations
Speed improvement with Nginx is most noticeable on already optimized sites. A site with slow database queries or poorly optimized code will remain slow, even with Nginx. Technology isn't a magic solution for programming issues.
The 60-minute cache can confuse users expecting immediate changes, leading to unnecessary support tickets or, worse, the perception that the hosting service has problems.
Need help with Nginx on your server?
At Webzi, we specialize in implementing and optimizing Nginx on cPanel servers. We understand both the benefits and complexities of this configuration.
If you need:
- Evaluate if Nginx is right for your project
- Custom implementation on your VPS or dedicated server
- Configuration optimization for specific cases
- Troubleshooting cache or compatibility issues
Contact us and our engineering team will evaluate your particular case. We can offer custom solutions, from special configurations to migration to servers specifically optimized for your type of application.
Remember: each project is unique and what works for one may not be ideal for another. At Webzi, we prefer to analyze each case individually to recommend the best technical solution, whether it's Nginx, LiteSpeed, or traditional Apache configuration.