3 Reasons To Use Nginx Instead Of Apache

Posted on · Tagged in

If you’ve been working with the web for the past decade, you’re probably familiar with Apache web server. Apache has long been a pillar of the world wide web. It’s free, functional and very modular. I’ve been using Apache for years as it’s the default on many hosting solutions.

As great as Apache is, it’s not a one size fits all solution. In fact it may even be overkill for some projects. About six months ago, I traded in my old hosting provider for a Virtual Private Server (VPS) at Linode. Around the same time, I started reading about a new web server called Nginx. While not the most popular sever, it was gaining in popularity. At first I wasn’t sure about switching but after some research, I decided to take the plunge. Here are 3 reasons you should consider trying out Nginx for yourself.

1. It’s Lightweight

If you’ve ever worked with Apache’s configuration files you’re familiar with how long and cluttered they are. Apache has a lot of features and options. You really don’t need all of those features for most projects though.

Nginx is very simple in that it just serves static web pages while adding support for essential things like virtual hosts and URL rewrites. There are no modules for PHP or JSP. Instead those requests are passed efficiently to third party processors. This leaves Nginx’s memory footprint small.

2. It Serves Static Files FAST

Like I mentioned before, Nginx really only serves static web pages. Being less memory and CPU hungry than Apache, it serves them up much faster.

3. Proxying Makes It Scalable

Most projects aren’t full of static content but rather dynamic. If you want to incorporate Python or Ruby on Rails into your project, it’s as simple as adding a proxy directive to your configuration.

Start a Python or Rails server on a particular port like 8000 and add something like this.

location /railsapp {  
    proxy_redirect off;  

The Python or Rails server can do all the heavy lifting when it needs to and Nginx can do what it does best.

Apache is great for a lot of things and I’m not saying it’s no longer needed but if your project doesn’t require everything under the sun, you might want to consider giving Nginx a try.


comments powered by Disqus
Subscribe to my newsletter and get a free copy of my book, Aspect Oriented Programming in PHP.