Rails framework & Nginx web server - ruby-on-rails

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.

Related

Setting up multiple rails apps using nginx and Puma

I have a web server serving multiple Rails applications using a combination of nginx and Passenger. This is pretty straightforward, because the Passenger install sets-up pretty much everything you need to connect to nginx.
I found "Rails app with Puma" that seems to explain how to set up nginx and Puma together. How would this configuration need to be modified in order to serve a second Rails application on the same server?
Also, this guide doesn't say anything about restarting the application automatically if there is a system reboot or some other issue. Is there a way to do that? The nginx + Passenger combo seems to do it by default.

find which web server rails app using

I am new to rails.
How do I find which web server rails app using?
Command to start app is
rails s puma -dp 80 -e production
Also I see apache2 is not running on server. So I guess Puma is being used. But I am not sure Puma is webserver, I found link which describes setting up Puma with nginx. So Am I using nginx? Also where do I find log of this web server?
Puma can be used as a webserver, since the command line appears to be setting the port to 80, this is probably how it is configured in your case. This works fine for the most part, but a more common configuration is to use apache or nginx as a reverse proxy and to serve static assets. (the stuff in public/assets). Requests for non-static content are then forwarded to puma.

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.

Starting Rails server on boot on CentOS

I'm pretty new to rails and trying to figure things out, I looked online but not much luck.
I have some servers that are running rails on startup without using rc.local at all, but I can't figure out why.
All I need is for rails to start on boot in production mode on port 80 (instead of 3000, as the rest of the servers also start on port 80).
Any ideas?
ATM relaying on webrick
Have a look at setting up nginx with ruby enterprise edition.
Check out Phusion Passenger. It supports both the standard Apache web server and Nginx web server.
http://www.modrails.com/

Configuring Passenger with Ruby 1.9.2 + Rails 3.1.0rc4 and Ruby 1.8.6 + Rails 2.3.11

How can I configure Passenger to run two different projects under these requirements?
First project is Redmine (Rails 2.3.11 and Ruby 1.8.6) and second one is something like a mini-blog (Rails 3.1.0rc4 and Ruby 1.9.2).
OS: Ubuntu Server
Personally, I prefer nginx to Apache, but you can do this with both.
First, the bad news - you cannot do this with a single installation of either Apache or nginx - passenger is compiled against a single specific ruby interpreter that you are using. Now, the good news is that since you have rvm setup, it is trivial to manage multiple ruby interpreters.
You need to have two separate http server (Apache or nginx) installations - one will be the default and answer on port 80, and the other will need to answer on another port (this will not be publicly used). You need to compile passenger for one ruby and http server (Apache or nginx), and another passenger for the other ruby and http server (both http servers can be Apache, both can be nginx, or if you want to make things "interesting", you can have one of each). I highly recommend using ruby 1.9 with your default (port 80) passenger since any new apps you run on the server will be using ruby 1.9+/rails 3+.
Once you have each http server + ruby + passenger setup, you will need to configure your secondary site (running on the not-port-80 web server) as a proxy + reverse proxy from the port 80 http server to the secondary http server (e.g. port 5000).
I have this configuration running for a couple different clients (on different production servers) and do not have any trouble. In one case, we are using passenger standalone servers for the secondary ruby/passenger combination rather than having a full nginx installation - this has proven to be quite stable, but creating functional init scripts that worked as we wanted was a bit fun.

Resources