Quick and easy Slicehost slices - ruby-on-rails

Can anyone point me to an article with the best way to quickly setup a Slicehost slice with Rails/Git from scratch?

Slicehost has a number of useful articles on how to set up rails. These capistrano recipes might also come in handy.

If you arent' experienced linux/apache admin, you can follow a sequence of 6-8 of pickled onions posts: apt-get update, SSH, iptables, mysql, ruby, gems, rails, apache, mod_rails
Here's the sequence for ubuntu intrepid
Here's what i used for Hardy
http://articles.slicehost.com/2008/4/25/ubuntu-hardy-setup-page-1
http://articles.slicehost.com/2008/4/25/ubuntu-hardy-setup-page-2
http://articles.slicehost.com/2009/2/2/ubuntu-intrepid-installing-mysql-with-rails-and-php-options
http://articles.slicehost.com/2008/4/25/ubuntu-hardy-installing-apache-and-php5
http://articles.slicehost.com/2008/4/28/ubuntu-hardy-apache-config-layout
http://articles.slicehost.com/2008/4/28/ubuntu-hardy-apache-configuration-1
http://articles.slicehost.com/2008/4/28/ubuntu-hardy-apache-configuration-2
http://articles.slicehost.com/2008/4/30/ubuntu-hardy-ruby-on-rails
(This is a good minimal sequence. I would recommend spending more time learning iptables, denyhosts, how to blacklist IP's and summarize logfiles to lock the server down).

I just did a slicehost installation (Ubuntu Hardy/RoR)
Install Ruby
thin installation (your RoR server)
Nginx installation (The web server/vhost/proxy)
Watch git tutorials here - they are great!
Thin/Nginx is very easy to set up compared to Apache/Mongrel, and uses less memory. Apache wins in some performance test, but uses more memory.

Rails core team member Josh Peek has some Capistrano recipes for setting up and deploying to Slicehost.

Related

Setting up Ruby on Rails for web development

I was considering installing, setting up and using Ruby on Rails for web development. Where should I start and how does Ruby on Rails work with a local server? Any OS where Ruby on Rails is optimal or any general advice I should know?
Any OS where Ruby on Rails is optimal or any general advice I should know
Linux and Mac OS are by far the most popular dev OS's for Rails - you can install dependencies much easier.
Windows can be a real pain with Rails at first. Not rails, but its dependencies. These are called Gems and work like plugins.
Certain gems require external binaries / C headers for them to run. Two of the most notorious are the MYSQL2 and RMagick (ImageMagick) gems.
--
I don't know the core problems (it's something to do with MINGW32 / Win32 environment), but Windows often has a difficult time with certain gems.
Not that it's stopped us - we have a series of Windows machines devs use to create truly incredible RoR apps (very difficult to get them all running smoothly).
DB
You don't get a DB with your Rails install - you need to have that running separately.
If you don't want to install a local MYSQL server (which can be a pain), I'd recommend getting some cheap shared hosting (with unlimited MYSQL db's). This will allow you to hook up your app to a third party DB host, negating any data integrity issues if your dev machine has problems.
Make sure you have PHPMYAdmin too - it's a life saver :)
Although Rails with many different SQL variants, MYSQL is the most popular. Heroku has made PGSQl quite popular within the Rails community, although I'm not up to speed on the major differences.
how does Ruby on Rails work with a local server
Rails comes with its own web server for development, called WEBrick.
Honestly, WEBrick is a pile of shit but it works.
You just need to load up the cmd, type rails s and it will fire it up. If you get some more experience, you can use the likes of puma or thin as dev servers (they are much faster and better mimic the production environment)
In production, you'll be best using one of the commercial-grade servers like Apache or NGinX, good tutorial here.
Getting Started
There are a ton of tutorials to get started with Rails.
Some of the best resources are:
RailsCasts (stopped mid 2013)
GoRails (still active)
Michael Hartl Rails Tutorial
Finally, enjoy yourself. I remember the Tumblr guy saying that he got such initial traction for Tumblr through the Rails community (he said they're the most committed bunch ever). He was right, the Rails community is a big family who all love code.
Download Rails from http://railsinstaller.org
go through online tutorials and start working
it a beautiful language to work with

Chef cookbooks to set up a Rails production server (CentOS)

So, I got tired of seting up production servers for my Rails apps all the time and decided to learn to use a tool that can simplify that process for me. I choose Chef-solo.
I've read the documentation and watched some tutorials, but I'm not realy sure I understend the process well, so I decided to go right to practice and learn on the way.
Now the real question: can someone provide me with a set of correctly working cookbooks to set up the server so I wouldn't need to reinvent the wheel myself?
OS - CentOS v.6.0-6.3
Software:
Development Tools (groupinstall)
git
Node.js
ImageMagick
Nginx and Unicorn
MySQL and PosgreSQL
Mail Server POP/SMTP/IMAP
RVM + ruby
MemCache
Think that's it.
Ofcource I need not only to install the packages, but also to configure them properly.
Any suggestions or additional info needed?
You can try looking at my repo at https://github.com/dmytro/chef-solo
I am using it to bootstrap Rails environments for myself.
Additionally it can be combined with Capistrano deployment. I use this in my capistrano recipes https://github.com/dmytro/capistrano-recipes
I've put blog post on these. Please lake a look too: http://dmytro.github.io/2013/05/21/easy_spawn_new_hosts_with_capistrano.html

Config rails server on vps hosting

I must configure my RoR vps hosting for my rails app, but on my localmachine i simple use webrick...
Are any ways to do this on server, so that it will be faster, and also, if it reboot's or memory down, or something that call's shutdown of server, then it automatically starts?
Also how about rails enterprise?
Now i have clean ubuntu server, and rvm on it
Follow this tutorial, it's great for beginner and will answer all your questions: http://coding.smashingmagazine.com/2011/06/28/setup-a-ubuntu-vps-for-hosting-ruby-on-rails-applications-2/
Which webserver to use depends on many things. Among others, there's Thin, Unicorn, Rainbows, Puma, and counting.
I suggest you look on google (or even here, I'm pretty this was answered before) for comparisons between ruby webservers, so that you can know what situation each of them are adapted to, and which one will fit your needs best.
For production deployment you need to install nginx or apache,
nginx is lightweight ,consider installing nginx,
Now there are various ways simple and easy to install is passenger with nginx
Or simply you can use nginx+unicorn or nginx+thin you can find various article just google it.

Deploy Rails app to EC2

My setup: Rails 2.3.10, Ruby 1.8.7 on Windows
The last time I deployed a Rails app from Windows to Linux on Slicehost, I used Capistrano, Nginx, Mongrel, and SVN. That was 3 years ago, fast forward to now, I'm still on Windows for development and is now looking to deploy to EC2. A quick search turns up tools like Rubber and Chef which aren't easy to grasp with a quick read. It seems like Rubber and Chef are designed for multi-EC2 instances deployment which will be useful when I need to scale.
I'm also new to Passenger but it seems to be the default way to deploy Rails app nowadays, one thing that isn't so clear to me is whether Passenger is a replacement for Mongrel? In my old setup, I configured Nginx to forward the Rails requests to a cluster of Mongrel processes but I don't see anything like that for Passenger.
Any insights are much appreciated.
We use something like what you're describing for our production server: EC2 + Apache + Passenger. We haven't had any need to use the fancy deployment tools you describe - plain old Capistrano (plus capistrano-ext so we can use it for multiple environments) does the job just fine. I've looked at Rubber (not Chef), but deemed it needlessly automagical and too poorly documented, and I'm really not sure what it offers that can't be done just as well with roles in Capistrano.
Passenger has been great. It's an "overseer" that manages a collection of Mongrel-like workers (I had thought that the workers were Mongrels, but upon further reading, I don't think they are. The Passenger comparisons page even compares its RPS to a Mongrel cluster, so...), starting them up as needed, culling them under low loads, restarting them if they crash, etc. It's actually very similar to the Server + Mongrel Cluster you described, but probably a bit better, as Passenger has an understanding of the underlying workers that Nginx / Apache don't. And you'll have to make a few minor tweaks to get Capistrano playing nicely with Passenger.
And if possible, pair Passenger with Ruby Enterprise Edition (from the same guys who made Passenger). It's a much faster version of Ruby, mostly due to a rewritten, configurable garbage collector. You'll have to tune your GC settings to get the most out of it.
Hope this helps!
Both might help:
http://ginzametrics.com/deploy-rails-app-to-ec2-with-rubber.html
Hosting rails on ec2
Rubystack allows you to have the same Rails environment for development on Windows and for deployment on Linux. We also have EC2 images (scroll to the bottom) and it is completely free, so you may want to give it a try.
Also, this may not work for you, but depending on your requirements, you may want to go for a PaaS solution like Heroku

Best Linux Distro for Ruby on Rails?

After a bad experience trying to get even the simplest Rails application running at Lunarpages, I'm moving to Slicehost. Does anyone have an opinion as to which of their Linux distros to use for a fairly high-traffic Rails site? They offer CentOS, Debian 5, Fedora (10 to 12), Gentoo, Red Hat EL 5, and Ubuntu (8 and 9).
While we're on the subject, does anyone have any opinions as to the relative merits of Slicehost versus Amazon WS?
Thanks!
I've always been a fan of Ubuntu, it's easy to use and lots of other people are using it so there is a lot of information if you run into trouble.
I've never used Slicehost but AWS is pretty great if you're going to be bringing instances up and down often (since you only pay for what is running). If you just have one server that will be running continuously then AWS might end up costing more without giving you much benefit. It all depends on how you use it though and if the flexibility of AWS is worth the (potential) added cost in your situation.
If you are interested in systems administration. I would go with Slicehost, Linode or AWS ec2, Linode has been shown to be more performant (link) than both Slicehost and AWS.
With that said, if you aren't interested in systems administration I would go with Heroku. It is the easiest way to deploy and management is minimal. You do have to be aware that Heroku is limited on some 3rd party services you would install on your own, but but they do have some packages included that you can enable for sending email etc. You are also limited on file size and they recommend you store your assets on AWS s3.
In terms of overhead Linode is less than AWS ec2, because AWS ec2 is really for high availability, Heroku is the least as mentioned above. AWS will cost you more than Slicehost or Linode and I think if your site is small more than Heroku too.
You will need decent Linux chops to get going on AWS, Slicehost, and Linode. Heroku will keep you away from most of this but also limit you if you need something really custom. For distro choice I would say Ubuntu hands down if you are new.
I've run RoR on Ubuntu 8.04 LTS on Amazon (Approx 3-4 years worth of uptime across a few servers for a couple of sites) and Slicehost (Approx 8 months). I've had zero complaints/niggles/problems with the linux distro or the hosts themselves. I'd just grab whatever linux distro you're most comfortable with, I build pretty much everything from source for RoR in production anyway:
Download gem
Build Ruby EE from source
Install passenger with nginx from source
etc. etc.
As to the merits of your two options, I've always used Amazon for work/business and slicehost for smaller stuff. This is pretty subjective and I really can't fault either, but for work/important stuff I'd still lean towards Amazon. It's not a strong leaning, but the flexibility of turning on/off instances at will, plus S3 would have me go that way again.
I'm using slicehost and running Ubuntu intrepid with passenger/rails.
My choice was mostly based on there being a lot of rails related documentation for that distro. Which has definitely made it easier.
http://articles.slicehost.com/ubuntu-intrepid
In terms of dedicated rails hosts, don't forget to check out heroku. They use a completely git-based system to deploy your app (which can be written against any of the major Ruby frameworks), and you only get charged for the database and CPU-hours that you actually use.
I also have heard good things about EngineYard.
Ubuntu is likely the most popular OS for Rails, probably because of Ubuntu being a very popular Linux distro. It's a great OS that will do anything and everything you need it to.
Having said that, it's not necessarily the only distro that works well with Rails. CentOS, for instance, is an excellent choice as well.
I would also second other people's recommendations of Heroku, and EngineYard as well. For VPS, I would probably rather pick Linode over Slicehost.
I'm partial to Ubuntu, as once you get your apt-get all updated and squared away, installation is quite quick and painless. Though, I'm sure this is said for any distro that makes good use of apt-get.
I second (or whatever sequence this shows up as) the calls for Heroku and Linode.
As for Amazon, I use the S3, and RDS if I can. The RDS not as much, but I'm moving some stuff there. But paperclip with the S3 is pretty great.
I use Centos for development and production, not problem with that, I think you need check some specific needed points in your app and only important stuff.
A GNU/Linux distribution with required points (or maybe that allow to put in) is all that your need, for example begin from a kernel.

Resources