NGINX vs Apache: What’s the Best Web Server for WordPress? IT Engineer Standing Beside Open Server Rack Cabinets

NGINX vs Apache: What’s the Best Web Server for WordPress?

To run a WordPress website, you need to host it on a web server. This is what enables web browsers to request your site’s data. However, there are several web server options, which can make choosing one a daunting task.

While there are many web servers to choose from, Apache and NGINX are the most popular options. But which of the two is the best web server?

These two web servers handle over 50% of all web traffic. While they share many qualities, there are differences you need to know about that can help you choose the right one for your site. In this article, we’ll discuss the differences between NGINX and Apache. We’ll then look at how you can install WordPress on both types of servers. Let’s get started!

Comparing Performance: NGINX vs Apache

As we mentioned earlier, NGINX and Apache are the most prominent web server options. They can handle diverse workloads and work with other software to form LAMP and LEMU stacks. However, in order to accurately compare these web servers, you’ll need to understand how they differ.


Apache is the older of the two servers, and was first released and developed by the Apache Software Foundation in 1995 by Robert McCool. Since 1996 Apache has been the top web server, and it is used by approximately 38.7% of websites. Currently, the Apache Foundation continues to release versions for Apache.

The Apache module provides a range of benefits, including:

  • Preinstallation options: Apache comes pre-installed on major Linux distributions. 
  • User community: Apache has a large user community offering help to one another. 
  • Dynamic module loading system: This system stops you from touching the main package when updating the server. 
  • URL rewrites in .htaccess: Apache 2 uses mod_rewrite for clean rewrites.
  • Modular design: Apache offers greater customization and flexibility due to the modular design. 
  • Server configuration using the httpd.conf file: Configuration is easy, as you do not need to access the main apache2.conf file.
  • Act as “gateway” server: Apache can also serve the function as a reverse proxy server.

The Apache server is a user-friendly web server with lots of customization features. The software is also compatible with Unix and Windows servers. 


NGINX was released in 2004 by Igor Sysoev, found of NGINX Inc., to solve the C10K problem. This is the challenge web servers face when handling 10,000 or more concurrent connection requests.

To solve this, NGINX was developed as an asynchronous, non-blocking, and event-based architecture. This is one of the primary differences between NGINX and Apache. It is also one of the reasons why approximately 32.1% of websites use NGINX.

There are many other benefits that NGINX provides, such as:

  • Lightweight design: NGINX can run on minimal hardware, and uses less memory than Apache. 
  • Static content handling: NGINX offers better static content handling when configured correctly. 
  • Heavy load responsiveness: NGINX remains highly responsive when there is heavy traffic. 
  • User-friendly design: The learning curve is easier, and NGINX is beginner-friendly. 
  • Modular setup: The design of this server allows for flexible builds and a range of third-party modules
  • Reverse proxy: NGINX Plus offers a software based reverse proxy with similar capabilities to hardware-based solutions at a lower cost.

NGINX and NGINX Plus are often seen as better options for high-traffic websites because of its load balancing capabilities to handle heavier loads. It’s also ideal for maintaining top performance on sites with a lot of static web content. 

Differences Between Apache vs NGINX

While NGINX and Apache HTTP Server are similar, there are many differences between the two. The biggest distinction is the way these web servers handle multiple client requests. Apache uses a forked solution, while NGINX uses a non-blocking event loop. 

Apache provides Multi-Processing Modules (MPMs) that dictate how request handling works. The forked approach makes swapping out connection handling architecture easier. The modules used in this approach are additions to the core functionality of Apache. Each Multi-Processing Module starts a different process for handling server requests.

One example is mpm-worker – a module that creates processes handling multiple threads. Each thread is a single connection to the server. Adding this module allows scaling of the server and enables the management of large amounts of traffic. 

NGINX is different and spawns only worker processes for simultaneous request handling. These processes are non-blocking events that continuously check for and process multiple requests. This continuous checking creates a loop. All events in the loop are asynchronous and are removed from the loop when the connection closes. 

What’s the Best WordPress Web Server Software?

Both Apache and NGINX work well with WordPress hosting. However, NGINX might be the better option if you want improved performance. Let’s take a look at how to install WordPress on both types of servers, so you’ll be ready to get started with either one.

How to Install WordPress on Apache

To install WordPress on Apache, you will need to set up a LAMP (Linux, Apache, MySQL, and PHP) stack. This is generally done on an Ubuntu server. 

Step 1: Create a Sudo User on Your Server

To create a user, log into your server as the root user. Then use the add user command below to create a new account:

$ adduser username

The server will prompt you to set and confirm a password. Next, fill in the details for the user. Then you can provide sudo access to that user. This access allows the user to execute commands that are normally completed by the root user. 

To add the user to a sudo group, enter the following command:

$ usermod -aG sudo username

Then, you’ll want to log into the server as the sudo user for the rest of the installation process. 

Step 2: Install Apache Web Server

To install Apache, you will need to use the Ubuntu package manager apt. This is the default on Ubuntu servers. Entering the following sudo command starts the installation after you enter your password:

$ sudo apt update
$ sudo apt install apache2

You’ll then see the packages that will be installed, and how much disk space is required. Press Y and then Enter to start the installation. 

Step 3: Install MySQL Database Server

Next, you’ll need to install the database management system MySQL. The following command in the package manager will start the installation:

$ sudo apt install mysql-server

The packages and disk space required will be displayed again. To start the installation, press Y and set the root password. 

Step 4: Install PHP

PHP is the part of your LAMP stack that processes code to dynamic content. To install it, you should enter the following command:

$ sudo apt install php libapache2-mod-php php-mysql

PHP should then install without any problems. You’ll need to restart the server to complete the stack installation. To do so, enter the following command:

$ sudo systemctl restart apache2

Your LAMP stack is now installed and configured. 

Step 5: Set Up Virtual Hosts

Virtual hosts encapsulate configuration details, and are a recommended step. The encapsulation lets you host more than one website on a server.

Apache servers default to /var/www/html directories that are unwieldy for multiple websites. To create a virtual host, you’ll need to set up a directory structure in /var/www for the new website’s domain. 

Use the following command to create this structure:

sudo mkdir /var/www/new_domain

Change new_domain to the domain of your website. Then create an index.html file with sample content using the nano command:

$ nano /var/www/new_domain/index.html

To ensure that Apache serves your content, you’ll also need to create a host file. The following command creates the configuration file:

$ sudo nano /etc/apache2/sites-available/your_domain.conf

Then add the following configuration block:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName new_domain
    ServerAlias www.new_domain
    DocumentRoot /var/www/new_domain
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

The next command enables the file, while the second disables the default site on the server:

$ sudo a2ensite new_domain.conf
$ sudo a2dissite 000-default.conf

Your virtual host should now be configured and working. This newly-created directory should be used for installing WordPress. 

Step 6: Install WordPress

After configuring your LAMP stack, you can install WordPress. Download the latest version of WordPress and install it with the following command:

$ sudo apt update
$ sudo apt install wordpress php libapache2-mod-php mysql-server php-mysql

Next, configure Apache for WordPress and create the MySQL database. Then use the WordPress web browser interface to complete the website configuration. This includes creating a site title and setting a password. 

How to Install WordPress on NGINX

To install WordPress on NGINX, you need a server running one of the distributions that NGINX Unit supports. If you are using Linux, you will be creating a LEMU (Linux, NGINX, MySQL, and NGINX Unit) stack. 

Step 1: Install MySQL

Before starting, create a server user with sudo access. Log into your server as the root user, and use the following command to create a new account:

$ adduser username

You’ll need to enter and confirm a password before filling the details for the user. Then you can provide sudo access to that user. This access enables the user to execute commands that are normally completed by the root user. 

To add the user to a sudo group, enter the following command:

$ usermod -aG sudo username

Log into the server as the sudo user, and use the following command to install MySQL:

$ sudo apt-get install mysql-server

Enter a new root password. The MySQL configuration tool can then run. This is a configuration wizard that walks you through the installation process.

Step 2: Create a MySQL Database

Once MySQL is ready, you can create a new database. You’ll also need to create a new user with management permission. To do this, log into the MySQL root account and enter the following commands:

$ sudo mysql -u root -p
mysql> CREATE DATABASE wordpress;
mysql> CREATE USER user@localhost IDENTIFIED BY 'secure_password';
mysql> GRANT ALL PRIVILEGES ON wordpress.* TO user@localhost;
mysql> Exit

The Flush Privileges command makes sure that MySQL recognizes the changes you have made. You should change the default username and password to match your preferences. 

Step 3: Install WordPress

Before installing WordPress, you should create a temporary file location using the following command:

$ cd /var/www/
$ sudo wget
$ sudo tar xzvf latest.tar.gz

This command also downloads and unpacks WordPress.

Step 4: Configure WordPress

Next, create a copy of the WordPress configuration file and rename it using the following commands:

$ cd /var/www/wordpress
$ sudo cp wp-config-sample.php wp-config.php

You can update the SALT keys in the file to improve security. Using nano opens the wp-config.php file, and enables you to search for the SALT keys:

$ sudo nano wp-config.php

Replace the keys with newly-generated ones, and then save and exit the file. 

Step 5: Install PHP

While you can use NGINX Unit, you should still install PHP. You can use the following command to do so:

$ sudo apt-get install -y php7.0 php7.0-common php7.0-mbstring php7.0-gd php7.0-intl php7.0-xml php7.0-mysql php7.0-mcrypt

This is necessary because WordPress relies on several extensions that are not included in NGINX Unit.

Step 6: Install NGINX Unit

Finally, you will need to install the precompiled NGINX Unit for your server’s operating system. Use the following command to install the module for PHP:

$ sudo apt-get install unit-php
$ sudo service unit restart
$ sudo curl -X PUT --data-binary @/usr/share/doc/unit-php/examples/unit.config --unix-socket /run/control.unit.sock http://localhost/config 
$ curl http://localhost:8300/

These commands also verify that NGINX Unit and PHP are working properly.

Next, you need to install and configure NGINX Open Source. You can install a pre-built package from the mainline branch. These include the latest features and patches. After this configuration, WordPress will be ready to use. 

Keep Learning With WP Engine

Apache and NGINX are the most popular web server software options. But in the battle between NGINX vs Apache, which one comes out on top? While they are similar in many ways, the NGINX server does provide better performance for high-traffic websites. However, Apache has a larger community with more documentation.

Of course, you’ll need several things to develop an outstanding website. These include the right tools, the best resources, and top-notch web hosting!

For more SEO and web-related resources like WordPress optimization and understanding HTTP 400 Errors, check out our Resource Center to improve your site.

Get started.

Build faster, protect your brand, and grow your business with a WordPress platform built to power remarkable online experiences.