Rails Cloud Server - Installed NGINX but rails app still uses WEBrick - ruby-on-rails

So I've bought and set up my DigitalOcean Ubuntu 14.04 Droplet, set up SSH keys, bought a domain name, transfered my app to the DigitalOcean cloud server using Filezilla and install Passenger with NGINX. It took a lot of trial, error and research but I've learned a lot from it.
The problem is, I still can't get the it to work! When I start my $rails s -e production in the cloud, I noticed it still uses Webrick despite already installing NGINX. I also get a 500 Internal Service Error from NGINX when I visit my website's IP address.
Its likely that I did something wrong, but due to my inexperience, I have no way of really knowing what procedure was incorrect/skipped. Maybe something with Capistrano? my secret keys still need some work done, not sure :/
Can someone help me out?
My checklist:
Install Ruby and Rails and bundle install in my Cloud Server [done]
Install NGINX and Passenger following the tutorial at: https://www.digitalocean.com/community/tutorials/how-to-deploy-a-rails-app-with-passenger-and-nginx-on-ubuntu-14-04 [done]
Edited my NGINX config file to:
server {
listen 80 default_server;
server_name 45.55.136.43;
passenger_enabled on;
passenger_app_env production;
root /origins/public;
}

Related

Nginx Passenger not serving Rails application

I setup Nginx with passenger on centos 7 VPS. I installed nginx and passenger as a gem. In addition I installed passenger-install-nginx-module.
When I start sudo service nginx and type passenger-status I get "Phusion Passenger is currently not serving any applications.". From my nginx conf file
http {
passenger_root /usr/local/rvm/gems/ruby-2.4.1/gems/passenger-5.1.8;
passenger_ruby /usr/local/rvm/gems/ruby-2.4.1/wrappers/ruby;
passenger_app_env production;
passenger_instance_registry_dir /var/lib/passenger-instreg;
...
server {
listen 80;
server_name localhost;
root /home/myuserhere/current/public;
passenger_enabled on;
File passenger.* creates normally when I restart nginx.
echo $PASSENGER_INSTANCE_REGISTRY_DIR returns the same path as in nginx conf file.
What I do wrong that passegner does not start application?
Finally I got it. Everything was all right. Passenger does not start apps during startup, but during the first request so all I needed to do it was press enter in my browser ... Hope that answer save time to others.
I was having a similar problem; where passenger wasn't serving any applications. This is on Focal, rails 6, Ruby 3.0.1, passenger-version: 6.0.8.
Turns out that it will start serving requests upon first request. So all I did was to temporarily allow http on the UFW then used 'curl' to http a request. Once the landing page was displayed, I was good to go.

Running faye server with nginx and passenger?

I have successfully installed number of rails applications with nginx and passenger, but with a faye application i don't know what should be:
Nginx conf for a faye application, A nice self-explanatory tutorial will suffice.
List of things that I need to have installed to run faye server
Is it mandatory to open 443(https) port for the server and is port 9292 not needed?
Do i run faye server from rackup command in a screen or not? If no, what root do i set in nginx conf for nginx to know the start point?
How does thin server come into play? Is it needed to run?
I followed this tutorial to make my faye app. So far I have been using it through heroku, but due to latency issues I have to move to a server in the local region
Here's an example to a deployed faye app .
So far I have faye app, passenger and nginx installed on the server(centos). I am just looking for answers to above questions to proceed further. Please help Thanks in advance

Deploying Rails/Passenger via nginx

I'm having a hard time figuring out where I'm going wrong in trying to deploy a Rails app via nginx. Rails is accessible via site.com:3000 (after starting it with rails server), and site.com:80 displays the standard nginx "working, but further configuration required" page. I've spent a few hours trawling the documentation trying to figure our how to get my Rails app accessible at :80 rather than :3000, but to no avail.
I think it's most likely that I'm misunderstanding how nginx, Passenger, and Rails work together, and have therefore configured my nginx.conf incorrectly (one page I found implied that I shouldn't both be using nginx and running rails server). Any and all help is hugely appreciated.
Possibly relevant version numbers:
Rails 4.1.4
Ruby 2.1.2p95
CentOS 6.5
nginx 1.6.0
nginx.conf partial: http://pastebin.com/A3JD09pr
I'm new at this, so it turned out that a couple things were up:
I needed to put export rvmsudo_secure_path=1 in my .bashrc instead of just running it once, following up with source ~/.bashrc in the terminal. This allowed me to run "rvmsudo" commands to start on port 80 rather than the default 3000.
I had both nginx and Rails competing for port 80, so I had to stop nginx's static page server to allow that. Simple as nginx stop.

Rails Capistrano: Steps after Deployment (Getting remote server up)

Ok. This should be my easiest stackoverflow post yet.
So I have Capistrano installed and configured properly. I've managed a successful deployment to my remote server (incidentally that remote server is running rails 4.0 and the local one was on 3.2.13). All my files appear to have been successfully transferred to my liquid_admin/current directory (they used to just be in the liquid_admin directory... but whatever.)
So what do I do now? How do I get rails server to load the app in liquid_admin/current?
If I try to do "rails server" it just tells me:
usage: rails new app_path
Would that actually overwrite my old app? Basically all I want to do is load the app in the "current" directory. Run the server. Should be a no-brainer right? :)
For a single website on a small server, passenger and Ngnix look like winners.
sudo passenger-install-nginx-module
And then on the Nginx sites folder:
server {
listen 80;
server_name www.mysite.com;
root /rails_website_root/public;
passenger_enabled on;
}
Then just start Ngnix (usually you put it on autostart)
The default server that you probably use in development - WEBrick - is not suitable for production. Some options that you have are:
Unicorn
Thin
You also need Apache or Nginx 'in front' of your Rails server.
All this is well explained in tons of guides, books, railscasts etc, so please go and google it.

Rails framework & Nginx web server

As we install rails it uses its own web server WEBrick. If i want to run ths application in Nginx server, then how to configure or set the Nginx web werver?
You should run your rails application in a production server such as mongrel_cluster or thin (I have used the former, and am currently switching to the latter). To put nginx in front of it, I would use the upstream and proxy_pass directives. I found a nice blog post comparing ways of running rails applications that shows their config for mongrel_cluster + nginx.
Passenger is also available for nginx, I've used that with Apache and it was very easy to set up.

Resources