Sending Rails app live with Nginx on Ubuntu 10.04 Lucid box - ruby-on-rails

we are following this nginx guide and we want to send our Rails app LIVE right now. what do we replace rails_env development with at 2:26 in order to send it live and not to development??

Set it to production if you want it to run in the production environment.

Related

How to run rails applications on digitalocean using "rails s" (make it a development environment)

My issue is that I created a droplet to develop Rails apps in digitalocean .
I used the one-click rails droplet. And now I want to create more rails apps than the default rails app in this droplet.
The issue here is that it comes installed with nginx/unicorn .. And they're always on with path of default rails project in their config files.
Now let's assume I created another rails app(file) and I want to run it using "rails s" instead of default rails app that is created by the droplet. How can I do it?
Note: I don't want to change the file path in configs each time I decide to try another app
PS: I tried stopping the service of unicorn/nginx one at a time and both of them in the same time to use "rail s" to run the app .. But it didn't work .. Web pages were not loading
I know it might be a question of a rookie. But I'm kinda new to these stuff and I'd appreciate it if anyone could help me.
If you run it with rails s on the server, chances are it will be running with Puma, or if you're on an older version of Rails, Webrick. Unicorn is not involved in that case because Rails is using its own default web server. If you see that 'rails s' is not running in the right environment, it may be because RAILS_ENV is being set in your shell profile. You can override that by doing:
RAILS_ENV=development rails s
To launch your console.
That being said, rails s runs on localhost:3000 by default - and in the case you described it would be running on DigitalOcean's localhost - not yours. In order to get to it from your local machine, you would need to set up some sort of reverse proxy to allow connections to DO to get served from localhost. This is what nginx is doing for you - it's facilitating a reverse proxy.
If you want do use your DO server as a development machine for a second rails app you have, you're going to have to create that new rails app on the server, then create the reverse proxy settings in nginx to direct to it, then finally create the unicorn settings to serve it. This is an uncommon way of developing though. I recommend using your local machine to develop, and setting up Capistrano or some other deploy tool to deploy it to DO instead. You'd still need to add the settings in nginx/unicorn for the second app, but it will save you headache down the road.

Digital Ocean with Dokku for Rails 4 and Nginx

I recently switch from using Heroku to DigitalOcean. I have to say that nothing beats the pleasure of using Heroku, unless the concern is about server location, and price.
Deploying my existing Rails app from Heroku to Digital Ocean with Dokku is pretty smooth, but I wonder if Nginx is being used to serve the Rails app.
The answer is no. I stop Nginx, and the server is still serving the app.

Why is my rails app at example.com:3000 and not example.com?

I am building a rails app but it appears at example.com:3000, how do I make it appear at example.com?
Thanks
Presumably because you are running the development app on its default port.
Go through the deployment process for your live system.
If you run your app with rails server you can run it with rails server -p 80 but you must be root and this solution is not good for production. You'd better use a solution provided by Quentin's link.

How practical is it to run a Rails server with Apache or Nginx even in development mode?

Since WEBrick or Mongrel might be limited to not having keep-alive etc, can't Apache or Nginx be used with Rails even in development mode?
For example, running Apache there always, and attach Rails to it, so that starting Rails meaning starting the Rails part, and no webserver such as WEBrick or Mongrel need to be started. Is that feasible? On some Mac, even Apache is running all the time when the system Settings has the "Web sharing" selected.
You can use Apache or nginx or any server of your choice for any environment you wish to run. But you can't just start it with rails server.
As described in this post, you just need to set the right option in your httpd.conf, in the section that serves your rails:
## Specify Rails Environment here, default value is "production"
RailsEnv development

Running more than Rails apps on a local Mac

I would like to set up multiple Rails apps running simultaneously.
I'm using a basic installation with Rails and Mongrel. I'm pretty newbie when it comes to a server side thing.
What kind of options do I have to run multiple Rails app running at the same time on a local Mac?
The only thing that stops you from running multiple rails apps on one machine is the ports.
If you want to run several apps while developing just use script/server -p <port number> for each of the apps.
If you have a production machine set up, I would recommend you to use phusion passenger with apache or nginx, and set up different virtual machines (or ports)
If you end up using Phusion Passenger, the Passenger Preference Pane can automatically configure your Apache virtual hosts for you. It's a lot easier than editing the Apache configuration and your /etc/hosts file each time you want to set up a new application.
Generally you start rails server using webrick or mongrel like
script/server
and
mongrel_rails start
respectively, that starts your server on port 3000 by default, ie. you can access your app on localhost:3000
To have multiple rails apps running on same machine, just start the servers by going to different rails application root directories on different ports like so
script/server -p 3001
or
mongrel_rails start -p 3001
Just for info, if you want to start rails apps in different environments then just pass -e option when you start the server like so
script/server -e production
or
script/server -e test_or_anyotherenv
If you don't give -e option, then it will by default start the server in development environment.
I'm a Django (not Rails) coder, but I think you should launch the servers at different ports.
Initially, I used mongrel on different ports. Works just fine. But, as agregoire mentioned, Phusion Passenger and the Passenger PrefPane make your life so much easier. Checkout Ryan Bates's RailsCast, Passenger in Development, for a good tutorial on setting it up.

Resources