How To Deploy on Dreamhost
I have just installed radiant in my dreamhost setup, and I also saw that this page empty. So this is the best moment to write all the steps down while my memory is still fresh! This document is mostly a compendium of several sources, I will try to cite when possible.
Having Radiant installed in Dreamhost requires to follow several steps, covering activation of FastCGI support, custom installation of gems, creating the MySQL databases, setting up the environment, and certain customizations. I now will describe them in detail.
Enabling FastCGI
Go to your Dreamhost Control Panel, in Domains → Manage Domains, select the domain that is going to host the Radiant installation and click on “Edit” in the WebHosting column. Choose it, and then make sure ‘FastCGI Support’ is enabled.
If you want a step by step with screenshots, visit the entry made by William in RailsHosting, Deploying a Rails App with DreamHost.
Custom Installation of gems
Radiant is not included in the standard installation on Dreamhost, so we need to add the required gems. For this, you have to setup a custom gems repository in your local directory. The instructions are listed in the Dreamhost Wiki, in this link. I will summarize them here to make it more comfortable for all.
1. Log in into a shell, for the user who is hosting the domain where you want to set Radiant.
2. Create the ’.gems’ directory, setup the environment variables, and load the new setup. To do this, add the following lines to ’.bash_profile’, and then update the enviroment runningsource .bash_profile
export GEM_HOME="$HOME/.gems"
export GEM_PATH="$GEM_HOME:/usr/lib/ruby/gems/1.8"
export PATH="$HOME/.gems/bin:$PATH"
3. Edit or create the ’.gemrc’ file, and add the following (replace username appropiately)
gemhome: /home/yourname/.gems
gempath:
- /home/yourname/.gems
- /usr/lib/ruby/gems/1.8
Creating the Database
Radiant will need one database, and I will show here how to create a MySQL database to use with Radiant. Go to the Dreamhost Control Panel, under Goodies → Manage MySQL. Follow the on-screen instructions to create a new database. Note that you need a separate hostname (you can create one in the same page). Take note of the hostname, database name, username and password, as they will be needed in the Radiant configuration.
Install and Setup Radiant
So we are finally here! Go to the Shell window, and follow the standard Radiant installation instructions. Of course, always refer to the latest installation instructions in Installation. Note that path/to/project is not neccessarily the actual web path (actually, that is not recommended). I suggest you create something like ‘radiantcms’ in you home directory.
% gem install --include-dependencies radiant
% radiant --database mysql path/to/project
Then, configure the database. Modify the config/database.yml to point to your MySQL database, using the parameters you copied earlier. Set it as the production database.
Finally, initialize Radiant:
% rake production db:bootstrap
Modifications needed for Dreamhost
In order for everything to work properly, you need to change some directory permissions, modify some scripts, and finally make a link to make your Radiant installation available to the public.
Go to
chmod -R 755 public
Check the public/.htaccess file, if it is set up properly. Modify the RewriteRule to point to dispatch.fcgi instead of dispatch.cgi.
public/dispatch.fcgi file, and add the following before the last line ( I placed it just after the initial comments ):
ENV['RAILS_ENV'] = 'production'
ENV["GEM_HOME"]="/home/gmarcus/.gems"
ENV["GEM_PATH"]="/usr/lib/ruby/gems/1.8:/home/gmarcus/.gems"
Ensure the selected environment is production in the config/environment.rb file. Uncomment the line:
ENV['RAILS_ENV'] ||= 'production'
Finally, create a link in your host to point to your radiant installation (modify according to your setup):
% ln -s ~/radiantcms/public ~/hostname/radiant
or if you prefer to have it as a subdomain:
% ln -s ~/radiantcms/public ~/subdomain.hostname
That’s it, Enjoy!
Check the References for more information and for special cases.
References
Deploying a Rails App with DreamHost
Dreamhost Wiki, Talk on Ruby on Rails
