{"id":56037,"date":"2020-06-25T15:38:36","date_gmt":"2020-06-25T20:38:36","guid":{"rendered":"https:\/\/blog.cpanel.com\/?p=56037"},"modified":"2020-06-25T15:38:36","modified_gmt":"2020-06-25T20:38:36","slug":"how-to-install-and-manage-nginx-on-cpanel","status":"publish","type":"post","link":"https:\/\/devel.www.cpanel.net\/blog\/products\/how-to-install-and-manage-nginx-on-cpanel\/","title":{"rendered":"How to Install and Manage NGINX on cPanel"},"content":{"rendered":"\n
Although Apache and NGINX are both web servers, they approach the task of serving web pages differently. Each has advantages and trade-offs, which prompts the question: can I use NGINX with cPanel? <\/p>\n\n\n\n
The short answer is yes, you can use NGINX with cPanel; however, its integration is a little tricky. Let\u2019s explore the ways cPanel users can take advantage of NGINX\u2019s strengths, and look at how we are working to make NGINX a viable alternative to Apache on cPanel servers.<\/p>\n\n\n\n
cPanel and Apache have decades of shared history, and Apache is deeply integrated into cPanel, which depends on Apache for many of its features. NGINX currently serves 32 percent of websites, versus Apache accounting for 37 percent of websites served on the internet. So what is NGINX, and what does it do differently than Apache?<\/p>\n\n\n\n
NGINX is a web server, load balancer, and reverse caching proxy. Like all web servers, it accepts HTTP requests and responds with HTML documents. NGINX was developed in response to perceived weaknesses in the way Apache handled network connections and requests.<\/p>\n\n\n\n
Initially, Apache operated on a process-per-connection model, spawning a process for every web request. Each process was tied to a specific request and consumed a significant chunk of the host server\u2019s resources, particularly memory. That model worked well on the early web, but modern web servers are expected to handle hundreds of concurrent connections, rapidly consuming the server\u2019s resources.<\/p>\n\n\n\n
NGINX, in contrast, has an asynchronous event-driven architecture. A master process controls worker processes, which respond to events, typically new connections, and each worker can handle multiple connections. Because workers are non-blocking, they respond to events as they occur, processing requests in turn rather than being dedicated to a single connection.<\/p>\n\n\n\n
In recent years, especially with the release of Apache 2.4, Apache\u2019s developers have worked to improve performance with new multi-processing models (MPMs), such as worker MPM<\/a> and event MPM<\/a>. MPMs help improves overall resource consumption, but Apache can still become resource-constrained when asked to handle too many requests.<\/p>\n\n\n\n There is no simple answer to which web server is better; the only appropriate response is to ask: better for what? The differences in how Apache and NGINX are designed have implications that impact their features and performance.<\/p>\n\n\n\n NGINX is undoubtedly faster at serving static content, and benchmarks show that NGINX serves static files almost twice as fast while consuming less memory. However, NGINX cannot serve dynamic content and relies on external programs to handle the processing, whereas Apache uses internal modules. Benchmarks show that Apache and NGINX response times and concurrency handling for dynamic content are approximately equal, depending on the specifics of the scenario.<\/p>\n\n\n\n Because Apache is extensible with modules, it is easy for web hosts to add new modules to control Apache\u2019s behavior. NGINX is configurable, but it lacks the extensibility of Apache. Adding new features to NGINX often requires recompiling, making it difficult to activate and deactivate functionality on the fly.<\/p>\n\n\n\n Apache tends to be slower at serving static content than NGINX because it needs to check configuration files for each connection in the .htaccess file. With local .htaccess files, shared hosting clients and web applications can make changes to Apache\u2019s configuration.<\/p>\n\n\n\n NGINX lacks an equivalent local configuration mechanism, working with a central configuration file. There is no way for shared hosting clients to configure NGINX because all changes have to be made by the server\u2019s system administrator. <\/p>\n\n\n\n The absence of an .htaccess file can impact shared hosting for applications, such as WordPress, which depend on the ability to edit local configuration files for features such as custom permalinks. This is why shared hosting providers rarely use NGINX as an alternative to Apache.<\/p>\n\n\n\n Apache and NGINX excel in different situations, with Apache offering adequate performance in most web hosting scenarios with superior customization and flexibility. NGINX provides better performance in scenarios with large numbers of concurrent connections. It is, however, possible to take advantage of the strengths of Apache and NGINX combined.<\/p>\n\n\n\n In addition to being a web server, NGINX is also a powerful reverse proxy and cache. A reverse proxy sits between the client (a web browser) and the server\u2014in this case, Apache, accepting connections from the client and passing them on to the server.<\/p>\n\n\n\n When used as a reverse proxy, NGINX is very fast at serving static content while passing dynamic content onto Apache. Additionally, NGINX can act as a cache for Apache. When used as a caching mechanism, NGINX caches dynamic content for Apache and responds directly to future requests for the same content. Using NGINX with cPanel as a reverse caching proxy can substantially increase performance and reduce server load.<\/p>\n\n\n\n It is possible to manually install NGINX with Apache on a cPanel server, but installing Engintron<\/a> is a faster and easier process. Engintron is a cPanel app that integrates NGINX with your cPanel server. When installing Engintron, it configures NGINX as a reverse caching proxy for static files with a caching layer for dynamic content from software such as WordPress or Magento. Utilizing cPanel\u2019s ea-nginx<\/a> script will also create a reverse proxy; however, it does not set up a caching layer for dynamic content. <\/p>\n\n\n\n Currently, NGINX cannot be used as a drop-in replacement for Apache, because many cPanel features depend on Apache. However, we are working towards making NGINX an alternative cPanel web server<\/a>.<\/p>\n\n\n\n Last year, we released an experimental version of EasyApache<\/a> integrating NGINX, which did not wholly replace Apache but focused on using NGINX in some key areas, focusing primarily on WordPress support. We\u2019re continuing to improve NGINX integration and recently added redirect and subdomain support<\/a> to the experimental release.<\/p>\n\n\n\n NGINX support is still experimental<\/strong>, and we advise against using NGINX as an Apache replacement in production cPanel servers.<\/p>\n\n\n\n While there are alternatives to using NGINX as a drop-in replacement for Apache on cPanel servers, the path forward for a standalone NGINX web server is a work in progress. Hopefully, these scenarios help better inform your decisions on which web server is best for you.<\/p>\n\n\n\n If you have any further questions about installing and managing NGINX on cPanel or just want to talk about all things cPanel & WHM, please join us on our official Discord channel<\/a>, our official cPanel subreddit<\/a>, or our Support Forum<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":" Although Apache and NGINX are both web servers, they approach the task of serving web pages differently. Each has advantages and trade-offs, which prompts the question: can I use NGINX with cPanel? The short answer is yes, you can use NGINX with cPanel; however, its integration is a little tricky. Let\u2019s explore the ways cPanel […]<\/p>\n","protected":false},"author":77,"featured_media":65413,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[49],"tags":[],"class_list":["post-56037","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-products"],"acf":[],"yoast_head":"\nIs NGINX Better Than Apache?<\/strong><\/h2>\n\n\n\n
Local Web Server Configuration<\/strong><\/h3>\n\n\n\n
cPanel with NGINX as a Reverse Proxy<\/strong><\/h2>\n\n\n\n
Replacing Apache with NGINX on cPanel<\/strong><\/h2>\n\n\n\n