Skip to content
This repository has been archived by the owner on Dec 12, 2021. It is now read-only.

Deployment

ryanb edited this page Dec 10, 2010 · 6 revisions

Server Setup

First follow the Railscasts Server Setup

Beanstalkd, GNU Go and God

sudo aptitude install beanstalkd gnugo
sudo vim /etc/default/beanstalkd # uncomment start line
sudo /etc/init.d/beanstalkd start
sudo iptables -A INPUT -j DROP -p tcp --destination-port 11300 -i eth0
sudo gem install god
sudo ln -s /usr/games/gnugo /usr/bin # easy way to make it available everywhere

Initial Deploy

The deploy.rb file is already setup, so you can just start deploying without running capify. Of course you'll need to configure deploy.rb to point to your server with proper settings. Run these commands to perform your first deploy.

On Local

cap deploy:setup

On Server

vim /var/apps/govsgo/shared/config/private.yml
vim /var/apps/govsgo/shared/config/database.yml
mysqladmin create govsgo_production -u root -p
god -c /var/apps/govsgo/current/config/god.rb

On Local

#
cap deploy:cold

Apache Virtual Host

Create the virtual host file in /etc/apache2/sites-available/govsgo. It should contain something like this.

<VirtualHost *:80>
  ServerName govsgo.com
  DocumentRoot /var/apps/govsgo/current/public
  <Directory "/var/apps/govsgo/current/public">
    Options FollowSymLinks
    AllowOverride all
    Options -MultiViews
  </Directory>
  # Redirect all requests to govsgo.com domain
  RewriteEngine On
  RewriteCond %{HTTP_HOST} !^govsgo\.com$ [NC]
  RewriteRule ^(.*)$ http://govsgo.com$1 [R=301,L]
</VirtualHost>

Now add the rewrite module, enable that host, disable the default, and then reload apache.

sudo a2enmod rewrite
sudo a2dissite default
sudo a2ensite govsgo
sudo /etc/init.d/apache2 reload

Now try going to your domain and you should see your rails app! If there are problems, try tailing the apache log.

sudo tail /var/log/apache2/error.log

Future Deployments

When you make a change, future deployments are really easy. Once you have commited the change and pushed to the git repository, just run cap deploy or cap deploy:migrations if you've changed your migrations.