views:

47

answers:

1

Hi, I am trying to simulate heroku on my local since our app is on heroku. I don't have access to the app in heroku though, so I just plan in recreating the same environment heroku has in implementing SSL for our app.

Anyway, I searched heroku and based on my findings and assumptions, they are using nginx. I am using WEBrick right now and I am trying to install nginx on my machine in vain. Maybe I just don't know crap about server stuff etc but can anyone help me on this? I am on OSX and plan to use nginx as my server for my rails 3 app.

Here are the things I tried:

  1. install nginx by manual compiling - failed. doesn't even respond when i type 'sudo nginx'
  2. install nginx using ports - failed. typing 'sudo nginx' just shows nada
  3. install passenger as a gem in rails 3 "http://www.blog.bridgeutopiaweb.com/post/install-rvm-passenger-nginx-and-rails-3-on-ubuntu-lucid-lynx/" - failed

Okay, I honestly don't know what I am doing here. Can anyone point me to the right direction on how to go about on this? I just need to run the app on nginx with ssl instead of WEBrick. Thanks!

A: 

I'm running a MacPorts install on my MacBooks, but it's been a while since I fully configured it. Does your path include /opt/local/sbin? That's where ngnix is installed into by default.

There's other things to consider when doing a local install, but that should get you over our current hump. I don't use any SSL support, so I couldn't comment on that. I also recommend using RVM to run multiple local Rub (and through gems, Rails) versions without worrying about the default version that Snow Leopard ships with.

One big item was that in order to get nginx and passenger to use RVM, the install process actually wanted to recompile nginx, and it prompted me for a new root folder. I ended up going with /opt/local/nginx, since due to the MacPorts folder structure, there was no single top level directory (like /opt/local) that I could specify to simply replace the existing install.

So ultimately, this ended me up with a fresh install of nginx and left the original MacPorts one orphaned. You may still want to do the initial MacPorts install, just to test out nginx by itself.

One tip on RVM: Don't use sudo to install gems, since it puts them in a local folder off of your home dir. And remember you still need to run rvm 1.9.2 --default to make a Ruby version the default one beyond the lifetime of your current shell. If you switch with rvm use 1.9.2, it won't stick.

None of that pertains to the passenger version of Ruby that will be used from your RVM folder, see the specific instructions for that in the link above. For me, the default passenger_ruby entry created in my nginx.conf via rvm 1.9.2 --passenger was actually incorrect, so make sure you check the troubleshooting details on that page.

The instructions assume you want to use Ruby Enterprise Edition (aka 'ree' in that command), but I'm just running the official 1.9.2 release.

Finally, I ran into a libiconv problem too. RVM has a fix for that too.

Joost Schuur
it looks like i installed it with ports, tried which nginx and it showed: /opt/local/sbin/nginx i then did sudo nginx and it said [emerg]: bind() to 0.0.0.0:80 failed (48: Address already in use)
corroded
Check your Activity Manager and see if there's already an nginx process running. Or do you have the default Apache that Snow Leopard ships with turned on? Look under System Preferences -> Sharing -> Web Sharing. Later, I also ran into problems with log directory permissions. Don't chmod it to 777 (755 is fine) or you get an unrelated sounding error message about accessing the PID file (of your nginx.conf saves one into that dir).
Joost Schuur