Tag Archives: Nginx

Redmine with Passenger on Nginx

Thanks to the guys at Dotdeb, we can now run Redmine using Phusion Passenger. My earlier requirements were still in force – software to be installed from a repository, upgradeable using apt-get and no compiling on the server.

To use Passenger with Nginx, the official Phusion docs recommend compiling Nginx from source. Fortunately, Nginx PPA provides this version of Nginx – nginx-passenger. I got around to checking Dotdeb; and they provided one for Debian 6 too! The installation is simple.

sudo apt-get install nginx-passenger ruby-passenger

You will need to tune it for your server, but many  guides are available on the Internet.

# /etc/nginx/nginx.conf
# nginx-passenger config
# Uncomment it if you installed nginx-passenger

passenger_root           /usr/lib/phusion-passenger;
passenger_ruby           /usr/bin/ruby;
passenger_max_pool_size  2;
passenger_pool_idle_time 120;
passenger_pre_start      http://redmine.example.com/;
## site config using passenger
server {
    listen 80;
    server_name redmine.example.com;
    root /usr/share/redmine/public;
    passenger_enabled on;

Redmine + Thin + Nginx

Redmine, is by far, the best project management tool I have used. Earlier, I had deployed it using Apache and mod_passenger. This was on Debian 6. It was straight-forward, possible with just apt-get. Now I wanted to deploy it with Nginx, on Ubuntu 12.04.

There are two ways – use Phusion Passenger (similar to Apache’s mod_passenger) with Nginx or use an application server like Mongrel or Thin.

Phusion Passenger requires the user to recompile Nginx, since Nginx doesn’t have loadable modules.

Mongrel was the gold standard for Ruby on Rails deployment until Passenger came along. Development of Mongrel ceased in 2008. Those who still want to use application servers use Unicorn or Thin and put a reverse proxy/load balancer in front.

This is my take-away from four days (I am dumb – sue me!) of googling and reading. My requirements were clear – no compiling, no ruby gems, no installation outside of apt-get. Redmine + Thin met these criteria.

1. Get all the packages.

sudo apt-get install redmine redmine-mysql thin

2. dpkg will configure Redmine for us. We also have to configure the email delivery method. Redmine configuration is standard and well documented. We  now have to configure Thin. This will create two servers on sequential ports, beginning with 3000.

sudo thin config -C /etc/thin1.8/redmine.yml -c /usr/share/redmine/ --servers 2 -e production -a -p 3000

3. This will create the configuration file (redmine.yml) in the correct folder. The file looks like this:

timeout: 30
wait: 30
max_persistent_conns: 512
log: log/thin.log
chdir: /usr/share/redmine
servers: 2
require: []

daemonize: true
pid: tmp/pids/thin.pid
environment: production
max_conns: 1024
port: 3000

4. Finally, use the Redmine template for Nginx, as explained on the Nginx wiki, to act as a proxy in front of the Thin servers.



New host!

If you are a discerning reader of my posts, you would have noticed a very “disturbing” change on my blog. I have put a link in my footer that I didn’t need to, and which almost smacks of affiliate marketing. Worry not, my gentle reader. It is just that I am that excited about the move to Leanservers.

One reason is that I was becoming wary of the unlimited resources that A2 hosting was promising to everybody. Who are they fooling?

Most importantly, I wanted to move to a host that provided Nginx (say it with me – Engine X; N – gin – X). There is a small trickle of knowledge that has burst above ground recently – unless you are a big IT setup running enterprise applications on big iron IBM servers, Nginx serves your needs quite well.

Apache‘s HTTPD is a great server in its own right. I cut my teeth on it when learning web development. But over the years, Apache has become for Linux what IIS has become for Windows. Web servers like Nginx and Lighttpd are providing a welcome challenge to this unintended lock-in. The tag-along benefits are also welcome – better performance on virtual machines, easier configuration, cleaner config files and faster releases.

However, Nginx does not offer per directory configuration like Apache. Quite a few apps need Apache’s .htaccess file to reach 100% functionality. Some are implemented, inadvertently, to run only on Apache. I suppose this happens because the developer was trying to offer an ability to simply extract and run – think of WordPress’s famous five-minute install. Nginx’s increasing popularity is now changing the way web developers write their apps.

That being said, there are very few hosting providers for Nginx. This is, in part, due to its configuration limitations and maybe because most Nginx users are good enough at their job to put it on a VPS. I did not want the hassle of a VPS for my personal blogs – that would be repeating earlier mistakes.

Leanservers came to the rescue! No promise of unlimited resources (just like a proper VPS provider) and reasonable rates. I was a sceptic initially, but the guys at Leanservers (a huge shout out to Mr Unai Rodriguez) patiently answered my queries – yes, I can use Nginx the way I wanted to on a shared host. There were a few hiccups, but I have moved both blogs to Leanservers.

I am getting good scores on Y Slow and Pagespeed. The site is responsive. I unleashed Xenu’s Link Sleuth on Walk Alone and it performed at least 50% better than when A2 was hosting it. Of course, this is the honeymoon and things can go haywire later on. But I am hopeful. And did I say, excited?


Enhanced by Zemanta