I have been using Rackspace Cloud for several months and it is the most advanced web hosting I have ever seen by a long shot. Rackspace has always had great customer service, but I always thought the pricing was ridiculous compared to similar options. Not anymore.. with the Cloud you can get a cheap, flexible and scalable solution (I’m still keeping an eye on reliability.. time will tell). Currently I have 9 servers running on the cloud, but I am still waiting to move my flagship site to the cloud.. reliability and performance seem great so far, but I want to give it a few more months before I commit my highest traffic site to it. Its pretty easy to get a Rails stack running on the cloud using a simple shell script. Here is what I am currently using. Note that some of the versions may be outdated when you read this article, so you may need to update the script. Once you have this server loaded, you can create a backup and then create more servers based on that backup. You can literally have a working dedicated Rails server in less than 5 minutes. I am using a CentOS 5.4 server on the cloud
Server setup shell script: setup.sh
# SETUP.SH #
##############
#————————————————————————————————————-
# INSTALL SOFTWARE AND DEPENDENCIES WITH YUM
#————————————————————————————————————-
rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm
yum -y install mysql mysql-server mysql-devel gcc make zlib zlib-devel openssl openssl-devel git expect pcre pcre-devel readline-devel libxml2-devel libxslt-devel
#————————————————————————————————————-
# CREATE A DIRECTORY FOR DOWNLOADED FILES AND INSTALL RUBY
#————————————————————————————————————-
mkdir /home/Downloads
cd /home/Downloads
wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p174.tar.gz
tar -xvf ruby-1.8.7-p174.tar.gz
cd ruby-1.8.7-p174
./configure
make
make install
#———————————————————
# INSTALL RUBYGEMS
#———————————————————
cd ..
wget http://rubyforge.org/frs/download.php/60718/rubygems-1.3.5.tgz
tar -xvf rubygems-1.3.5.tgz
cd rubygems-1.3.5
ruby setup.rb
cd /
#————————————————————————————————————-
# INSTALL GEMS – YOU WILL NEED RAILS, MONGREL AND PROBABLY MYSQL.
# THE OTHERS ARE JUST SOME COMMON ONES I USE.
#————————————————————————————————————-
gem install –no-rdoc –no-ri rails -v=2.3.2
gem install –no-rdoc –no-ri mime-types
gem install –no-rdoc –no-ri mysql — –with-mysql-lib=/usr/lib64/mysql
gem install –no-rdoc –no-ri fastercsv
gem install –no-rdoc –no-ri mongrel mongrel_cluster
gem install –no-rdoc –no-ri json
gem install –no-rdoc –no-ri mechanize
#————————————————————————————————————-
# CHANGE MYSQL TO STARTUP SCRIPT AND START SERVER
#————————————————————————————————————-
mv /etc/rc3.d/K36mysqld /etc/rc3.d/S36mysqld
/etc/init.d/mysqld start
#————————————————————————————————————-
# INSTALL NGINX WEB SERVER & copy a working config file (you create this) to the config dir
#————————————————————————————————————-
wget http://sysoev.ru/nginx/nginx-0.7.64.tar.gz
tar -xvf nginx-0.7.64.tar.gz
cd nginx-0.7.64
./configure –sbin-path=/sbin/nginx –conf-path=/usr/local/nginx/nginx.conf –pid-path=/usr/local/nginx/nginx.pid –with-http_ssl_module –with-md5=auto/lib/md5 –with-sha1=auto/lib/sha1
make
make install
# THIS IS A DEFAULT NGINX CONFIG THAT I UPLOAD TO THE SERVER. COPY NGINX CONFIG TO THE APPROPRIATE DIR & RESTART
cp /root/nginx.conf /usr/local/nginx/nginx.conf
/sbin/nginx
#————————————————————————————————————-
# OPEN UP SECURITY FOR MONGREL
#————————————————————————————————————-
echo 1 >/selinux/enforce
/usr/sbin/setsebool -P httpd_can_network_connect=1
#————————————————————————————————————-
# OPTIONAL – SECURITY – THIS IS A DEFAULT IPTABLES SCRIPT I UPLOAD TO THE SERVER. COPY IPTABLES SCRIPT OVER
#————————————————————————————————————-
cp /root/iptables_config /etc/sysconfig/iptables
/etc/init.d/iptables restart
#*******************************************************************************************************
# NOTE: THE REST OF THIS SCRIPT IS USED TO AUTOMATE PULLING YOUR APP CODE FROM GITHUB,
# RAKING THE DB, AND ADDING STARTUP SCRIPTS FOR MONGREL, AND STARTING MONGREL INSIDE
# YOUR RAILS APP DIR. IF YOU ARE USING CAPISTRANO, SOME OF THIS IS PROBABLY NOT NECCESSARY, BUT I
# HAVE BEEN TOO LAZY TO LEARN CAP.. THIS METHOD WORKS FINE FOR WHAT I DO
#*******************************************************************************************************
#————————————————————————————————————-
# OPTIONAL – CREATE RAILS DIR.. I ALWAYS USE THIS DIRECTORY.. MODIFY TO YOUR TASTE-> /RAILS_APPS
#————————————————————————————————————-
mkdir rails_apps
#————————————————————————————————————-
# OPTIONAL – IF YOU ARE USING GITHUB, YOU WILL WANT TO COPY YOUR SSH KEYS.
# I JUST FTP THE KEY FILES TO MY SERVER ALONG WITH THE SETUP SCRIPT.
# I PLACE ALL THE FILES I AM USING IN /ROOT/
#————————————————————————————————————-
mkdir /root/.ssh
cp /root/id_rsa.pub /root/.ssh/id_rsa.pub
cp /root/id_rsa /root/.ssh/id_rsa
cp /root/known_hosts /root/.ssh/known_hosts
chmod 700 /root/.ssh/*
#————————————————————————————————————-
# OPTIONAL – GET THE APP FROM GITHUB
#————————————————————————————————————-
cd /rails_apps
git clone git@github.com:yourusername/yourproject.git
mkdir /rails_apps/yourproject/log
mkdir /rails_apps/yourproject/tmp/pids
#————————————————————————————————————-
# OPTIONAL – RAKE THE DB
#————————————————————————————————————-
cd /rails_apps/yourapp
rake db:migrate
#————————————————————————————————————-
# OPTIONAL – ADD MONGREL STARTUP SCRIPT AND PUT IN RC.LOCAL AND START MONGREL
#————————————————————————————————————-
cp /root/server_start.sh /rails_apps/server_start.sh
chmod 700 /rails_apps/*.sh
echo “/rails_apps/start_server.sh” >> /etc/rc.local
/rails_apps/server_start.sh
This worked for me last time I tried it. YMMV
