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 Jul 29, 2011 · 11 revisions

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/railscasts/shared/config/app_config.yml
vim /var/apps/railscasts/shared/config/database.yml
mysqladmin create railscasts_production -u root -p

On Local

#
cap deploy:cold

Apache Virtual Host

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

<VirtualHost *:80>
  ServerName railscasts.com
  ServerAlias *.railscasts.com
  DocumentRoot /var/apps/railscasts/current/public
  <Directory "/var/apps/railscasts/current/public">
    Options FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
  </Directory>
  # Redirect all requests to railscasts.com domain
  RewriteEngine On
  RewriteCond %{HTTP_HOST} !^railscasts\.com$ [NC]
  RewriteRule ^(.*)$ http://railscasts.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 railscasts
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.

Clone this wiki locally