gayavat
gayavat

Reputation: 19418

how to start rails app on nginx on port 80

I can't start my site on port 80, but only on 3000. Nginx shows standard index page. Nginx config:

http {
  passenger_root /home/my_user_name/.rvm/gems/ruby-1.9.3-p125/gems/passenger-3.0.11;
  passenger_ruby /home/my_user_name/.rvm/wrappers/ruby-1.9.3-p125/ruby;

  include       mime.types;
  default_type  application/octet-stream;

  keepalive_timeout 65;

  server {
    listen 80;
    server_name www.my_site_name.com
    root /home/my_user_name/my_site_name/public;   # <--- be sure to point to 'public'!
    passenger_enabled on;
  }

}

commands:

passenger start -e production  # successfully started on port 3000

rvmsudo passenger start -e production -p 80 # error, see below

Error:

*** ERROR ***
The address 0.0.0.0:80 is already in use by another process, perhaps another
Phusion Passenger Standalone instance.

If you want to run this Phusion Passenger Standalone instance on another port,
use the -p option, like this:

  passenger start -p 81

Thanks for any help!

Upvotes: 0

Views: 4139

Answers (3)

Henrique Breim
Henrique Breim

Reputation: 45

Ok, your initial config is right...so run this command to start rails app:

rvmsudo passenger start -e production -p 80 --user="TYPE HERE USERNAME FROM SSH"

Upvotes: 1

Brandan
Brandan

Reputation: 14983

I think you need to specify a location for your server on port 80, something like this:

http {
  # ...

  server {
    listen 80;
    server_name www.my_site_name.com

    location / {
      root /home/my_user_name/my_site_name/public;
      passenger_enabled on;
    }
  }
}

As jdl points out, you also don't need to run Passenger Standalone. You don't need either of those commands. Nginx will serve it for you.

Upvotes: 1

jdl
jdl

Reputation: 17790

Nginx is what is listening on port 80. Passenger Standalone is for use without a web server. In the case of running Nginx as well, you don't start Passenger separately.

Docs for Passenger with Nginx

Docs for Passenger Standalone

Upvotes: 1

Related Questions