What to do after Rails deployment? - ruby-on-rails

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

Related

Ruby on Rails application deployment on local computer with postgresql

I am new to Ruby on Rails. We have developed an small application with Postgresql. Now we have to deploy it. But when i searched over internet i found lot of suggestion is to deploy them on Heroku or some premium servers. where we are not in a position now to deploy it on cloud.
How can i deploy the application on local computer? Is this similar to setting up a development environment?
Any link or lead will be much appreciated!
I hope you have your application already running on your development environment.
Create another database in your postgres, to use it for production in local system. And make necessary changes in database.yml
I feel passenger is the easiest way to deploy application, you can follow the steps in this link https://www.digitalocean.com/community/tutorials/how-to-deploy-a-rails-app-with-passenger-and-apache-on-ubuntu-14-04 to deploy your app.
Heroku also have free deployment for few application. You can use heroku.
There are some more option like AWS, Digital Ocean. AWS is also free for one year.
Yes setting up a development environment is like set up your environment. But best practice is use a deployment automation like capistrano.
You can run it in a production environment and make it public. I had written a blog post regarding this.
Please check here
ps - Make sure your system is up for public access and i am hoping that this is for test purpose only and to show it to your clients.
Yes, it would be fairly similar to setting up your development environment.
In addition to setting up Passenger as described in the Digital Ocean post from Rajuk's answer, I use Capistrano for deployment to my Ubuntu servers. You can set up the Capistrano deployment configuration to deploy to any machine.
The possible configuration variables are too numerous to address here without further details about your specific situation.
Check out Railscast #335 Deploying to a VPS where Ryan talks about deploying to a Linux machine (a cloud VPS in this case) with Capistrano.

Deploying Ruby on Rails on Bluehost

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.

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.

How do you deploy your Rails application?

Do you upload your rail application to your host via FTP first?
I'm currently using Passenger and Capistrano. If I do "cap deploy" in my local machine then I think Capistrano should upload my rail application to my host, right?
Someone from my host is saying that I need to run "cap deploy" in server. I think it doesn't make sense.
You should be able to run cap deloy on your local machine and that should get the current version of your software to the server. However, you need to set up first how this is supposed to happen. I for example use Git to manage my code and also use it to get my software on the server. However, you could also use SVN or FTP if you prefer that. If you google for Capistrano together with the Software youbeant to transfer the code with and maybe even your hosting providers name, you probably will find a decent step by step explanation. For me John Numemaker's post on deploying with Capistrano and Git on Dreamhost really helped: http://railstips.org/blog/archives/2008/12/14/deploying-rails-on-dreamhost-with-passenger/
As an alternative you also might want to check out heroku.com. Their smallest offer is free and enough for most projects. The deployment process is so easy a monkey could deploy a Rails app on their platform. I generally can only recommend heroku.

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