I am a developer, NOT a sysadmin!  Now that this is out of the way, I also should mention that I’m a newb when it comes to Linux and for that matter Ruby on Rails (compared to most Rails and Linux users).

I was initially intrigued by Ruby on Rails from an entrepreneur standpoint; you can create a data driven website literally within minutes.  However, one thing that I learned really quickly was that although Rails development allows for rapid prototyping/development, the install, on the other hand is a major pain in the butt.

One of the major lessons learned is that version matching between Ruby, Ruby Gems, and Rails is paramount in a successful Rails 3.0 install.  Another lesson learned is that install steps for Windows, Linux, and Apple can be drastically different; some have parts already installed and others don’t (among many other differences).  The steps below are strictly for installing Ruby on Rails 3.0 on Ubuntu 10.04.  There are no guarantees for other operating systems, and for that matter, if you deviate from the versions used below, there is no guarantee the install will work.

<rant>Sorry to be such a stickler about versions and operating system differences, but I have tried minor deviations from the below and spent endless hours, just to figure out it was a version of one thing not compatible with another thing.</rant>

Alright, enough talk... on to the install.

First we have to install Ruby 1.8 and necessary components
sudo apt-get install ruby1.8-dev libopenssl-ruby1.8 libsqlite3-dev


Next we will create a symbolic link so we can use "ruby" in place of "ruby1.8"
sudo ln -s /usr/bin/ruby1.8 /usr/bin/ruby


Then we will install Ruby Gems 1.3.6
cd ~
wget http://rubyforge.org/frs/download.php/69365/rubygems-1.3.6.tgz
tar -xvf rubygems-1.3.6.tgz
cd rubygems-1.3.6
sudo ruby setup.rb


We will also create a symbolic link for "gem" as well
sudo ln -s /usr/bin/gem1.8 /usr/bin/gem


Next we will install Rails 3.0
sudo gem install rails --version 3.0.0 --verbose --no-rdoc --no-ri


Now we can create a data driven website with Rails 3.0
cd ~
rails new testing
cd testing
sudo bundle install
ruby script/rails server


Go to http://localhost:3000 in your browser to check it out.

Good luck and let me know what you think.

-Jessy Houle

Posted in:   Tags:

 

blog comments powered by Disqus

If you are hosting a popular website, you undoubtedly have to keep in mind bandwidth costs. Images, video clips, and music can take up quite a bit of bandwidth, which directly affects the bottom line. Even personal blogs, podcasts, and family websites can take a healthy amount of bandwidth. Bandwidth aside, you also have to keep in mind availability/uptime. In comes Amazon S3, which provides cheap bandwidth costs and high availability all in a professional manner.

I do not work for Amazon, nor do I get payment from Amazon in any way. However, I do appreciate when companies provide a truly great service that is an excellent fit for businesses, and can also be utilized by the hobbyist at home.

The Amazon S3 service allows you to outsource your bandwidth intensive content and connect it to something called a Cname (alias), to maintain a professional, branded look.

For example, if I own the csharprocks.com Domain and I have images and video clips that I want to provide to users of my website. I could simply host these image and video clips with my ISP (Internet Service Provider – AKA web hosting company). However, after I reach a certain bandwidth threshold, I will be charged overage fees, or even worse, I could be banned and have to find a new web hosting company. To continue with this example, I want to host my web pages (the ASP.NET, HTML, CSS, and JavaScript) on my webhost, but host my bandwidth intensive content in an Amazon S3 Bucket, which cheapens the bandwidth cost and provides the high availability. However, this leaves me with image URLs like http://storage.csharprocks.com.s3.amazon.com/logo.jpg. This doesn't look very professional and furthermore takes away from my brand. However, with Amazon S3 and my DNS provider, I can change the above link to http://storage.csharprocks.com/logo.jpg or http://images.csharprocks.com/logo.jpg, which looks much more professional and keeps my brand intact. In fact, there is no visible evidence that the image came from an Amazon S3 server at all.

Sign up for an Amazon S3 account (if you haven't already)

I am not going to go in-depth here, as the steps are simple, and I assume you are already an Amazon S3 user, and just want to attach a Cname to your S3 Bucket.

  1. Go to http://aws.amazon.com/s3/
  2. Click the Sign Up For Amazon S3 button
  3. Follow the remaining steps to setup an account

Create your Cname S3 Bucket

The reason that I say "Cname" S3 Bucket is because you have to name your Bucket with your desired Cname. This is very important, as this is the only way Amazon knows how to map your Domain Cname to this Bucket. Also, as a side-note, all Buckets (your Buckets, your friend's Buckets, and Buckets of other people you don't know) are all at the root level. In other words, all Buckets are unique across the Amazon S3 system. If I create a Bucket named "test" then you cannot create a Bucket named "test" because I already own that Bucket name. Ok, back to the example... If I want to have images, video clips, and other high bandwidth content look like they came from my Domain's web host (in the example above http://storage.csharprocks.com), then I need to create an S3 Bucket with that name.

You can use any S3 client of your choosing, but I prefer the S3 Organizer Firefox plug-in and will use it to describe S3 client to server interaction.

  1. Create an Amazon S3 Bucket with the same name as your desired Domain Cname

    S3 Bucket Creations

Attach a Domain Cname (alias) to your S3 Bucket

At this point, you have an S3 Bucket and Amazon is ready to start receiving Cname type requests. Now we need to update our DNS to allow for branded, professional looking web requests (such as http://storage.csharprocks.com/).

Your DNS provider admin screens may look a bit different then DNSExit (http://www.dnsexit.com/), but the concepts and steps should remain true to our example.

  1. Click on the Edit DNS link for your domain
  2. Click on the Add Alias link
  3. Type storage as the alias, choose is external host, and type the URL of the S3 Bucket you created above ({bucketname}.s3.amazonaws.com, where {bucketname} is the name of the S3 Bucket)

    CName creation

  4. Click the Add Alias button
  5. Finally, click the Save Change button

Add content and change ACLs

The final step is to add your high bandwidth content to your S3 Bucket and change the ACL (Access Control List) file permissions. Another side note here... When you upload your content (at least in S3 Organizer), by default the permissions are set to private. Meaning that only you, when authenticated, can request the content. You need to edit your contents ACL to allow anonymous request access.

  1. Upload content to the S3 Bucket you created in the above steps
  2. Edit the ACL of the content you just uploaded by selecting the content (unfortunately, one at a time in S3 Organizer) to have it publicly accessible by right clicking on it and choosing Edit ACL from the context menu

    Edit S3 ACL

  3. You should be prompted with an Edit ACL dialog box. Check-mark the Read access for Everyone and click the Ok button. At this point, the content you selected should be accessible to the public, as well as available using your new Cname (alias).

    S3 ACL Dialog

 

Good luck and let me know how this worked out for you. I am interested to hear if you or your company is capitalizing on this great service, and of any pitfalls you may have experienced.

-Jessy Houle


Posted in:   Tags:

 

blog comments powered by Disqus
Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2012 It Works On My Box