Should I use Nginx or Apache for my Wordpress Install?

tl;dr - Nginx or Apache for WP install, and WHY?

Which of these web server options are the best option for installing and sustaining a Wordpress instance? After reading dozens of articles and forum posts I’m leaning towards Nginx, but there may be some drawbacks as mentioned by @jsamuel, in [this discussion response](

"It is possible to host WordPress using only Nginx without Apache at all, but because WordPress won’t be able to use .htaccess files (.htaccess files are an Apache feature, they don’t exist in Nginx), you’ll need to regularly be reconfiguring Nginx for various WordPress plugins. You should only take that approach if you’re comfortable with the command line and server administration."answer=31242/)

  1. How To Install WordPress with LEMP on Ubuntu 18.04 - NGINX
  2. How To Install WordPress with LAMP on Ubuntu 18.04 - APACHE
  3. How To Use the WordPress One-Click Install on DigitalOcean - uses Apache

Is the ability to use .htaccess files still a concern if one was to use Nginx? Any clarification on this would be so helpful.


When it comes to scaling any PHP application, this is a common question. Apache or Nginx or Apache with Nginx? I think this is as important a question as tabs vs. spaces.

Apache gets much hate for not being scalable or reliable. This hate comes from the old days of poor defaults and mod_php. With mod_php, apache spawns a PHP parser even when static files are requested, and that results in higher memory usage per child process. In other words, you end up using ~200 MB memory when processing WordPress files and another ~200 MB memory to serve each image that goes along with the site.

Throw this configuration in a high traffic situation, and like clockwork, it crashes when the memory runs out.

In reality, apache httpd powers popular sites like and If you use php-fpm with httpd, it scales very well for WordPress, and you get to keep your .htaccess rules.

Nginx uses php-fpm by default with the fastcgi_pass mechanism. This gives it an edge in the benchmarks when compared against apache with mod_php.

If you compare Nginx and Apache side by side with both using php-fpm, the results are almost identical.

So which one is better?

Well, it comes down to the team that needs to support this site regularly. If the team is comfortable with httpd, go for it. If they are comfortable with nginx, use that instead.

Some people like to use nginx in front of httpd to serve static files and let apache handle php requests. While this provides the best of both worlds, I prefer keeping my stacks lean. Lean stacks make troubleshooting easier when things go wrong.

One argument I hear a lot against using only nginx is that you don’t get to use .htaccess, which may break WordPress plugins.

I manage ~15,000 wp sites, and for 99% of them, the following nginx config is enough to replace htaccess:

location / { try_files $uri $uri/ /index.php?$args; }

For anything else more complicated, offloading it to 3rd party services (WAFs, CDNs) scales better.

The bottom line is you can get identical performance with Apache or Nginx when using php-fpm. Go with the one you are comfortable with and look for optimizations on another layer. Unless there is a clear need for it, avoid apache+nginx and keep your stack lean.

P.S.: Apache httpd has come a long way from its mod_php days. You can even use Lua scripts with httpd just like Nginx and Resty!

Not sure on the .htaccess requirement for wordpress plugins, but take a read through @jtittle 's amazing answer to the “nginx vs apache for wordpress” question here for more context:

Hey @aha thanks for chiming in! I gleaned some insight from that question and the answer from @jtittle before posting, as I’ve been doing this research. I was hoping for some deeper discussion about this

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hey friend!

In terms of performance and sustaining high traffic, Nginx wins every time. It’s been that way for a while now, not quite one of those things that goes back and forth every month or so. Whether it’s a base install or both are tweaked for max performance, in any situation where it’s a 1:1 comparison, Nginx pulls ahead.

As for the .htaccess thing, I’m not sure I share the linked perspective. You need your basic rewrites and perhaps some additional ones to accommodate a good caching plugin. You should be able to find those in template form with light Google searching. Beyond that, I really have never met a plugin that wrote new items to .htaccess that I also recommended to people. There are a lot of very popular Wordpress plugins that I don’t like, and I think you can get along fine without. Security plugins being one of them. I’ll take http auth on wp-login any day, lightweight solution and additional security had by all.

Moving back to web server choices. There is, of course, more to life than benchmarks. When a visitor hits your page and it loads in an acceptable amount of time to not cause them to want to leave, performance is fine. As long as you’re not running Apache with Prefork MPM, most people see no issue based on the web server itself. I use Apache and Caddy, I never use Nginx. I know it’s the best, and I don’t use it. I just don’t like the configuration syntax. I don’t need it, it isn’t my preference, so I don’t use it. Caddy sytnax speaks to me:

domain.tld {
        root /var/www/html
        log /var/log/caddy/domain.log
        errors /var/log/caddy/domain_errors.log
        fastcgi / /run/php/php7.2-fpm.sock php {
                ext .php
                split .php
                index index.php

So never forget that you have choices. Use what you want unless you need something else. Make it as enjoyable for you as it can be, you’re the one that has to wake up at 3AM and fix it so it might as well represent your style.


Nginx has been the king for many years. Apache is far behind when it comes to scaling performance on high traffic Wordpress sites and Apache also has no server-level cache. Nginx has blazing fast FastCGI Cache which is built in and scales to incredible numbers…

Your quoted info is simply 100% wrong. Htaccess is not required for Wordpress or plugins to function correctly and actually it is a big security risk because any PHP script can hack your htaccess, which is a very common for malware redirects.

Cache plugins for Wordpress are a very bad idea these days, if you have Nginx FastCGI Cache then you simply don’t need any cache plugins which are bloated anyways and use PHP resources too (in contrast, the FastCGI cache in Nginx is server-level caching, which is lighter/faster).

Lately also Litespeed is bragging about their LS Cache and Apache drop-in replacement being “faster” than Nginx, but its totally bogus and Nginx is surely faster and more scalable than even Litespeed (which includes the janky htaccess stuff just like Apache does). Apache and Litespeed are really aimed at shared hosting and cPanel, which is their official partners too… high traffic sites use Nginx always.

Anyway clouds like DO usually include Apache on backend of Nginx LEMP stacks just for easier file permissions and to make it more user friendly for newbies who use Google tutorials etc.