Deploying Ruby on Rails on Bluehost - ruby-on-rails

Does anyone here know how to deploy a Ruby app on Bluehost? I am having quite a problem with this. Everytime I put my files inside the folder where my domain is pointing at, it always giving me a 403 error when I try to visit the website.

It's so painful. The instructions are incomplete. There are a bunch of things to get caught on like broken versions of sass, assets not pre-compiling, database configuring, how to restart the server, the root directory for passenger, etc.
I had problems with all of those things. I had to come here (Stack Overflow) to find most of the answers.
My site still runs in dev but not in production. The BH support is not much help. THey should call it BlueWordPressHost because that is who they are supporting.
Look in the <rails_root>/log directory for clues.
I'm not willing to switch over to Heroku and use postgres, I tried it but in reality your just dealing with another set of problems setting it up.

Give it a look -> Ruby on Rails Setup with Bluehost.
You cant just drop your Files in a folder.
Although Bluehost does a great job, i recommend you using Heroku for deploying Ruby on Rails Apps.
Deploying with Heroku is quite Easy -> Deploying with Git

I followed the instructions in the Ruby on Rails Setup as The Mini John referenced and it worked. They use Phusion Passenger to allow you to deploy any rack based application. However, I did have to manually install my gem dependencies. This is probably not a scalable solution for a production application with many users. However, if you already have bluehost as a hosting provider and are willing to maintain your own server and deal with possible latency issues and downtime, it may be worth it for you. Here is my Ruby on Rails 4.0 "Hello World" application deployed to bluehost: http://hello.getplanit.com.

Related

Deploying rails app basics

I've been self teaching myself ruby and rails for the past year and finally have an app ready that I want to deploy out to the world. While I can relatively easily deploy to Heroku, I would rather learn how to configure things myself but I have very little understanding of web servers and what all is needed to deploy things. I've done a lot of research and it seems like most rails apps are deployed with some combination of unicorn/puma with nginx and Capistrano. I was hoping someone had resources or could explain the bare-bones basics of these tools.
I am mostly confused about unicorn/puma vs nginx. They all seem like web-servers, but clearly nginx is different from unicorn. I have no idea how they interact with each other in order to serve web applications.
I know Capistrano is used to deploy code, but I have no idea what that actually means.
Lastly, how do these tool interact with hosts such as AWS or digital ocean.
Any help or resources that can get me started would be appreciated.
This is the best overview that helped me understand the different options that are available: Ruby on Rails Server options. It covers most app servers and how they compare practically, and it covers Capistrano at the end.
Personally, I use AWS OpsWorks for my production environment (they have a Free Tier available for a year) which has a default Rails on Nginx or Apache app server layer: http://docs.aws.amazon.com/opsworks/latest/userguide/workinglayers-rails.html.
I found the Deploying Rails book to be a comprehensive resource for all things related to rails deployment. Unfortunately it is out of print. I doubt if it is too outdated even if it was written for rails 3.
There are quite a few good blogposts; one I found very helpful was http://robmclarty.com/blog/how-to-deploy-a-rails-4-app-with-git-and-capistrano
Note: The above blogpost uses capistrano version 2.14.2.
I would advice following the same steps to understand capistrano, and then use http://capistranorb.com/documentation/upgrading/ for upgrading to capistrano version 3.x
This guide is pretty helpful and succinct
Using Capistrano 3, RVM & Puma
https://coderwall.com/p/ttrhow/deploying-rails-app-using-nginx-puma-and-capistrano-3

How to configure and deploy Ruby on Rails Application on server using apache, heroku or Phusion Passenger dont know about such terms

I am new to Ruby on Rails. I have been working as junior developer and most of time working on localhost so don't know how to launch Ruby on rails application, How to Configure Ruby on rails application and how to deploy it.
often I came accross following terms but don't know It's meaning and how to use them and where to use them.
Apache
Phusion Passenger
Heroku
nginx
Please Help me and also looking forward to any good tutorial to learn all that terms.
Thanks.
I think there is quite a lot of resources on the web for this, but :
Heroku is a platform as a service. Basically, you push your rails app to a git remote, and that's it, deployed. You can manage addons, workers, and processes from CLI, and scale up/down if you need. Probably the most painless way to start with.
Apache & nginx are two werbservers, I'd say they are the most common in the rails world. Nginx is the latest of the two and it seems to be better for most of the tasks, but if you want to know which to choose, there is several posts on the internet for that too.
Phusion passenger is the bridge (or one of the available bridges) between your rails app and your webserver. If you've done php before, think of it as mod_php.
Since this is all new to you I'd advise that you start with hosting on Heroku. You can do a lot with the free version and it's arguably the easiest way to get started with hosting your rails website. Check out the getting started guide from Heroku. There's also another beginners guide here.
Once you feel comfortable with Heroku your next step could be looking into hosting on your own virtual private server (VPS). The setup is much more manual but things that would cost extra money on Heroku are now free if you set it up yourself on your VPS. Here is a great article on VPS hosting.
For reference, I was hosting websites on Heroku for about a year before I started looking into hosting on my own VPS. Now what I do is start by hosting my projects on Heroku since it's the fastest way to get up and running. Then if the website is successful I transition to a VPS.

What to do after Rails deployment?

I am am a newbie in Ruby on Rails development and I am learning this fantastic framework fast and easy. The only problem (which is a big one) is how to deploy.
I have tried a Linode StackScript which installs Ruby, Rails, Passenger and Nginx and I have made a "cap deploy" and all files was sent to the server but how on earth do I get this public. When I visit my website (IP) it seems to be down or not responding. Is there anything I need to do after deployment to make my app available to the web?
Thankful for all help, I really want to slay the deployment beast!
For ease of deployment, and scalability, have you looked at Heroku instead of hosting your own server?
That would make the process of deploying as simple as git push heroku

Rails application on shared hosting?

Is there a way that I can deploy my locally made rails app on a shared host that has Ruby installed?
Capistrano to deploy and (Mongrel or Passenger... preferably the latter... or if you HAVE to, FastCGI although FastCGI is pretty slow with Rails) to serve.
If you have a shared host you'll have to vendor your Rails version and all your gems, as you probably won't have access to install gems. Even if you did, you won't want Rails picking old versions of things.
Personally, I would use Capistrano. There are plenty of books and tutorials around that will tell you how to use it to deploy Rails applications. It is very easy to configure.
Dreamhost supports Rails, many others probably do also.
As for installation of your app: it depends a bit on what's already available on your shared host, and what you're allow to do / install / configure there. For Dreamhost, here's their documentation. Other shared hosting solutions may or may not be similar depending on their policy.
The best way I've found is to install the passenger gem. Once you've uploaded your app to your account all you need to do is add a few lines to your .htaccess file and you should be off.
Definitely capistrano + git (git, if you have SSH access, like f.e. in HostingRails shared host), nothing can be easier.
Neat Capistrano guide: http://www.linuxjournal.com/article/10100
How to config Capistrano + git: http://github.com/guides/deploying-with-capistrano
Some nice Capistrano recipes: http://github.com/josh/slicehost
Assuming your http server is nginx or apache, install Phusion Passenger
On the Passenger site, there are very good docs for configuring Apache/nginx with Rails
As a first step, just copy your Rails app somewhere to the host and get Passenger working
Once you have that working, you will need a better way to deploy/update the app; as others have suggested, Capistrano is a popular way to do it and you should have no problem finding some tutorials online to help you do it
I have done steps 1-3 and it is incredibly easy and works perfectly fine (I was just too lazy to do step 4).
Found a good reference : REFERENCE LINK this will help to deploy ROR App on a shared host.

Why is it supposedly "hard" to deploy Ruby on Rails to production?

I admit that I don't follow much of anything "right" on deploying test versus production code. I have been using ASP.NET, and I typically run it locally in Visual Studio, it works, I upload it, I test it again on the production server.
I have read several people say that deploying Rails apps is harder and there are special programs/ways on the ruby site about deploying RoR. I've only toyed with RoR. What is special about deployment? You don't just copy and paste the code and run it (from development machine to the production)? Is it because one is in Apache and the other running on the built in server?
This will be on a Mac Server if it matters.
Deploying RoR is not difficult anymore, especially with Phusion Passenger.
What is somewhat difficult, is getting a automated production environment setup with capistrano, vlad, etc. If you don't mind simply copying your code to the server, you can do that just fine. Most people choose not to do it that way because you lose out on a lot of the benefits that the automated deployment tools give you.
I guess people consider a Rails app harder to deploy than say some PHP apps or such where you just plop the code somewhere and point Apache or whatever at it. But, as mentioned above, you could do that now with Phusion Passenger.
We use Nginx+Passenger, but not for simplicity of deployment. Capistrano is our deploy tool of choice, and really, unless you have a very simple app, you're going to want something like Capistrano anyway. For example, with our deploy, we do a slew of things:
run any database migrations
generate release notes automatically, based on all the commits to Git between the last deploy and this one
notify various people via email (with differing lists depending on whether the deploy is to our staging environment or production) - we do this via cap_gun which integrates with Capistrano.
Notify New Relic RPM of the deploy so it can mark it in our RPM analysis
Notify Hoptoad of the deploy, so it too can have that data when reporting any exceptions
produce our sitemap.xml file, and ping Google to tell them there's a new one
update crontab files (I store our crontab files for each server in our git repo, and then on deploy it sees if there is a new version and updates accordingly, etc.).
flush/restart memcached
There are other ways aside from Capistrano, but it's a proven tool, with a lot of flexibility, yet pretty simple to setup a vanilla configuration.
So, my take is that once you get into any app that is beyond just the very simplest of apps, you're going to need/want to be doing things other than just simply updating the code. In the beginning though, if you just need the code updates, and maybe Rails migrations, then you can do simpler things like Passenger and code sync, or look at tools like Heroku or Engine Yard's stuff where they do a deploy by doing a Git clone (and then offer some additional abilities).
Another super easy way to deploy is with http://heroku.com/
Some of the issues you face with deploying rails to production:
Database connection.
You need to be sure that the database connector is set up for the production environment.
Database migrations.
You have to run database migrations against the production database even though you may have already run them in production/testing/staging
Ruby version. The version or sub-version or Ruby can trip you up, e.g. An error occurred while installing debugger-linecache (1.1.1), and Bundler cannot continue
Gem dependency.
Your production environment may have different packages and gems from development. Bundler will figure this out for the most part and install the dependencies but occasionally there are still issues that you have to resolve manually.
Dependencies.
Some gems on some machine have particular dependencies. I have seen frequent problems with using gems on my unix box that work on OSX and vice-versa.
Note the last 3 shouldn't affect you if on the same machine but I included them based on the title and to be comprehensive.
It's not especially hard. If you stick to conventions then with a little bit of configuration it boils down to this:
cap deploy
...however there is sometimes a bit of effort needed up front to get the workflow in place.
The good news is that lots of people have packaged up solutions and stacks for RoR that you can just plug and play. For example, google ec2onrails - this is a packaged Ubuntu image and set of capistrano tasks for running rails apps in Amazon's EC2 cloud, with lots of common stuff set up already out of the box.
Choose a good hosting provider and you should be able to find something similar for that also.
An easy way to deploy Rails apps is to use Phusion Passenger. Deployment doesn't get much easier than that for any programming language or framework. You can do that on a Mac server.
Another really easy way to deploy rails is with jruby and the glassfish gem.

Resources