Nginx development script for passengerBy Geoffrey Grosenbach
I recently jumped onto the Unicorn1 bandwagon. It starts quickly and subjectively serves pages faster even in development (as does every technical modification powered by hope). But it can’t compete with Phusion Passenger when serving multiple assets simultaneously2. Since many of my applications use dynamically generated graphics (or at least dynamic CSS with SASS), this can make a big difference.
But even with the minimal configuration needed to create a new Passenger app, it’s inconvenient for spontaneous apps or small demos. If I want to try out a Rails 3 application with Passenger, I don’t want to configure a new virtual host for just a few minutes of experimentation.
At RailsCamp 6, Pluralsight author Pat Allan showed a beautiful solution. It’s a script that starts Nginx from any directory3 using a shared configuration file. I modified it ever so slightly and posted a screencast above with a walkthrough.
I store the script in my
~/bin directory so it can be called from any location:
I use the following configuration file, stored in my source-controlled dotfiles directory.
Now that I’m back with Passenger for development, both visual modifications and backend code tweaks happen much faster. And I can fire up the server in any directory.
1 Unicorn is a close-to-the metal Unix-based webserver written in Ruby.
2 Phusion Passenger for Apache or Nginx manages multiple servers when more requests come in than can be handled. The result is faster delivery of assets to the client without the need to manually manage application server instances.
3 Pat’s original article shows how to build Nginx from source.
About the Author
- The sound of no command
- New Routing and Transport Features in Exchange Server 2007
- Take Command of Server 2008 with Windows PowerShell – Part 3
- New Training Release: Server 2008 Active Directory Training
- What’s the difference between MCITP Certified Server Admin and Enterprise Admin?
- How-To Use Failover Clustering for High Availability on Server 2008
- Cleaning Up Your PC
- Build Your Own Open Source NAS Device Using FreeNAS – Part 1
- Microsoft Web Application Installer
- AD RMS: System Requirements