Home » Cpanel/WHM » Install nginx as reverse proxy in cPanel

Install nginx as reverse proxy in cPanel

The web-hosting control panel’s default web-server is Apache. cPanel/WHM doesn’t have native support on Nginx, but we can install and configure it so that it will improve the server performance.

Why run Apache and Nginx together? Is there any advantage by using Nginx as reverse proxy on Cpanel?

Both Apache and Nginx are powerful and effective web-servers. Apache is the topmost webserver since it was released in 2006 and Nginx is now using top websites. The reason for using Apache and Nginx are clear, Apache’s power and Nginx’s speed. By setting Nginx as reverse proxy, we can increase the website’s speed and performance on the server. This is because, Nginx will take care of all static contents in the website such as CSS, images, SWF files, MP4 and more. Apache will manage the rest of requests (dynamic requests – php page). This is known as a Nginx reverse proxy setup. Nginx stand as a front end server with a powerful backend Apache server.

How to set up?

If you wish to install nginx as reverse proxy on Cpanel then, follow these steps:

1. SSH to server as root.
2. Change the directory to “/usr/local/src”

# cd /usr/local/src

Download the latest nginxadmin package & install

#wget http://nginxcp.com/latest/nginxadmin.tar 
#tar xf nginxadmin.tar
#cd publicnginx
#./nginxinstaller install

In WHM, Nginx Admin plugin will now be available under plugins section. After installing make sure Nginx process is running on the server, You can chcek this by using the following command.

# ps aux | grep nginx

If it is not showing any process, then kill httpd and restart httpd

#killall -9 httpd
#/etc/init.d/httpd restart

Nginx Admin Uninstall instruction:

#cd /usr/local/src 
#wget http://nginxcp.com/latest/nginxadmin.tar 
#tar xf nginxadmin.tar 
#cd publicnginx
#./nginxinstaller uninstall 

P.S. Make sure that the Nginx is running on port 80 and Apache on different port (like 8080). Don’t forget to open the new port the server firewall.

Originally posted 2016-01-11 05:53:21.

About admin

I have been working with Linux based systems since 2002. I hope the article published on this site will be useful to those new to server administration.