<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Kris Forbes Blog</title>
    <description>Kris Forbes - Personal blog covering experiences with tech such as Docker, Azure, OVH, Linux, Windows, etc.</description>
    <link>http://blog.krisforbes.ca/</link>
    <atom:link href="http://blog.krisforbes.ca/feed.xml" rel="self" type="application/rss+xml"/>
    <pubDate>Tue, 12 Jul 2016 14:52:50 -0400</pubDate>
    <lastBuildDate>Tue, 12 Jul 2016 14:52:50 -0400</lastBuildDate>
    <generator>Jekyll v3.2.0.pre.beta1</generator>
    
      <item>
        <title>Using Azure Traffic Manager With Your Apex/Root Domain Record is Possible With CloudFlare</title>
        <description>&lt;p&gt;&lt;img src=&quot;https://i.pstorage.space/i/WgJ5J23eY/original_tumblr_inline_o8q0btElj21ri0chs_500.jpg&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;

&lt;p&gt;I wanted to write this blog post explaining how it is possible to use &lt;a href=&quot;http://t.umblr.com/redirect?z=https%3A%2F%2Fazure.microsoft.com%2Fen-us%2Fservices%2Ftraffic-manager%2F&amp;amp;t=YmJkOTE3ZGI2NDIwNTAwMzgyNzE3NDhlZmM0ZGVkYzhlMjYzOGQwMSxpUVp5QjBGUw%3D%3D&quot;&gt;Azure Traffic Manager &lt;/a&gt;with your apex domain name. I’ve googled solutions for this and haven’t found any until now. &lt;/p&gt;

&lt;p&gt;Azure Traffic Manager currently does not support Apex or “Root” “@” domain names. Meaning, you cannot use it with &lt;a href=&quot;http://t.umblr.com/redirect?z=https%3A%2F%2Fexample.com&amp;amp;t=YWUyYWEyOTQzOGRlYTMzMWEyZWEzOGY5YmJkY2ViMGE5MWNhYTNmMCxpUVp5QjBGUw%3D%3D&quot;&gt;https://example.com&lt;/a&gt;. This is because Traffic Manager provides you with a CNAME “wwwexamplecom.trafficmanager.net” and &lt;a href=&quot;http://t.umblr.com/redirect?z=http%3A%2F%2Fwww.ietf.org%2Frfc%2Frfc1035.txt&amp;amp;t=MzUwNjUwOWU1NjkzOGI2NWM4ZjY0NjkyNGY4Njg4ZDlmYWFlMWUwYSxpUVp5QjBGUw%3D%3D&quot;&gt;DNS RFCs&lt;/a&gt; forbid the use of a CNAME record as the domain apex record.&lt;/p&gt;

&lt;p&gt;This is where Cloudflare comes in.&lt;/p&gt;

&lt;p&gt;Cloudflare supports a feature called &lt;a href=&quot;http://t.umblr.com/redirect?z=https%3A%2F%2Fblog.cloudflare.com%2Fintroducing-cname-flattening-rfc-compliant-cnames-at-a-domains-root%2F&amp;amp;t=MjA5YWZiODkwMDE5YzAzY2QyMzgyOWI1YTNmMmMxMmNkYjhkNDFkNyxpUVp5QjBGUw%3D%3D&quot;&gt;CNAME Flattening&lt;/a&gt; that they have developed in-house for their DNS servers. You can use Cloudflare to host your domain for free and you aren’t required to use their caching/proxying service.&lt;/p&gt;

&lt;p&gt;After creating a Cloudflare account and adding your domain, you can use a CNAME record as your domain apex “@”. Behind the scenes, Cloudflare is translating “wwwexamplecom.trafficmanager.net” to an IP and returning the IP when “example.com” is queried.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://i.pstorage.space/i/xY1Z1vyaW/original_tumblr_inline_o8pzv0DwmT1ri0chs_500.jpg&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;

&lt;p&gt;I hope this helps anyone looking to use Azure Traffic Manager.&lt;/p&gt;
</description>
        <pubDate>Mon, 13 Jun 2016 13:15:28 -0400</pubDate>
        <link>http://blog.krisforbes.ca/2016/06/13/using-azure-traffic-manager-with-your-apexroot.html</link>
        <guid isPermaLink="true">http://blog.krisforbes.ca/2016/06/13/using-azure-traffic-manager-with-your-apexroot.html</guid>
        
        
      </item>
    
      <item>
        <title>Docker and why I’m using it</title>
        <description>&lt;p&gt;&lt;img src=&quot;https://i.pstorage.space/i/g0zYzybap/original_tumblr_inline_o2yxw5w3mO1ri0chs_400.png&quot; alt=&quot;logo&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Docker has been a hot topic for the past year or so. It started to be used heavily in Dev environments and has since moved on to be used in production by companies like &lt;a href=&quot;http://t.umblr.com/redirect?z=http%3A%2F%2Fkubernetes.io%2F&amp;amp;t=Njg3NmU0NDVmMDJlNWIxOGNmY2U5YTliYTZlZWQwMjFjYjhmMjE2NCxEUm9RUDJadg%3D%3D&quot;&gt;Google&lt;/a&gt;, &lt;a href=&quot;http://t.umblr.com/redirect?z=https%3A%2F%2Fengineering.shopify.com%2F17489060-docker-at-shopify-how-we-built-containers-that-power-over-100-000-online-shops&amp;amp;t=NmFmY2YyNzY4MGIyMDA0ZWRlYzM0NDVlMTBmNGY2YTQ0MTgyZGVlYSxEUm9RUDJadg%3D%3D&quot;&gt;Shopify&lt;/a&gt;, and &lt;a href=&quot;http://t.umblr.com/redirect?z=https%3A%2F%2Fengineering.riotgames.com%2Fnews%2Fthinking-inside-container&amp;amp;t=N2QyNTQ3YjQ3NTAyZmQxNTIxZDFiMGYzOWEwZjcyZmYzMjYwZmM4NixEUm9RUDJadg%3D%3D&quot;&gt;Riot games&lt;/a&gt;. For the longest time, I’ve continued to do things the way I always do - fancy one liners, collections of bash scripts, things that generally break after a couple months.&lt;/p&gt;

&lt;p&gt;Recently, I setup a mumble server and didn’t document anything. It was a dead simple setup process, so why bother documenting how the server is setup? What happens if I want to lifecycle the server or decide to change the OS and I need to move the mumble service elsewhere?&lt;/p&gt;

&lt;p&gt;I am doing exactly that in a couple weeks - I’m upgrading my server to a new Xeon E5 and getting rid of the old. Docker, by design, is forcing me to ensure all my configurations are in one place and all the services are documented and portable.&lt;/p&gt;

&lt;p&gt;I’ll be posting some of my experiences with Docker in production shortly. Right now, I’m moving the following in my home lab to Docker containers to learn:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;PostgreSQL&lt;/li&gt;
  &lt;li&gt;Phusion Passenger (Ruby App server)&lt;/li&gt;
  &lt;li&gt;NGINX cache static asset host&lt;/li&gt;
  &lt;li&gt;Plex&lt;/li&gt;
  &lt;li&gt;Sonarr&lt;/li&gt;
  &lt;li&gt;Aria2 Downloader&lt;/li&gt;
  &lt;li&gt;rTorrent&lt;/li&gt;
  &lt;li&gt;Mumble&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&amp;amp; more&lt;/p&gt;

&lt;p&gt;While Docker is suitable for large-scale deployments, there’s nothing stopping you from using it in your home lab or in a small production environment.&lt;/p&gt;

&lt;p&gt;I’m interested to hear of your own experiences using Docker in small environments.&lt;/p&gt;
</description>
        <pubDate>Mon, 22 Feb 2016 16:48:12 -0500</pubDate>
        <link>http://blog.krisforbes.ca/2016/02/22/docker-and-why-im-using-it.html</link>
        <guid isPermaLink="true">http://blog.krisforbes.ca/2016/02/22/docker-and-why-im-using-it.html</guid>
        
        
      </item>
    
      <item>
        <title>Deploying with Inploy - An alternative to Capistrano</title>
        <description>&lt;p&gt;Inploy is similar to Capistrano but easier - it has better defaults and it is more forgiving when you don’t know what you’re doing (me).&lt;/p&gt;

&lt;h3 id=&quot;inploy-on-your-development-machine&quot;&gt;Inploy on your development machine:&lt;/h3&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;add to Gemfile: gem ‘inploy’
bundle install —without production
Create deploy.rb under your app’s config directory. The basic config/deploy.rb file:
application &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; “test”repository &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; ‘git@git.assembla.com:my-apps-repo.git’hosts &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;‘zer1’]path &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; ‘/home/deploy’
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h3 id=&quot;notes-on-deployrb&quot;&gt;Notes on deploy.rb:&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;default user is ‘deploy’&lt;/li&gt;
  &lt;li&gt;deploys to #{path}/#{application}&lt;/li&gt;
  &lt;li&gt;Inploy’s hosts will look to your development machine’s .ssh/config (so add your production server)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;inploy-commands&quot;&gt;Inploy commands&lt;/h3&gt;
&lt;p&gt;#### Pull the app from repo, bundle install, create database, migrate:
&lt;code class=&quot;highlighter-rouge&quot;&gt;
bundle exec rake inploy:remote:setup
&lt;/code&gt;&lt;/p&gt;

&lt;h4 id=&quot;once-youre-setup-you-can-update-your-app-and-repo&quot;&gt;Once you’re setup, you can update your app and repo:&lt;/h4&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bundle exec rake inploy:remote:update
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;That’s it! You can learn more about Inploy on Github.&lt;/p&gt;
</description>
        <pubDate>Mon, 25 Jul 2011 20:26:00 -0400</pubDate>
        <link>http://blog.krisforbes.ca/2011/07/25/deploying-with-inploy-an-alternative-to-capis.html</link>
        <guid isPermaLink="true">http://blog.krisforbes.ca/2011/07/25/deploying-with-inploy-an-alternative-to-capis.html</guid>
        
        <category>Ruby on Rails</category>
        
        
      </item>
    
      <item>
        <title>Rails on Ubuntu 10.04: Passenger, Nginx, MySQL, Varnish</title>
        <description>&lt;p&gt;I setup a new VPS this weekend and decided to share my notes.
My notes are from being logged in as root. If you’re logged in as another user, you’ll be typing sudo a lot. :)&lt;/p&gt;

&lt;h3 id=&quot;configure-your-locale&quot;&gt;Configure your locale &lt;/h3&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;locale -a
locale-gen en_US.UTF-8
update-locale &lt;span class=&quot;nv&quot;&gt;LANG&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;en_US.UTF-8
update-locale &lt;span class=&quot;nv&quot;&gt;LANGUAGE&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;en_US.UTF-8
&lt;span class=&quot;nb&quot;&gt;exit
&lt;/span&gt;ssh zer1   &lt;span class=&quot;c&quot;&gt;#zer1 is my VPS added to ~/.ssh/config &lt;/span&gt;
locale -a   &lt;span class=&quot;c&quot;&gt;#should have en_US.UTF-8 listed &lt;/span&gt;
update-locale   &lt;span class=&quot;c&quot;&gt;#errors? &lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# Set your time zonedpkg-reconfigure tzdata &lt;/span&gt;
ntpdate ntp.ubuntu.com
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h3 id=&quot;update-ubuntu&quot;&gt;Update Ubuntu&lt;/h3&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;apt-get update &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; apt-get upgrade
Install dependenciesapt-get install build-essential libmagickcore-dev imagemagick libxml2-dev libxslt1-dev git-core libapr1-dev libssl-dev libmysqlclient15-dev libcurl4-openssl-dev curl libncurses5-dev libreadline5-dev libopenssl-ruby1.9
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h3 id=&quot;install-mysql&quot;&gt;Install MySQL&lt;/h3&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;apt-get install mysql-server libmysqlclient-dev libmysqlclient15-dev libmysql-ruby
mysql_secure_installation
Install latest Ruby from sourcewget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-p290.tar.gz
tar zxvf ruby-1.9.2-p290.tar.gz
&lt;span class=&quot;nb&quot;&gt;cd &lt;/span&gt;ruby-1.9.2-p290.tar.gz
./configure
make
make install
which ruby
gem list
gem install passenger mysql bundler
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h3 id=&quot;set-default-environment-for-rails&quot;&gt;Set default environment for Rails&lt;/h3&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;export RAILS_ENV=production&quot;&lt;/span&gt; &amp;gt;&amp;gt; /etc/environment
Install Nginx and Passengerpassenger-install-nginx-module
curl -L https://raw.github.com/jnstq/rails-nginx-passenger-ubuntu/master/nginx/nginx &amp;gt; /etc/init.d/nginx
chmod +x /etc/init.d/nginx
update-rc.d nginx defaults
service nginx start
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h3 id=&quot;configure-nginx&quot;&gt;Configure Nginx&lt;/h3&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;mkdir /opt/nginx/conf/sites-enabled
nano /opt/nginx/conf/nginx.conf
add this within the http &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt; block:
change default listen port to 8080
include /opt/nginx/conf/sites-enabled/&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;;
nano /opt/nginx/conf/sites-enabled/test
&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;note port 8080 &lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;Varnish
server &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;    listen 8080;    server_name mywebsite.com;    root /home/deploy/test/public;    passenger_enabled on;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
service nginx restart
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h3 id=&quot;add-deploy-user&quot;&gt;Add deploy user&lt;/h3&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;adduser deploy
su deploy    &lt;span class=&quot;c&quot;&gt;#switches to deploy&lt;/span&gt;
ssh-keygen -t rsa -C “deploy@myserver”
cat ~/.ssh/id_rsa.pub
copy the output into your favorite Git hosting as an allowed key &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;Assembla, Github, etc&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
on your development machine:
cat ~/.ssh/id_rsa.pub
on the server as deploy user:
nano ~/.ssh/authorized_keys
paste &lt;span class=&quot;k&quot;&gt;in &lt;/span&gt;your development machine’s public key
git clone git@git.assembla.com:myapp.git      #lets you add host as known_host
rm -rf myapp         
Create a MySQL user and databasemysql -u root -p
create database myapp_prod;
create user ‘mydbuser’@’localhost’ identified by ‘secret’;
grant all privileges on myapp_prod.&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt; to ‘mydbuser’@’localhost’;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h3 id=&quot;install-varnish-http-cache&quot;&gt;Install Varnish HTTP cache&lt;/h3&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;apt-get install subversion autotools-dev automake1.9 libtool autoconf libncurses-dev xsltproc quilt debhelper
svn co http://varnish-cache.org/svn/tags/varnish-2.0.5
&lt;span class=&quot;nb&quot;&gt;cd &lt;/span&gt;varnish-2.0.5/varnish-cache
dpkg-buildpackage
&lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; ..
dpkg -i libvarnish1_2.0.6-2_i386.deb
dpkg -i varnish_2.0.6-2_i386.deb
service varnish start
Configure Varnishnano /etc/varnish/default.vcl
Leave this at defaults, but now you know where it is :&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
nano /etc/default/varnish
Comment out DAEMON_OPTS use the following instead:
&lt;span class=&quot;nv&quot;&gt;DAEMON_OPTS&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;”-a :80 -f /etc/varnish/default.vcl -s file,/var/lib/varnish/&lt;span class=&quot;nv&quot;&gt;$INSTANCE&lt;/span&gt;/varnish_storage.bin,1G”
service varnish restart
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
</description>
        <pubDate>Mon, 25 Jul 2011 19:59:00 -0400</pubDate>
        <link>http://blog.krisforbes.ca/2011/07/25/rails-on-ubuntu-1004-passenger-nginx-mysql-va.html</link>
        <guid isPermaLink="true">http://blog.krisforbes.ca/2011/07/25/rails-on-ubuntu-1004-passenger-nginx-mysql-va.html</guid>
        
        <category>Ruby on Rails</category>
        
        
      </item>
    
      <item>
        <title>Migrating to Google Apps from cPanel</title>
        <description>&lt;p&gt;So I just had a nightmare of a time bouncing from cPanel providers. I figured there had to be something better.
I decided to run a trial of Google Apps Standard for two weeks and consider if it would be viable to move businesses using cPanel to Google Apps Standard accounts.&lt;/p&gt;

&lt;p&gt;The trial went well. I used Google Apps for two weeks and had no service disruptions and migration was painless. After the trial, I moved my family’s small business &lt;a href=&quot;http://midhurstroofing.ca&quot;&gt;http://midhurstroofing.ca&lt;/a&gt; to Google Apps. 
Here’s some problems I encountered during the migration and how I fixed them:&lt;/p&gt;

&lt;h1 id=&quot;microsoft-outlook--pop3--google-apps-migration-tool-lost-timestamps&quot;&gt;Microsoft Outlook + POP3 + Google Apps Migration Tool Lost TimeStamps&lt;/h1&gt;
&lt;p&gt;I finished my first user and hooked up IMAP. All the dates for messages were wrong. The dates shown after the migration were all &amp;lt; 1 day and they should have gone all the way back to 2009.&lt;/p&gt;

&lt;p&gt;Apparently the problem is related to Outlook displaying the DateTime from a part of the message header that is updated during the migration. I found two solutions to this:
The first, was to use an email client other than Outlook. Literally any other client has no issues with the Google Apps Migration Tool - Mozilla Thunderbird, Apple Mail, mobile clients, etc.&lt;/p&gt;

&lt;p&gt;The second, for those that have users that are too used to Outlook to switch cold turkey, is to change Outlooks view to sort and display the Sent DateTime of the message header instead of Received(default). To accomplish this:
- click the Sort by Date at the top of your message list.
- click custom
- change Sort to Sent&lt;/p&gt;

&lt;p&gt;This view change is on a per-folder level, meaning you’ll have to do it on a couple folders. Depending on your user, usually Inbox and Sent is a must.
All future emails (not migrated) will have the proper information in the headers for Outlook to handle this under default settings. Hopefully Microsoft improves IMAP to handle this like other email clients do.&lt;/p&gt;

&lt;h1 id=&quot;users-were-used-to-an-inbox-under-personal-now-the-imap-mailbox-is-a-separate-item-in-the-navigation-pane&quot;&gt;Users were used to an Inbox under Personal, now the IMAP mailbox is a separate item in the Navigation Pane&lt;/h1&gt;
&lt;p&gt;For this challenge, I made sure unused PST/Archives listed in the navigation pane were removed (AutoArchive) since users get boat loads of storage with Google Apps, there’s no need to retain copies locally. &lt;/p&gt;

&lt;p&gt;The next thing was to either hide or delete email messages on the user’s machine. I recommend hiding them in a subfolder until you’re confident the move to Google Apps is complete.
Next is to make sure when Outlook is started, it shows their IMAP inbox instead of their old Inbox. To do this:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Tools &amp;gt; Options &amp;gt; Misc tab&lt;/li&gt;
  &lt;li&gt;Advanced Options&lt;/li&gt;
  &lt;li&gt;Change which folder is opened when Outlook runs&lt;/li&gt;
  &lt;li&gt;Select the inbox under IMAP
After that’s done, I collapsed the whole Personal archive in the navigation pane.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This results in a Navigation pane that looks very similar to the user’s old one.&lt;/p&gt;

&lt;h1 id=&quot;sent-items-need-to-go-into-gmail&quot;&gt;Sent items need to go into GMail&lt;/h1&gt;

&lt;p&gt;Make sure their sent items are properly being placed in their GMail Sent Items and not a local folder or the copy Google Apps Migration Tool makes.&lt;/p&gt;

&lt;h1 id=&quot;i-need-to-delete-imap-folders-in-outlook-but-it-says-permission-denied&quot;&gt;I need to delete IMAP folders in Outlook, but it says “Permission Denied”&lt;/h1&gt;

&lt;p&gt;GMail only allows the deletion of IMAP folders through the web interface. For this, I suggest you login to the web interface and use Manage Labels to clean things up.
Manage Labels interface:&lt;/p&gt;

&lt;p&gt;As you can see, there’s a lot of garbage folders that one might not necessarily use that get copied in a migration.&lt;/p&gt;

&lt;p&gt;That’s all! Overall I’m pleased with the outcome and I hope users are too.&lt;/p&gt;
</description>
        <pubDate>Sun, 17 Jul 2011 23:10:00 -0400</pubDate>
        <link>http://blog.krisforbes.ca/2011/07/17/migrating-to-google-apps-standard-from-cpanel.html</link>
        <guid isPermaLink="true">http://blog.krisforbes.ca/2011/07/17/migrating-to-google-apps-standard-from-cpanel.html</guid>
        
        <category>Google Apps</category>
        
        
      </item>
    
      <item>
        <title>Rails 3 on AWS micro: CentOS Nginx Passenger</title>
        <description>&lt;p&gt;Note: This was tested on AWS using a micro instance and ami-6b608c02 which seemed to be the most barebones community CentOS i386 EBS AMI I could find. It works as a Micro instance out of the box without issues.&lt;/p&gt;

&lt;h2 id=&quot;prepare-the-server&quot;&gt;Prepare the Server&lt;/h2&gt;

&lt;h3 id=&quot;update-the-system-and-install-required-libraries&quot;&gt;Update the system and install required libraries&lt;/h3&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;yum update -y
yum groupinstall “Development Tools” -y
yum install zlib-devel wget openssl-devel pcre pcre-devel readline-devel sudo nano -y
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h3 id=&quot;configure-time-settings&quot;&gt;Configure Time Settings&lt;/h3&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;yum install tzdata system-config-date -y
yum install ntp -y
&lt;span class=&quot;c&quot;&gt;# Contact NTP server and update current time&lt;/span&gt;
ntpdate ntp.ubuntu.com
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h3 id=&quot;configure-the-hostname&quot;&gt;Configure the hostname&lt;/h3&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;hostname my.specialhost.name
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;Write loopback IP and your hostname in your /etc/hosts file:
&lt;code class=&quot;highlighter-rouge&quot;&gt;bash
nano /etc/hosts
127.0.0.1 my.specialhost.name
Write your hostname to /etc/hostname
nano /etc/hostname
my.specialhost.name
&lt;/code&gt;
## Installing the Application Stack&lt;/p&gt;

&lt;h3 id=&quot;install-mysql&quot;&gt;Install MySQL&lt;/h3&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;yum install mysql mysql-devel
Secure your MySQL install:
mysql_secure_installation
Install Ruby
Ignore ri and rdoc &lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;this server
nano ~/.gemrc
Add these two lines:
install: —no-ri —no-rdoc
update: —no-ri —no-rdoc
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h3 id=&quot;download-ruby-from-source-and-install&quot;&gt;Download Ruby from source and install:&lt;/h3&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;wget ftp://ftp.ruby-lang.org:21//pub/ruby/1.9/ruby-1.9.2-p0.tar.gz
tar xvfz ruby&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;cd &lt;/span&gt;ruby&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;
./configure &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; make &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; make install
Check that Ruby and RubyGems all were installed correctly:
ruby -v
gems -v
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h3 id=&quot;clean-up-the-ruby-source-files&quot;&gt;Clean up the Ruby source files:&lt;/h3&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; ..
rm -R ruby&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;
Install Git &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;Good idea &lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;Capistrano deployments&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
yum install gettext-devel expat-devel curl-devel zlib-devel openssl-devel
wget http://kernel.org/pub/software/scm/git/git-1.7.1.tar.gz
tar xzvf git-1.7.1.tar.gz
&lt;span class=&quot;nb&quot;&gt;cd &lt;/span&gt;git-1.7.1
make &lt;span class=&quot;nv&quot;&gt;prefix&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/usr/local all
make &lt;span class=&quot;nv&quot;&gt;prefix&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/usr/local install
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h3 id=&quot;install-rails-and-passenger-gems&quot;&gt;Install Rails and Passenger gems&lt;/h3&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;gem install rails
If you need a specific version of Rails:
gem install rails -v&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;2.3.8
gem install passenger
Install modified Nginx with Passenger built-in
passenger-install-nginx-module
Option 1
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h3 id=&quot;create-init-scripts-for-nginx&quot;&gt;Create init scripts for Nginx&lt;/h3&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;git clone git://github.com/xdite/rails-nginx-passenger-centos.git
sudo mv rails-nginx-passenger-centos/nginx/nginx /etc/init.d/nginx
sudo chown root:root /etc/init.d/nginx
Verify the script can start and stop Nginx:
sudo /etc/init.d/nginx start

  &lt;span class=&quot;k&quot;&gt;*&lt;/span&gt; Starting Nginx Server…
  …done.
sudo /etc/init.d/nginx status

  nginx found running with processes:  11511 11510
sudo /etc/init.d/nginx stop

  &lt;span class=&quot;k&quot;&gt;*&lt;/span&gt; Stopping Nginx Server…
  …done.
Add Nginx to startup:
sudo /sbin/chkconfig nginx on
Check that it starts and stops with the server by:
reboot
Install ImageMagick and RMagick &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;Optional&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
yum remove imagemagick
yum install tcl-devel libpng-devel libjpeg-devel ghostscript-devel bzip2-devel freetype-devel libtiff-devel
yum install libjpeg-devel libpng-devel glib2-devel fontconfig-devel zlib-devel libwmf-devel freetype-devel
Download the ImageMagick Source
wget ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick.tar.gz
tar xvfz ImageMagick.tar.gz
&lt;span class=&quot;nb&quot;&gt;cd &lt;/span&gt;ImageMagick-6&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;
./configure —prefix&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/usr —with-bzlib&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;yes —with-fontconfig&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;yes —with-freetype&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;yes —with-gslib&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;yes —with-gvc&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;yes —with-jpeg&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;yes —with-jp2&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;yes —with-png&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;yes —with-tiff&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;yes
make &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; make install
Install RMagick
gem install rmagick
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h2 id=&quot;create-a-deployer-user-recommended&quot;&gt;Create a ‘deployer’ user (Recommended)&lt;/h2&gt;
&lt;p&gt;### Add the user
&lt;code class=&quot;highlighter-rouge&quot;&gt;bash
useradd deployer
passwd deployer
&lt;/code&gt;&lt;/p&gt;

&lt;h3 id=&quot;give-deployer-sudo-permission&quot;&gt;Give deployer sudo permission&lt;/h3&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;nano /etc/sudoers
Add this near the bottom of the file:
deployer    &lt;span class=&quot;nv&quot;&gt;ALL&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=(&lt;/span&gt;ALL&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;     ALL
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h3 id=&quot;end-your-ssh-session&quot;&gt;End your SSH session&lt;/h3&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;exit
&lt;/span&gt;ssh deployer@my.specialhost.name
Lock the root account
sudo passwd root -l
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h2 id=&quot;test-a-rails-3-app&quot;&gt;Test a Rails 3 app&lt;/h2&gt;

&lt;h3 id=&quot;create-the-testapp&quot;&gt;Create the testapp&lt;/h3&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;rails new testapp -d mysql
&lt;span class=&quot;nb&quot;&gt;cd &lt;/span&gt;testapp
bundle install
Enter your database password &lt;span class=&quot;k&quot;&gt;in &lt;/span&gt;your database.yml real quick
nano config/database.yml
rake db:create:all
rails generate scaffold post title:string body:text
rake db:migrate
Check really quick that WeBrick can start the rails app before we involve Passenger/Nginx
rails server
Change the user Nginx runs as
sudo nano /opt/nginx/conf/nginx.conf
At the top of the config file, uncomment or change “user nobody;” to:
 user deployer;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h3 id=&quot;add-a-virtual-host-to-nginx&quot;&gt;Add a virtual host to Nginx&lt;/h3&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo nano /opt/nginx/conf/nginx.conf
Find the server &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt; block &lt;span class=&quot;k&quot;&gt;in &lt;/span&gt;the default file and remove it. Add this:

server &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    listen 80;
    &lt;span class=&quot;c&quot;&gt;# server_name www.mycook.com;&lt;/span&gt;
    root /home/deployer/testapp/public;
    passenger_enabled on;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
Restart Nginx:
 sudo /etc/init.d/nginx restart

Try accessing your testapp
In your web browser:
http://my.specialhost.name/posts
Tweaking Nginx/Passenger

Enable gzip
sudo nano /opt/nginx/conf/nginx.conf
Find the existing commented “ &lt;span class=&quot;c&quot;&gt;#gzip on; ” and remove it and replace it with the following:&lt;/span&gt;
gzip on;
gzip_buffers 16 8k;
gzip_disable “MSIE &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;1-6].”;
gzip_proxied any;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

Longer expiration tags on content served by Nginx
Place the following &lt;span class=&quot;k&quot;&gt;in &lt;/span&gt;your virtual host’s server &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt; block:

location ~&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt; .&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;ico|css|js|gif|jp?g|png&lt;span class=&quot;o&quot;&gt;)(&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\?&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;0-9]+&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;?&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
      expires max;
      &lt;span class=&quot;nb&quot;&gt;break&lt;/span&gt;;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
Reduce Passenger spin-up &lt;span class=&quot;nb&quot;&gt;time

&lt;/span&gt;Place the following &lt;span class=&quot;k&quot;&gt;in &lt;/span&gt;your virtual host’s server &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt; block:
&lt;span class=&quot;c&quot;&gt;#Passenger options&lt;/span&gt;
rails_spawn_method smart-lv2; &lt;span class=&quot;c&quot;&gt;# This can cause problems with some apps&lt;/span&gt;
rails_app_spawner_idle_time 0;
rails_framework_spawner_idle_time 0;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
</description>
        <pubDate>Sat, 11 Sep 2010 21:07:00 -0400</pubDate>
        <link>http://blog.krisforbes.ca/2010/09/11/rails-3-on-aws-micro-centos-nginx-passenger.html</link>
        <guid isPermaLink="true">http://blog.krisforbes.ca/2010/09/11/rails-3-on-aws-micro-centos-nginx-passenger.html</guid>
        
        <category>Ruby on Rails</category>
        
        
      </item>
    
  </channel>
</rss>
