4th
Installing Spree on Site5 with Passenger
I’ll show you how I’ve installed Spree ecommerce on Site5 servers.
Install Your Own Gems
First, you need to tell RubyGems where to install your own custom gems since Spree is not preinstalled on Site5’s servers. SSH into your site then,edit or create the file ~/.gemrc with the following content (with, of course, your username in place of username):
gemhome: /home/username/ruby/gems
gempath:
- /home/username/ruby/gems
- /usr/lib/ruby/gems/1.8
Although not required for the basic installation, some of the rake tasks depend upon the shell variables $GEM_HOME and $GEM_PATH. It’s not a bad idea to add them to your .bash_profile like so:
export GEM_PATH=/home/username/ruby/gems:/usr/lib/ruby/gems/1.8
export GEM_HOME=/home/username/ruby/gems
Install the Radiant Gem and Unpack the App
Now this is very simple:
gem update rake
gem install --include-dependencies authlogic
rake gems:install chriseppstein-compass
gem install --include-dependencies spree
Unpack the application using the spree command into the directory shop (it will create the directory if it does not exist).
~/ruby/gems/bin/spree --database mysql shop
Configuration
Now, you should have the new folder shop in your current directory. Using Site5’s SiteAdmin on your domain (located at yourdomain.com/siteadmin), create the databases spreedev, spreetest, and spreelive (note that your username_ is prepended to all those table and user names). Create a new MySQL user spree, and give it access to all functions on all those databases (watch out — those checkboxes to give privileges on the MySQL user page don’t mirror your current settings. To see that, you need to go to the databases page.) Once that is all completed, edit shop/config/database.yml with those settings; the file should look something like this:
development:
adapter: mysql
database: username_spreedev
username: username_spreepassword: pword
host: localhost
test:
adapter: mysql
database: username_spreetest
username: username_spreepassword: pword
host: localhost
production:
adapter: mysql
database: username_spreelive
username: username_spreepassword: pword
host: localhost
Now edit the file radapp/config/environment.rb. You need to uncomment a line and add one more, so the following line (should be the 8th line down):
# ENV['RAILS_ENV'] ||= 'production'
becomes…
ENV['RAILS_ENV'] ||= 'production'
ENV['GEM_PATH'] = '/home/username/ruby/gems:/usr/lib/ruby/gems/1.8'
Bootstrap your Database
Okay! All of the config files are setup. Now in the radiant application folder, run the rake task to bootstrap the database. Answer the prompts to your liking.
$ cd shop/
$ rake production db:bootstrap
Setup the Symbolic Link
Just create the symlink and you’re done! From your home directory, just do this:
mv public_html public_html_bak
ln -s ~/shop/public ~/public_html
Setup Passenger
Just create the .htaccess file at shop/public/.htaccess , and edit it like this:
PassengerEnabled on
PassengerAppRoot /home/username/shop
Restart passport, the easiest way. From shop directory type :
touch tmp/restart.txt
Now point your browser to http://your.website.com/. It should be Spree!
To enter the admin page, go to http://your.website.com/admin. But we have a problem here with the https connection. So unless you have installed a ssl certificate, you will need to desactivate ssl also in production mode. To do so, you need to insert the next sentence on your production database:
INSERT INTO `username_spreelive`.`preferences` (`id`, `attribute`, `owner_id`, `owner_type`,
`group_id`, `group_type`, `value`, `created_at`, `updated_at`) VALUES ('1',
'allow_ssl_in_production', '1', 'Configuration', NULL, NULL, '0', NULL, NULL);