Introduction
cPanel is one of the most widely used web hosting control panels and ships with Apache as its default web server. While Apache is highly flexible and compatible with most web applications, Nginx is known for its superior performance, lower memory consumption, and ability to handle a large number of concurrent connections efficiently.
By deploying Nginx in front of Apache, you can improve website performance, reduce server load, and enable advanced caching capabilities without affecting existing cPanel functionality.
In this tutorial, we will install Nginx on a cPanel server using the Engintron plugin. Engintron automatically configures Nginx as a reverse proxy, moves Apache to port 8080, and allows Nginx to listen on the standard HTTP port 80.
How This Nginx Setup Works
Internet
|
v
+---------------+
| Nginx |
| Port : 80 |
+---------------+
|
v
+---------------+
| Apache |
| Port : 8080 |
+---------------+
|
v
+---------------+
| Website Files |
+---------------+
Traffic Flow:
- Visitor sends a request to the website.
- Nginx receives the request on port 80.
- Static content is served directly by Nginx whenever possible.
- Dynamic requests are forwarded to Apache on port 8080.
- Apache processes the request and returns the response through Nginx.
Prerequisites
Before proceeding, ensure you have:
- A cPanel/WHM server
- Root SSH access
- WHM administrative access (
https://SERVER-IP:2087) - Internet connectivity from the server
Installation Steps
Step 1: Log in to the Server
Connect to the server via SSH as the root user.
ssh root@server-ip
Step 2: Download the Engintron Installer
Download the latest Engintron installation script.
wget --no-check-certificate https://raw.githubusercontent.com/engintron/engintron/master/engintron.sh
Step 3: Install Engintron
Run the installation script.
bash engintron.sh install
The installation process may take a few minutes depending on the server specifications and internet connectivity.
Step 4: Access the Engintron Plugin
Once the installation is complete:
- Log in to WHM.
- Navigate to Plugins.
- Click Engintron for cPanel/WHM.
You should see the Engintron management interface where you can:
- Manage Nginx configuration
- Clear cache
- Restart Nginx
- Restart Apache
- Update Engintron
Verification
Verify Nginx Service Status
Check whether the Nginx service is running.
/etc/init.d/nginx status
Expected output should indicate that the service is active and running.
Verify Through HTTP Headers
Send a request to your domain and inspect the response headers.
curl -I domain.tld
Example output:
Server: nginx Date: Thu, 16 Nov 2017 05:16:55 GMT Content-Type: text/html; charset=UTF-8 Connection: keep-alive Location: http://domain.tld/ X-XSS-Protection: 1; mode=block X-Content-Type-Options: nosniff X-Nginx-Cache-Status: MISS X-Server-Powered-By: Engintron
The presence of:
Server: nginx X-Server-Powered-By: Engintron
confirms that Nginx is successfully installed and serving requests.
Benefits of Using Nginx with cPanel
- Faster handling of static content
- Improved website performance
- Reduced Apache resource usage
- Better handling of high traffic websites
- Built-in reverse proxy functionality
- Optional caching support through Engintron
- Easy management through WHM
Frequently Asked Questions (FAQ)
1. Will installing Engintron replace Apache on my cPanel server?
No. Engintron does not replace Apache. It installs Nginx as a reverse proxy in front of Apache. Apache continues to process dynamic content while Nginx handles incoming requests and static assets.
2. Can I uninstall Engintron if needed?
Yes. Engintron includes an uninstall option that restores the original Apache-only configuration.
bash engintron.sh remove
Always create a server backup before making major web server changes.
3. How can I verify that Nginx caching is working?
You can inspect the response headers using:
curl -I domain.tld
Look for headers such as:
X-Nginx-Cache-Status: HIT
which indicate that content is being served from the cache.
Conclusion
Installing Nginx on a cPanel server using Engintron is a quick and effective way to improve website performance without replacing Apache. By placing Nginx as a reverse proxy in front of Apache, you gain the performance benefits of Nginx while maintaining full compatibility with cPanel and existing hosted websites. The installation process is straightforward, and ongoing management can be performed directly from the WHM interface.
Related Articles
- How to Enable Expires Headers and GZIP Compression in Nginx
- How to Install an SSL Certificate on Nginx (Ubuntu 16.04)
- Install Nginx and Let’s Encrypt SSL with Docker on Ubuntu 20.04
Talk to our experts
Looking for the right technology solution for your business? Our team of experts can help you with development, cloud, DevOps, design, and a wide range of other technology needs. Get in touch with our team here.