0 How to Install RadiantCMS on Webfaction

A fellow colleague of mine wanted to know how I installed RadiantCMS on Webfaction. After installing Ruby, RubyGem and setting some paths in my home directory, installing RadiantCMS was a breeze.

When installing RadiantCMS (gem) on Webfaction you have to follow these instructions located at Webfaction’s help/support site. The instructions provided by Webfaction are prerequisites to installing RadiantCMS as gem.

Once you have completed those steps. You’re now ready to start installing some gems. To install the RadiantCMS gem you must complete a few tasks first as listed below:

From the webfaction panel …

  • Create a “Custom app (listening on port) – // note the port number
  • Edit that custom app and enable autostart.cgi (don’t think this does anything, but just to be safe)
  • Create “website” that uses whatever domain name you choose
  • Edit your newly created website and add the “Custom app” you created.

From command line via SSH

Since you installed Ruby and RubyGems into your home directory you now have the full ability to install and use your own gem packages. Now we need to install gems for RadiantCMS and Thin. If you don’t know what Thin is, its a Ruby HTTP daemon that is faster than Mongrel. More on Thin here (please realize that “sudo” is not required to install gems at webfaction and before running the following commands please create a database for your Radiant installation).

  • $ gem install --platform=RUBY radiant
  • $ gem install --platform=RUBY thin
  • $ cd $HOME/webapps/your_custom_app
  • $ radiant .
  • [Edit your database.yml file to use your newly created database]
  • $ rake db:bootstrap
  • touch autostart.cgi

Using the “--platform” option of the gem command is important as this allows you to install gems onto your Ruby and RubyGems installations. The last command creates an autostart.cgi file that is used to automatically restart your application in the event that a server is restarted or your web app goes bunkers and shuts down. Works quite well actually, but you need the proper script code to do it.


#!/usr/local/bin/python2.4
import os

# Test if the process is already running
running = False
try:
    # Try to read pid file
    pid = open('/home/username/webapps/your_radiant_app/log/thin.pid').read()
    # Check if this process is up
    lines = os.popen('ps -p %s' % pid).readlines()
    if len(lines) > 1:
        running = True
    else:
        # Delete pid file
        os.remove('/home/username/webapps/your_radiant_app/log/thin.pid')
except IOError:
    pass

print "Content-type: text/html\r\n" 
if running:
    print """<html><head><META HTTP-EQUIV="Refresh" CONTENT="2; URL=/"></head><body>
    Site is starting ...<a href="/">click here<a></body></html>""" 
else:
    print """<html><head><META HTTP-EQUIV="Refresh" CONTENT="2; URL=/"></head><body>
    Restarting site ...<a href="/">click here<a></body></html>""" 
    os.setpgid(os.getpid(), 0)
    os.system('/home/username/ruby1.8/lib/ruby/gems/1.8/bin/thin start -d -P /home/username/webapps/your_radiant_app/log/thin.pid -e production -p 3000')

The code above must be placed in the root of the radiant installation. So naturally it would be here; ”~/webapps/your_radiant_app/autostart.cgi”. Don’t forget to change the names [username] and [your_radiant_app] inside autostart.cgi to reflect your app’s directory name and username.

Pending that you did everything correctly and that my instructions were also correct. Go to the domain your custom app (listening on port) and website was mounted on and watch you app restart. (Please note that I will be editing this constantly to squeeze out any errors)