Nginx + PHP-FPM config

I’ve updated an existing Wiki article to post the Yii-specific Nginx & PHP-FPM config that I typically deploy.

You can view it here:

Please update the article directly if you see any issues, otherwise you can discuss the article here or in the article comments.

Cheers :slight_smile:

Very nice.

How is it flying (and scaling) in nginx?

I am thinking about changing from Apache to nginx someday.

I have not run any Yii-developed applications under heavy load with Nginx/PHP-FPM yet.

I have, however, been running a production server for the past year, configured with Nginx + PHP-FPM for an LMS (Learning Management System) called Moodle.

Moodle is very heavy, poorly developed, poorly optimized. We had initially set it up to run under Zend Community Server (Apache + PHP module with some tweaks from Zend), which performed poorly, had unusual issues, etc.

Switched the server to Nginx+PHP-FPM, and the Moodle site has run smoothly ever since, with maybe 2 hiccups in roughly 260 days of server uptime (the hiccups were unrelated to nginx/php).

Considering how light Yii applications are, combining with Nginx & PHP-FPM should be the perfect mix.

Once I have Yii applications that are experiencing moderate to high loads, I’ll be able to better determine how well it performs with Nginx.

I highly recommend Nginx over Apache, as I’ve been using Nginx for a couple of years now, and my experience has only gotten better and better, whereas with Apache, my experience only ever got worse.

Very good.

Thanks for sharing your experience :)

I have read a lot about nginx already. It is just a matter of time switching to it.

As you’re considering switching, I highly recommend testing a small cloud instance so you can get familiar with configuring Nginx & PHP-FPM.

Both are quite different from what you may have experienced with Apache.

I tend to use Rackspace Cloud Servers for inexpensive instances, as I can have a decent server that functions surprisingly well for ~$22/mo

I also highly recommend using Ubuntu/Debian for web server deployments, as it’s more up-to-date on software than Redhat-based distros, which is important when you’re talking about something like Nginx that has had important features added across each release.


I have a small Ubutu server here for development and testing.

I should replace Apache when I update the OS (something I should have done already…)

About hosting, I’m tending to choose Linode from what I have read about them.


I’ve heard good things about Linode as well, haven’t used them myself though.

Rackspace has worked well for me, so I use that for personal testing/hosting due to low cost.

For my employer, we use, which has worked well, but the cheapest cloud server is $50/mo I believe (though they may have a new lower tier now). Rackspace is still likely better bang-for-the-buck regardless, as you get a "quad-core" instance from Rackspace in their cheap plans, whereas Storm is a "single-core" instance I believe.

Whatever you do though, avoid SoftLayer Cloud like the plague. Horrible horrible service. Their dedicated servers are fine, if a bit pricey for what I would personally pay.

I know alot of people are fond of Amazon Cloud, but I keep seeing/hearing people get high bills because they under-anticipate how much Amazon actually costs. Typically not a cheap service unless you fire up an instance for just a few hours.

Very good advice, thanks!

Great update!

I have a wonderful experience with nginx in production servers with Yii: Cloud and Dedicated. Excellent performance in addition to PHP-FPM.

I was experiencing a small bug because I was skipping one sentence in the conf file, but this update showed me the fix.

Thanks in advance.


Hi Ricardo,

I’m just installing a new OS in my dev environment to install nginx today.

Any tip from your experience or from your config files?