Nginx vs Apache for cPanel – which one should you use?
August 12, 2018 TMZ Team

Apache and Nginx are the most popular web servers in the world and it is estimated that 70% of the web traffic in the world uses one of them.

Both are very robust solutions that have been developed for a long time and have strong communities, but which one should you choose for your cPanel server?

There is no clear answer to this question, since both have a number of strengths and weaknesses. The best option depends on your specific needs and your level of technical expertise, in this article we will go through the differences between Apache and Nginx and show you how to use them in a cPanel environment.

The Apache web server

Apache is the most popular and used web server in the world and has played a key role in the early development and expansion of the Internet. According to the latest estimates, 43% of all websites in the world are served by Apache, even if its market share is slowly decreasing.

The biggest strengths of Apache come from its widespread use: it is very well documented and supported. Apache is compatible with any platform or application and also very flexible, with a large number of modules and customizations.

Technically, Apache relies on a so-called forked solution, which spawns processes in order to handle incoming connections.

This can be an issue on websites with a lot of traffic because the server can eventually run out of CPU or RAM. Apache is also vulnerable to several types of attacks that exhaust all available workers, basically knocking the site offline.

Apache is the default web server in cPanel, where it is installed and configured out of the box.

WHM offers an excellent tool named EasyApache 4 (the latest version) that greatly simplifies Apache administration.

It comes with several profiles already set up that can be further modified, with various PHP versions, Apache modules, as well as PHP and Ruby extensions.

The advantages of Nginx

Nginx is a newer web server solution that was designed from the start to be able to handle a much greater number of connections, responding to the increased traffic of modern websites.

Unlike Apache, Nginx doesn’t spawn additional processes and the recommended setup is to have one worker per CPU core.

Its architecture is asynchronous and event-driven, which allows it to run on very low hardware resources and handle heavy loads without using all available CPU and system memory.

In addition, Nginx offers several other features and can serve as a load balancer, caching server or as a reverse proxy. It is excellent at serving cached static pages.

cPanel doesn’t officially support Nginx but you can still use it on your server. There are several ways to install it, we will present the most common options.

Installing Nginx from the command line

Before installing Nginx, go to Home – Service Configuration – Service Manager and disable Apache, make sure you uncheck both the Enabled and Monitor boxes.

You can then install the new webserver with these terminal commands:

Turn on the service and enable it at boot:

The disadvantage of this option is that it doesn’t integrate Nginx with cPanel in any way, so the entire configuration must be done manually.

The best of both worlds

There are several cPanel plugins that install Nginx and offer a graphical interface for it.

The best one at the moment is Engintron, which sets up Nginx as a frontend to Apache and allows you to take advantage of the best features of both web servers.

Nginx will handle requests and serve cached content, so your server will respond faster and allow a large number of connections.

In the background, Apache will take care of the dynamic pages, so you can continue to profit from its flexibility and features like the .htaccess file.

Installing Engintron takes a few minutes, you have to run these commands in the Terminal:

The plugin will then be active in the Plugins section of WHM. The initial configuration works well out of the box, for further tweaks it is recommended to edit the custom_rules file directly from the GUI.

The plugin also allows you to reload or update Engintron and even to stop it completely. Tweaks to other services, such as Apache or MySQL, are also possible from the interface.

 

In the end, the web server choice depends on your site’s load and your Linux skills.

If you run sites without a lot of traffic, the Apache server bundled with cPanel works very well and is easy to setup. For additional speed and performance Nginx is the obvious solution, with Engintron providing the most convenient way to integrate it in your cPanel environment.