Installing: Deployment Instructions

Deploying Webiva

These instructions are for a clean Debian Lenny system, but deploying on Ubuntu or any other apt based system should be pretty similar. If you have any instructions for other OSes/distributions please drop us a line.

Note: backports must be installed as a repository in order to successfully migrate the Webiva databases. Make sure you have backports in your sources.list, otherwise run:

 echo "deb http://www.backports.org/debian lenny-backports main contrib non-free" >  \
     /etc/apt/sources.list.d/backports.list
 wget -O - http://backports.org/debian/archive.key | apt-key add -

Update the package manager:

  # apt-get update

Now install all the necessary supporting software. You’ll need git to download the software. Also, webiva needs: Ruby, MySql, RMagick, memcached, rubygems and rake to run (You’ll also probably want Apache2 instead of running via webrick) and you’ll need to compile some gems to make it work so you’ll need some dev libraries as well:

 # apt-get install mysql-server mysql-client ruby1.8 ruby1.8-dev rdoc1.8 \
   libmagick9-dev libimage-size-ruby1.8 libxslt1-dev \
   g++ gcc  libmysql-ruby1.8 irb openssl zip unzip libopenssl-ruby \
   apache2 memcached libmysqlclient15-dev build-essential \
   git-core rubygems rake sudo

Create a webiva user and group:

   # groupadd webiva
   # useradd -d /home/webiva -s /bin/bash -m -g webiva webiva
   # passwd webiva
   [ Set a password ]
   # vi /etc/sudoers
         # Allow the user webiva to restart memcached
         webiva hostname=/etc/init.d/memcached restart

   # su webiva 

On the system you are deploying from:

(replace server_name with a name for your server or set of servers, web1 for example):

   $ sudo gem install capistrano

   $ cd config/
   $ cp deploy_example.rb deployments/server_name.rb
   $ vi deployments/server_name.rb

Edit the details of deployments/server_name.rb to match the server names and repositories, then deploy:

   $ cd ..
   $ ./script/deploy server_name webiva:setup

On the server you are deploying to (as user webiva)

   $ cd /home/webiva/current
   $ ./script/quick_install.rb
   [ Follow the prompts ]

Starling Install

We need to install the starling gem separately (daemons needs to come along for the ride as well)

 sudo gem install starling daemons

Now make sure you have gems in your path, try:

 which starling

If that doesn’t return anything, you probably need to add Rubygems bin directory to your path:

 echo "# Ruby Gems Path" >> ~/.bashrc; echo 'PATH=$PATH:/var/lib/gems/1.8/bin' >> ~/.bashrc
 . ~/.bashrc

Now start up the background process:

 cd /home/webiva/current
 ./script/background.rb start

Passenger Install

Now lets get passenger installed:

 sudo sh -c 'echo "deb http://debian.tryphon.org stable main contrib" > /etc/apt/sources.list.d/tryphon.list'
 sudo sh -c 'wget -q -O - http://debian.tryphon.org/release.asc | sudo apt-key add -'

 sudo apt-get update
 sudo apt-get -t lenny-backports install libapache2-mod-passenger librack-ruby     

Now add in a virtual host Webiva:

Note: the recommended installation is to replace the default host /etc/apache2/sites-available/default all requests will automatically get routed to Webiva - but please only do this if you don’t need anything on your virtual host - passenger makes it easy to set up:

 <VirtualHost *:80>
   ServerName mywebiva.com
   ServerAlias www.mywebiva.com
   DocumentRoot /home/webiva/current/public

   # set site to run as a the webiva user
   PassengerDefaultUser webiva

   # We don't want any user uploaded scripts to be executed in the public directory
   # This should be the public/system directory of your webiva install
   <Directory "/home/webiva/current/public/system">
         Options FollowSymLinks
         AllowOverride Limit
         Order allow,deny
         Allow from all
         <IfModule mod_php5.c>
          php_admin_flag engine off
        </IfModule>
        AddType text/plain .html .htm .shtml .php .php3 .phtml .phtm .pl
   </Directory>
 </VirtualHost>

now restart apache and you should be ready to serve some pages.

Log rotation

One last thing that’s worth doing is making sure you log files (there’s a number of them) rotate through and don’t eat up all your disk space. This is pretty easy to do, just make sure you have logrotate installed (should already be there)

  $ sudo apt-get install logrotate

Then create the following file called /etc/logrotate.d/webiva:

  # Rotate Rails logs:
  /home/webiva/current/log/*.log {
    daily
    missingok
    rotate 14
    compress
    delaycompress
    notifempty
    copytruncate
    create 0666 webiva webiva
  }

This will set up to rotate through your logs on a daily basis, keeping 14 days of logs and archiving anything older than 1 day.