Setting up a mod_rails box on SliceHost.com

mod_raills is easily 1,000 times easier to setup then the traditional stacks. For slice host the tutorials are pretty good but, missing a few things. Here what I had to do to get it up and running. Thanks to Jame H for some help on this late Saturday night.

Process for setting up a mod_rails box on http://slicehost.com

Tutorials:

Process:

  1. create a Ubuntu Hardy slice
  2. ssh in
  3. sudo apt-get update
  4. sudo apt-get install build-essential
  5. follow the apache tutorial (skip php steps)
  6. follow the rails tutorial but tack on “–no-rdoc –no-ri” to any gem install – to save space and time
  7. follow the mod_rails tutorial
  8. follow the rails app tutorial except:
    • instead of creating a rails app just do a svn co of whatever you’ve been working on
    • add this to the bottom of /etc/apaches/apache2.conf (change the IP obviously)
      ServerName 209.20.83.50

      LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.0.5/ext/apache2/mod_passenger.so
      PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.0.5
      PassengerRuby /usr/bin/ruby1.8

      NameVirtualHost *:80

      <IfModule mod_ssl.c>
      NameVirtualHost *:443
      </IfModule>

    • your sites-available file should look something like this

      <VirtualHost *:80>

      ServerName 209.20.83.50

      DocumentRoot /home/nietzche/public_html/pas/public

      </VirtualHost>

    • reload apache: sudo /etc/init.d/apache2 reload
    • restart mod_rails: touch /home/demo/public_html/testapp/tmp/restart.txt

On the slice you’re ssh’d into create update.sh and put this in it (change paths, etc. as needed):

cd ~/pas

svn up

cd ..

touch /home/nietzche/public_html/pas/tmp/restart.txt

Do a chmod 755 on update.sh

In your rails app you can create something like this to deploy

  1. create file script/deploy
  2. put this in it

    #!/usr/bin/env ruby

    %x[ssh root@209.20.83.50 ./update.sh]
  3. chmod 755 script/deploy

You just need to install mysql at this point:

sudo apt-get install mysql-server

Then set up the DB

mysql -u root -p
> create database mysite_production;
>\q

You database.yml for production will look like this:
production:
adapter: mysql
database: mysite_production
username: root
password: somepassword
socket: /var/run/mysqld/mysqld.sock

Some useful extras…

  • sudo apt-get install slocate – gets you the locate command