I've developed my Rails project locally and want to deploy it on my Ubuntu VPS. Now I've installed the gems on the VPS and copied my Rails App code to it. I can execute rails s --binding=0.0.0.0 in a putty session to the VPS and the website can be access from the Internet. The problem is when I close putty, the website is down. How to start my Rails App in a way that it still alive even if I closed putty?
Using rails s is not the way to go. It will use Webrick(or a different one if you choose) to handle the requests and it can be quite slow.
You should setup a production stack for serving your website.
Here is one of the best tutorials I've seen about how to deploy a Rails app to a production server(VPS).
In short you gonna need install RVM or Rbenv, Ruby, some libs, Database, Nginx and Passenger. You have alternatives too. But this is the basic.
I recommend using Capistrano for deploy. You can choose another deployment tool also, or none.
rails s it is best for development only.
Related
I have a rails application that I'm trying to use on other machines that do not have ruby, rails, or bundler installed. Is there a way I can zip up the rails application, the ruby environment and all its gems / dependencies? I'd like to be able to just send the zipped file to a computer without ruby and be able to run the application without having to install ruby, rails, bundler and all the gems in the rails app.
I've tried traveling-ruby, but it just packages ruby and not rails or bundler.
Edit: For clarification, the app is an internal tool for work. We would rather not deploy the app to a server, but rather just share the whole package with computers that may or may not have the dependencies installed.
You should consider Docker to prepare a "package" of self sufficient environment for your application. This way you will be able to send it to another machine and run without problems. You can use those containers for development purposes only. There is no requirement to deploy them into a server.
I am using rails 2.3.9, rubygems 1.8.24, ruby 1.9.3 and Windows 7 ultimate 64-bit
I just installed nginx as my web server through passenger. Now I want to run nginx as my default server such that when i run ruby script/server, it runs instead of the default WeBrick. Is there any way to do this? Thanks a million.
Nginx doesn't work the way you described. Once it is started, you won't need to run script/server, the rails app will be run at the same time when the Nginx/Apache started.
So, just deploy your rails app following the 'Passenger' manual( in development mode), and you will get your app always running.
so, as conclusion, we can tell that, when deploying a Rails app, Nginx and Apache is in the same group( work together with Passenger), and Mongrel/Webrick/Thin is another group(script/server approach).
You may want to take a look at Foreman.
I have originally been hosting my apps on Heroku, however this is not an acceptable deployment method in my current environment. We have personal information in our applications that deploying to Heroku and setting up DNS forwarding is not acceptable. Regardless of how 'secure' or 'reliable' anyone may think it is, it is just not acceptable in my case.
Our host is siteturn.com, integrated with Plesk 10.4.4. If I SSH onto our websites server as admin and type
ruby -v
ruby 1.8.7 (2010-08-16 patchlevel 302) [x86_64-linux].
rails -v
Rails 2.3.5
It appears Ruby and Rails are already installed (Older versions than I require, as I need ruby 1.9.3 and Rails 3.2) If I'm not mistaken it seems like my host 'supports' rails (why else would it already have it installed :P).
How should I go about deploying my application directly onto my companies website?
Heroku is an awesome service but the ease of deploying to Heroku has given you a skewed view of what is involved in hosting your own rails website. Heroku has shielded you from a lot of the hard parts.
For example, just because ruby and rails is installed does not necessarily mean you can host a production rails website. You'll need a rails specific web server (for example nginx and passenger, unicorn, etc). You also need a database (MySQL or Postgres) assuming your web app uses one. Also, as you said you need to upgrade the versions of ruby and rails.
That's just to get the server setup. After that you can get to the deployment part. Capistrano seems to be the most popular choice right now.
Take a look at this railscast episode on deploying to a virtual private server for a very good overview of what is involved. It also briefly goes into Capistrano as well. It's not a free episode but I feel it's definitly worth the money.
Pick up a copy of Agile Web Development with Rails, Third Edition and read what it says about deployment. That should get you started. There's more info required than can be put in a SO answer.
In my local, I am using werbrick application server for my localhost.
I have Ruby version 1.9.2 .and Rails version 3.1.
How to deploy On live,with Rails Project On Nginx Server?
And What will be the application server (like passenger module with apache) can be used with Nginx server for Rails 3.1 application?
This blog post should give you a good starting point. This one here goes a little deeper in detail. Note: I used these to get nginx running on my local development machine (OSX 10.7) and to host different rails apps locally without using Webrick. Probably there is more to take care of on a live / production system.
Thanks Tilo for your response. I will try to ask a better question.
I need to set up a Ruby on Rails Production environment that will only be used to host RoR applications and will be used as a Git server too. There will be no development done to these applications on the Production server. Right now, I forsee the production server hosting a maximum of 5 to 6 applications only. A couple will be company internal only and the rest of the apps will be viewable to the public. The traffic that they will receive is about 12 to 20 hits per week.
I have been given access to a Virtual Machine that will be the Production server and is currently running Ubuntu 10.04 LTS, Apache2, MySQL, and Passenger. There will be two RoR developers using the Production server to host their applications.
My Development Environment of which I am running Ubuntu 10.04 LTS, Apache2, and MySQL on my own laptop looks like this for each project/application:
RVM installed per application, Git,
Ruby 1.9.2 installed thru rvm, Rails
3.0.3, and I have yet to install the Capistrano gem.
My question is I don't understand how to host a RoR application on our production server.
As an example of what might be done to host a RoR application: I am surmising that I will create a user called app1 under the home directory. Next, should I install Ruby system wide or should I install rvm for app1 and then Ruby for app1? What are the steps involved on how to set-up the environment to run an application on a production server?
Can you give me a few setup scenarios, please?
Thanks in advance.
You didn't tell us what you want to use this web-site for... is it company internal only?
just a few users? or is it externally facing the internet? Just one server running everything?
If it's facing the internet, I would certainly stay away from Ubuntu... look at CentOS/RedHat or FreeBSD to install on a production server.
I'd definitely use Capistrano for deployment. Definitely Git.
I would definitely not install RVM system-wide - IMHO it is not robust enough.
I emailed with Wayne Seguin (maker of RVM) and he also uses the method I've outlined in the post below,
using one dedicated deploy user:
For how to deploy ruby-versions and gems with RVM, look at this post:
Installing Ruby offline using rvm
If you really need two versions of Ruby for two different apps, then use two deploy-users!
Each of them has their own default-ruby-version(!) that's why you really need two users :)
and you can install / manage the gems for each project separately under each of the deploy accounts.
You should also put the git repository in each of the accounts, so you can test.