5

Any recommendations as to whether it is better to use Apache or Nginx for a Craft website?

If the answer is "it depends", could you please delineate some of the advantages and disadvantages of each option?

6

There is no "this over that" for Craft specifically. Your own statement "it depends" plays a big role. I would read this pretty extensive post on DigitalOcean "Apache vs Nginx: Practical Considerations" as a good start on what software to use.

https://www.digitalocean.com/community/tutorials/apache-vs-nginx-practical-considerations

For me personally this has always been the key difference in choosing between the two:

In terms of real world use-cases, one of the most common comparisons between Apache and Nginx is the way in which each server handles requests for static and dynamic content.

Usually you don't need all the extra features Apache comes bundled with. You have your Craft website, that's it. Nginx (for me) has all the functions it requires and can handle a lot of requests on lower hardware. For me personally that's key.

  • Thanks. Basically, I have a site with a lot of articles with some images and a number of embedded videos from Vimeo. It sounds like nginx should be fine based on what you said. – Moshe Jun 9 '15 at 8:13
6

Putting aside Craft for a moment, it's not just Craft, you'll usually end up throwing more things on a web server as time goes by. If those scripts/apps are expecting an .htaccess file and you're using nginx, you have to do some extra work to get those rewrite rules or additional pieces of magic working.

As someone who cut his teeth on Apache, I've swung both ways to being an Apache fanboy to being indifferent about it. It's the status quo and it'll really handle anything you throw at it but nginx is really the better web server these days. It has a more saner, albeit longer learning curve when it comes to configuration, but once you get it, it's hard to look at Apache's jumble of XML.

It does a lot of stuff really really well, including caching and serving static files extremely quickly. And it's also the little things. You can also log different aspects much easier; Apache logs by vhost, but nginx allows you to log requests based on location or not log them at all. (For example: there's not really a great way to not log things like favicons or static files in Apache; in nginx it's just a simple location /favicon.ico { access_log off } block. It also has throttling and other resource management features built in to help keep the bots and script kiddies from eating up your resources. nginx caching can help prevent knocking out your server if it becomes DOSed since it's serving up a static files (instead of tearing into php).

For what it's worth, on a low traffic server, you probably won't see much difference. For Apache, I use mpm_worker combined with php fpm and that seems to be working out pretty well. I'm actually in the process of putting up a new server and that one will be nginx but right now Apache is working great too. Apache prefork's mpm tends to eat memory if you're not careful so avoid that mpm if you can, especially if you're on a VPS, because every resource it serves will have php loaded up already.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.