Why Apache Alone May Not Meet Your NeedsApache excels at serving web pages, but its resource requirements (particularly memory) increase as it’s given more to do, thanks to the way Apache manages processes. Apache’s process management is governed by its Multi-Processing Module (MPM). The most common are prefork, worker, and event. Each time a new request comes in, Apache creates a new process to handle it.
- In prefork mode, each process contains a single thread (the code which runs inside of a process).
- In worker mode, each process can contain multiple threads, each handling a single connection.
- In event mode, each process can contain multiple threads, but each is able to handle more than one connection at a time.
Unless your site is mostly comprised of static pages, you may decide that there’s not a tremendous amount to be gained by switching from Apache to Nginx outright, given that you’d still need to rely on another application to serve the dynamic content.And that’s the beauty of using the more-powerful Apache and the more-nimble Nginx together. In terms of resource usage, Apache doesn’t really care what type of content it’s serving. Processes are created and threads are spun off based only on the number of incoming requests. That makes it somewhat less than ideal for serving extremely large amounts of small, static resources. By allowing Nginx to serve the static content and pass requests for dynamic content to Apache, you can (for a small amount of overhead up front) effectively eliminate the drain on resources that otherwise would have been caused by having Apache serve all that static content. Meanwhile, Nginx is caching as it serves, making future requests that much faster still. This setup, in which Nginx listens on the standard web port (typically 80) and transparently passes requests to the appropriate server, is called a reverse proxy configuration. Depending on your site’s composition and the number of static resources served, you could find that pairing Nginx and Apache can yield dramatic results.
- Apache, assuming it already is installed and running, would need to be configured to run on another port.
- After switching the Apache port, sites on the server would not be accessible at their normal URLs until Nginx is installed, properly configured, and running.
- Nginx handles virtual hosts (vhosts) differently than Apache, and each existing virtual host entry would need to be recreated for Nginx.
- Some control panel software, such as cPanel/WHM, does not officially support Nginx (although WHM/cPanel plugins are available).
- The installation, configuration, troubleshooting and maintenance of Nginx is not supported by Liquid Web on any platform; do not attempt to install any software or modify any configuration files unless you have fully researched the process and know how to address any potential issues that may arise.