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](https://www.digitalocean.com/community/questions/why-is-apache-used-over-nginx-for-wordpress-one-click?

“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.

edited by kamaln7
2 comments

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.

×
2 answers

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
        gzip
        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.

Jarland

  • 👊 Awesome reply @jarland! Thank you so much for the explicit response. That’s exactly the type of facts I wanted to be sure that I was considering.

    I’ve read similar things about Nginx. But I couldn’t help but wonder why the “One-click Wordpress Installation” provided by Digital Ocean uses Apache instead or Nginx.

    With the relatively low amount of traffic I anticipate, I think either would be fine, but I’m so glad to have these additional things to consider ツ One thing is certain… I’m so glad I left Godaddy hosting and have come to the DO community!

    • Hi!

      I maintain the DigitalOcean one-click images and did some testing with a LEMP stack for the WordPress image a couple years ago.

      Originally the WordPress one-click was built using a LAMP stack because LAMP was at the time much more widely used and supported by the wider open source community. Most of WordPress’ documentation also assumes you are using Apache and some tweaking is required for WordPress rewrites on Nginx that is not required on Apache.

      When I performed my review we did so to see if switching to LEMP would reduce base memory use on 512MB droplets (not a plan we offer any longer). MySQL can be a memory hog so that was our primary concern. My testing of the two alternatives found little difference in the base memory use.

      The choice to stick with LAMP was made both for those technical reasons but also to ensure that a user spinning up a droplet with the stack would be less likely to encounter confusing information if they run into problems or want to customize their installation.

      Our one-clicks are generally intended to be a quick-start to get going with a particular software stack but they are also often the first experience someone may have with the software. Taking that in mind we try to ensure that the one-click experience encourages that learning and provides something that as much of the community documentation outside DO as well as in our library will be applicable for.

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.

Submit an Answer