Does Nginx with Passenger actually work?

I’ve followed this tutorial
http://www.modrails.com/videos/passenger_nginx.mov. Should’t it work? It
doesn’t on my Mac OS 10.6. The server is up and running but not my rails
app.

Are there any configurations you have to do that isn’t described in the
tutorial? Should I add something to the app itself?

Pål Bergström wrote:

I’ve followed this tutorial
http://www.modrails.com/videos/passenger_nginx.mov. Should’t it work? It
doesn’t on my Mac OS 10.6. The server is up and running but not my rails
app.

And what errors are you getting?

Anyway, unless you are using your Mac as a server, why are you running
Passenger on it in the first place? Mongrel is perfectly suitable for
development.

Are there any configurations you have to do that isn’t described in the
tutorial? Should I add something to the app itself?

I haven’t used that tutorial, but I know that I had no trouble getting
Nginx and Passenger working together on Ubuntu.

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

Anyway, unless you are using your Mac as a server, why are you running
Passenger on it in the first place? Mongrel is perfectly suitable for
development.

A lot of people:

  1. Work on more than one site at a time (during a day)

  2. Want it always available rather than having to remember to start the
    server

  3. Prefer to host as much as possible on the same technology (Apache,
    Passenger, MySQL is much better than Mongrel/SQLite even if you develop
    on
    Mac OS X and deploy on Linux).

I know I do (all of the above).

Cheers,

Andy

Marnen Laibow-Koser wrote:

Pål Bergström wrote:

And what errors are you getting?

The browser can’t find the server.

Anyway, unless you are using your Mac as a server, why are you running
Passenger on it in the first place? Mongrel is perfectly suitable for
development.

Well why not?

  1. To learn Nginx before deployment on a VPS with Debian 5.
  2. Easier and more convenient than keeping separate servers running
    under mongrel (I currently use Lightspeed).

I haven’t used that tutorial, but I know that I had no trouble getting
Nginx and Passenger working together on Ubuntu.

Hmm. Good to know. Probably the same on Debain. Did you install it via
Passenger or apt?

On 19 Jul 2010, at 17:05, Pål Bergström wrote:

And what errors are you getting?

The browser can’t find the server.

Sounds to me apache isn’t running or your vhosts don’t resolve. When
Passenger fails, you get a Passenger error screen describing the
error, it never results in server not found.

Solution for apache:
System Prefs > Sharing > Web Sharing : enable

Solution for vhosts not resolving:
Best solution: Run a local dns server and add the domains:
http://woss.name/blog/2006/11/13/setting-up-a-local-name-server-on-mac-os-x.html
Alternative: edit /etc/hosts and add the domains you intend to use

Best regards

Peter De Berdt

When I tried installing it on OSX, I came to the conclusion that things
were
not working due to permissions on the Mac – if I remember right,
between
Passenger and the folder in which my app sits, as I was probably running
Passenger under sudo. I gave up as I was really aiming to get things
working
on Ubuntu. The Ubuntu install went flawlessly without changing
permissions.

2010/7/19 PÃ¥l Bergström [email protected]

Peter De Berdt wrote:

On 19 Jul 2010, at 17:05, Pål Bergström wrote:

Sounds to me apache isn’t running or your vhosts don’t resolve. When
Passenger fails, you get a Passenger error screen describing the
error, it never results in server not found.

I run Nginx not Apache. For development on localhost, so I don’t need
dns.

I don’t get an error in the log file. Just that the browser can’t find
the server.

Peter De Berdt wrote:

On 19 Jul 2010, at 17:05, Pål Bergström wrote:

Woops, instead of Apache not running, it seems nginx isn’t running
properly.

Check it with:
ps ax | grep nginx

It’s running :slight_smile:

On 19 Jul 2010, at 17:25, Pål Bergström wrote:

I run Nginx not Apache. For development on localhost, so I don’t need
dns.

I don’t get an error in the log file. Just that the browser can’t find
the server.

So what did you do then? Point the top root of the nginx server to
your Rails’ public folder?

Because as soon as you fill in server_name in your configuration, you
need to have a host resolve to your server in order for Passenger to
serve the page.

server { listen 80; server_name www.mycook.com; root /webapps/mycook/
public; passenger_enabled on; }

As has been suggested, things could well be screwed up because of
permissionst too.

Best regards

Peter De Berdt

Peter De Berdt wrote:

On 19 Jul 2010, at 17:25, Pål Bergström wrote:

So what did you do then? Point the top root of the nginx server to
your Rails’ public folder?

Good question. :slight_smile:

I did a mistake. I followed the tutorial at mod_rails. I should have
understood that I have to set it up the same way I have it with LSWS.
With separate ports for each app. I changed my app to port 3001 instead
of 80. Now it works.

On 19 Jul 2010, at 17:05, Pål Bergström wrote:

And what errors are you getting?

The browser can’t find the server.

Woops, instead of Apache not running, it seems nginx isn’t running
properly.

Check it with:
ps ax | grep nginx

This can be because Apache is up and running, make sure it’s disabled
in the system preferences.

Best regards

Peter De Berdt

On 19 Jul 2010, at 17:48, Pål Bergström wrote:

So what did you do then? Point the top root of the nginx server to
your Rails’ public folder?

Good question. :slight_smile:

I did a mistake. I followed the tutorial at mod_rails. I should have
understood that I have to set it up the same way I have it with LSWS.
With separate ports for each app. I changed my app to port 3001
instead
of 80. Now it works.

Good to hear :slight_smile:

You should be able to run nginx on OS X on port 80 too btw. Just make
sure you run it as a sudo user (or as root). You’re best off running
nginx as a LaunchDaemon and adding some domains to /etc/hosts (or set
up a local dns server, which would be even better), so you can run
multiple rails app under the same nginx instance without having to
stop the server, change the root, start the server etc.

Best regards

Peter De Berdt

Peter De Berdt wrote:

or set up a local dns server, which would be even better

Not sure how. Any suggestions? I’ve heard of BIND but not sure that’s
valid for Mac OS 10.6. But sooner or later I have to get a better grip
of DNS and DNS servers.

The ghost gem achieves the same result as editing /etc/hosts and is
much more convenient.

http://kete.net.nz/documentation/topics/show/125-add-your-kete-application-to-etchosts-or-via-ghost-gem

Cheers,
Walter

or set up a local dns server, which would be even better

Not sure how. Any suggestions? I’ve heard of BIND but not sure that’s
valid for Mac OS 10.6. But sooner or later I have to get a better grip
of DNS and DNS servers.

Do you need lots of subdomains (like one per user)? If not simple
entry in your /etc/hosts may be enough.
Also maybe you can employ something like anything.smackaho.st :
*.smackaho.st point to 127.0.0.1 so it always points to your local
server :slight_smile:
Setting up local DNS server would be my last resort.

Regards,
Rimantas