-
Notifications
You must be signed in to change notification settings - Fork 174
Deployment
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.
cap deploy:setup
vim /var/apps/railscasts/shared/config/app_config.yml
vim /var/apps/railscasts/shared/config/database.yml
mysqladmin create railscasts_production -u root -p
#
cap deploy:cold
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]
<LocationMatch "^/assets/.*$">
Header unset ETag
FileETag None
# RFC says only cache for 1 year
ExpiresActive On
ExpiresDefault "access plus 1 year"
</LocationMatch>
</VirtualHost>
Now add the rewrite module, enable that host, disable the default, and then reload apache.
sudo a2enmod rewrite
sudo a2enmod headers
sudo a2enmod expires
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
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.
Create the virtual host file in /etc/apache2/sites-available/railscasts-ssl
. It should contain something like this.
<VirtualHost *:443>
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>
SSLEngine on
SSLCertificateFile /etc/ssl/private/railscasts.com.crt
SSLCertificateKeyFile /etc/ssl/private/railscasts.com-private.key
SSLCertificateChainFile /etc/ssl/private/railscasts.com-intermediate.crt
<LocationMatch "^/assets/.*$">
Header unset ETag
FileETag None
# RFC says only cache for 1 year
ExpiresActive On
ExpiresDefault "access plus 1 year"
</LocationMatch>
</VirtualHost>
Then run the following commands to create the SSL certificate and enable it.
sudo vim /etc/ssl/private/railscasts.com.crt # paste Certificate
sudo vim /etc/ssl/private/railscasts.com-private.key # paste Private Key
sudo vim /etc/ssl/private/railscasts.com-intermediate.crt # paste Intermediate Certificate
sudo a2enmod ssl
sudo a2ensite railscasts-ssl
sudo /etc/init.d/apache2 reload