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.
Related
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.
I want to run multiple rubies on our production server. We have some ruby 1.9.3 rails 3.2 sites going live as well as keep older 1.8 sites. I understand that Passenger 3.2 will be able to do this natively but isn't live yet.
So for now, is this the best way to do this?
http://blog.phusion.nl/2010/09/21/phusion-passenger-running-multiple-ruby-versions/
The apache passenger module can't do this. You could however run passenger standalone for each app (with a different ruby version) and then proxy from apache to passenger standalone.
You could of course also proxy to unicorn, thin etc.
What about using multiple VMs/Slices for your different versions of ruby and rails, that way you have more control of your enviroment and don't have to worry about your different rubies/rails causing headaches with each other.
EDIT
Another solution that I have heard of but haven't tried is setting multiple users and running each version of ruby/rails per a different user
I want to develop a website using Ruby on Rails.
What is the requirements for the Server, i.e. what do I have to tell the admin what I need. I believe the server will be running on a machine that is already hosting some websites which use PHP. I dont know more about that so far, and it will probably be depending on my requirements.
As far as I understood from documentation and other questions the server needs to have ruby, rails installed. It also said that I could use cgi.
My problem is that I need a concrete list of things that my admin should provide.
Another question suggests that the only thing is to intall Phusion Passenger if I can use an Apache Werbserver. This would seem like an option maybe.
So what do I really need?
Phusion Passenger is the easiest way to go in a mixed environment.
A Rails app needs these things:
ruby (ruby enterprise edition or MRI 1.9.2)
rubygems
sort of gems handled with bundler
You should try it with Passenger on Your local computer. Then you will see the list for the installation.
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.
Does the hoster have to support "Ruby on Rails" or "just Ruby" to run Rails?
I know mainly PHP and ask myself if "Ruby on Rails" behaves to Ruby ... like "Zend Framework" to PHP: just a bunch of PHP files I can copy in my project folder and my hoster only needs to support PHP.
I ask as my host only supports Ruby (but not Rails). If I couild just copy rails over sftp within the project, I would like to give it a try.
The primary thing is, you cannot chain your Rails application directly with Web-server, so the hoster should support one of these servers: Passenger, Thin, Mongrel, and so on.
Another thing to know is, your Rails application can also depend on some specific gems, thus they should be already installed by the hoster to successfully run your application (for example, the hoster has some super-duper control panel that can deal with Rails bundles to setup every gem, check environment, do migrations, and then run the server itself; or the hoster gives you plain SSH and you do everything you need to do, if you know what to do and how to do).
The host has to support Ruby (or JRuby). Rails is a framework that's implemented as a set of Ruby files that are distributed as RubyGems.
If a web host says they support Ruby, it's assumed Rails will work. Rails is just a Ruby application though, and all the Rails code needed to run the application can (and often does) live right in your app's directory tree.
Rails is a Ruby framework. So a basic rails app needs only ruby and rubygems. RubyGems is similar to PHP Pear but a bit more flexible and powerfull. In order to serve the HTML produces by your rail app you need a webserver. Ruby provides natively a "basic" Webserver called Webrick.
But in a production environment you'll need a real webserver (Nginx, Apache) and Passenger.