<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ray Acayan &#187; Ubuntu</title>
	<atom:link href="http://www.RayAcayan.com/tag/ubuntu/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.RayAcayan.com</link>
	<description>A Geek of All Trades</description>
	<lastBuildDate>Wed, 18 Aug 2010 19:40:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>The Amazon EC2 Blog Migration Project</title>
		<link>http://www.RayAcayan.com/projects/the-amazon-ec2-blog-migration-project/</link>
		<comments>http://www.RayAcayan.com/projects/the-amazon-ec2-blog-migration-project/#comments</comments>
		<pubDate>Tue, 27 Oct 2009 16:46:29 +0000</pubDate>
		<dc:creator>Ray Acayan</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[Amazon EC2]]></category>
		<category><![CDATA[Amazon Web Services]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[AWS]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[cloud]]></category>
		<category><![CDATA[Consulting]]></category>
		<category><![CDATA[cPanel]]></category>
		<category><![CDATA[FileZilla]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[mod_security]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[OWASP]]></category>
		<category><![CDATA[PuTTY]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Webalizer]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://174.129.34.151/blog/?p=1080</guid>
		<description><![CDATA[I. Overview This side project presents my procedure for migrating my WordPress blog from a web hosting provider running cPanel to an Amazon EC2 instance. This project builds on the environment created in my previous blog post, &#34;The Mobile Cloud Project, Part 1.1: Basic AWS&#34;, where I presented an overview of Amazon Web Services and [...]]]></description>
			<content:encoded><![CDATA[<p></br></p>
<h2 style="color:darkblue">I. Overview</h2>
<p>This side project presents my procedure for migrating my WordPress blog from a web hosting provider running cPanel to an Amazon EC2 instance.</p>
<p>This project builds on the environment created in my previous blog post, <a href="http://www.rayacayan.com/projects/the-mobile-cloud-project-part-1-1-basic-aws/"><b>&quot;The Mobile Cloud Project, Part 1.1: Basic AWS&quot;</b></a>, where I presented an overview of Amazon Web Services and a procedure for creating virtual servers (Reserved and On-Demand instances) on Amazon EC2.<br />
<br /></br></p>
<h2 style="color:darkblue">II. Consulting</h2>
<p>I do my best to explain the concepts and techniques behind my projects.  If you like my work and can use my expertise in your projects, I am available for <span id="consulting_page" onmouseover="consulting_mouseOver()" onmousemove="consulting_mouseMove()" onmouseout="consulting_mouseOut()"><a href="http://www.RayAcayan.com/consulting/"><strong>consulting</strong></a></span> at a competitive rate.<br />
<br /></br></p>
<h2 style="color:darkblue">III. Procedure</h2>
<p>Once the Amazon EC2 instance was created and configured in my previous <a href="http://www.rayacayan.com/projects/the-mobile-cloud-project-part-1-1-basic-aws/"><b>blog post</b></a>, this migration procedure is actually fairly straightforward.  From the point of view of a terminal console, an Amazon EC2 instance running Ubuntu Linux is very similar to any other Ubuntu server.  The only difference is that certain tasks that were simplified behind a web hosting provider&#8217;s cPanel now need to be done explicitly on an EC2 instance.</p>
<p>This procedure assumes an existing WordPress blog at <a href="http://www.RayAcayan.com">http://www.RayAcayan.com</a> (i.e. this blog), an existing EC2 instance running Ubuntu 9.10 (Karmic), an Elastic IP address associated with that instance, and a local Windows client with Putty and FileZilla configured to connect to both the old blog&#8217;s web hosting provider and the new blog&#8217;s EC2 instance.  These were all configured in my previous blog post <a href="http://www.rayacayan.com/projects/the-mobile-cloud-project-part-1-1-basic-aws/"><b>&#8220;The Mobile Cloud Project, Part 1.1: Basic AWS&#8221;</b></a>. </p>
<h3 style="color:darkgreen">1.  Install packages on EC2 instance</h3>
<ol type="i">
<li>Connect to the EC2 instance using Putty.</li>
<li> Install Apache2, MySQL, PHP, Ruby on Rails, Python, and Django packages with the following commands.</li>
<div class="code">
$ sudo apt-get update<br />
$ sudo apt-get install apache2 mysql-server libapache2-mod-auth-mysql<br />
$ sudo apt-get install php5-mysql phpmyadmin<br />
$ sudo apt-get install build-essential libssl-dev libreadline5-dev zlib1g-dev<br />
$ sudo apt-get install libmysqlclient15-dev<br />
<br />
$ sudo apt-get install ruby-full rubygems1.9.1 rails libmysql-ruby<br />
<br />
$ sudo apt-get install python2.6 python3 python-django<br />
$ sudo apt-get install libapache2-mod-python python-mysqldb
</div>
</ol>
<h3 style="color:darkgreen">2.  Enable mod_rewrite on Apache</h3>
<ol type="i">
<li>The mod_rewrite module allows WordPress to use pretty permalinks on your blog, such as /category/postname/</li>
<div class="code">
$ sudo a2enmod rewrite<br />
$ sudo nano /etc/apache2/sites-enabled/000-default
</div>
<li>Modify this file to show the following changes (i.e. change &#8220;None&#8221; to &#8220;All&#8221; to allow pretty permalinks, and add # comments to disable directory listing) then save this file.</li>
<div class="code">
DocumentRoot /var/www/<br />
[...]<br />
Options FollowSymLinks<br />
AllowOverride <b>All</b><br />
[...]<br />
<b>#</b> Options Indexes FollowSymLinks MultiViews<br />
<b>#</b> AllowOverride None<br />
<b>#</b> Order allow,deny<br />
<b>#</b> allow from all
</div>
<li>Restart Apache:</li>
<div class="code">
$ sudo /etc/init.d/apache2 restart
</div>
</ol>
<h3 style="color:darkgreen">3.  Install WordPress on the EC2 instance</h3>
<ol type="i">
<li>Connect to the EC2 instance using Putty.</li>
<li>Create the WordPress username and database on MySQL by entering the following commands:</li>
<div class="code">
$ sudo mysql -u root -p &lt;password&gt;<br />
mysql> create database wordpress;<br />
mysql> create user &lt;wp_username&gt;;<br />
mysql> set password for &lt;wp_username&gt; = password(&#8220;&lt;password&gt;&#8221;);<br />
mysql> grant all on wordpress.* to &lt;wp_username&gt;@localhost identified by `&lt;password&gt;&#8217;;<br />
mysql> quit
</div>
<li>Enter the following commands at the Linux prompt to download and install WordPress:</li>
<div class="code">
$ cd /var/www<br />
$ sudo wget http://wordpress.org/latest.tar.gz<br />
$ sudo tar -xzvf latest.tar.gz<br />
$ sudo mv wordpress blog
</div>
<li>Go to http://&lt;elastic ip&gt;/blog/wp-admin/install.php to execute the WordPress install script.</li>
<li>Download and install the WordPress themes and plugins that were in the previous blog (cPanel).</li>
</ol>
<p></p>
<h3 style="color:darkgreen">4.  Copy WordPress files and database from the old blog to the new blog</h3>
<ol type="i">
<li>Open FileZilla client and connect to the web hosting provider&#8217;s server that is hosting the old blog.  (See the provider&#8217;s instructions on how to do this.)</li>
<li>Download all files in the old blog:  ~/public_html or /var/www</li>
<li>Open a second FileZilla client to connect to the new blog (EC2). </li>
<li>Upload your custom files and directories to the /var/www directory of the new blog.</li>
<li>Open the WordPress Dashboard on the old blog (cPanel), click &quot;Export&quot; in the &#8220;Tools&#8221; menu on the left, and save the .xml file.</li>
<li>Open the WordPress Dashboard on the new blog (EC2), click &quot;Import&quot; in the &#8220;Tools&#8221; menu on the left, and upload the .xml file from the previous step. </li>
<li>Install the &#8220;WP-DB-Backup&#8221; plugin on both the old and new blogs.</li>
<li>On the old blog&#8217;s WordPress admin, click &#8220;Backup&#8221; on the &#8220;Tools&#8221; menu on the left and save the file as &#8220;oldwordpress.sql&#8221;.</li>
<li>Connect to the EC2 instance via FileZilla and upload the &#8220;oldwordpress.sql&#8221; file.
<li>Connect to the EC2 instance via Putty.</li>
<li>At the Linux prompt, enter &#8220;mysql wordpress &lt; oldwordpress.sql â€“u root -p&#8221; to import the old WordPress database to the new one.</li>
<li>Verify that the new blog is working at http://&lt;elastic ip&gt;/blog including links and styles. </li>
</ol>
<p></p>
<h3 style="color:darkgreen">5. Remap DNS to the new blog IP address on EC2</h3>
<ul>
<li>DNS needs to be configured to remap the blog&#8217;s domain name to the Elastic IP address of the new blog on EC2.</li>
</ul>
<ol type="i">
<li>Before proceeding, add an entry &#8220;&lt;elastic ip&gt; www.RayAcayan.com&#8221; to the local hosts file at C:\windows\system32\drivers\etc</li>
<li>Verify that the blog is working properly using the normal URL <a href="http://www.RayAcayan.com">http://www.RayAcayan.com</a></li>
<p>  At this point, only the local computer can access the new blog via URL because of the hosts file entry.  The new IP address will need to be propagated to the rest of the Internet via an external DNS provider so that everyone else can access it.</a></li>
<li>Select an external DNS provider such as <a href="http://www.easyDNS.com">http://www.easyDNS.com</a> and purchase a DNS-only service for about $20/year.</li>
<li>Add a DNS entry to map the hostname to the Elastic IP address of the new blog.</li>
<li>Go to the domain registrar&#8217;s website where the old blog domain is currently registered.</li>
<li>Change the name servers of the domain to point to the name servers of the  external DNS provider.</li>
<li>Wait several hours for the new DNS settings to propagate on the Internet.  Enter &#8220;nslookup&#8221; at the command prompt. If the response is the elastic IP address of the EC2 instance, then the DNS propagation has completed.</li>
<li>Remove the hosts file entry created in step 5.i. and run &#8220;ipconfig /dnsflush&#8221; at the command prompt. Verify that the blog is still reachable via the normal URL: <a href="http://www.RayAcayan.com">http://www.RayAcayan.com</a></li>
</ol>
<h3 style="color:darkgreen">6.  Install Additional Applications</h3>
<ol type="A">
<strong>
<li>Install Webalizer</li>
<p></strong><br />
Webalizer is a web stats application offered by your web hosting provider&#8217;s cPanel.  You will need to install it manually on your EC2 instance if you want to continue using it.</p>
<ol type="i">
<li>Connect to the EC2 instance using Putty.</li>
<li>Enter the following command to install Webalizer on the EC2 instance:</li>
<div class="code">
# apt-get install webalizer
</div>
</ol>
</ol>
<h3 style="color:darkgreen">7.  Configure Security</h3>
<ol type="A">
<strong>
<li>Secure the Apache web server with mod_security and Core Rule Set</li>
<p></strong></p>
<p>The &#8220;mod_security&#8221; Apache module is an open source intrusion detection and prevention engine for web applications.  It protects the Apache web server from common attacks such as SQL injection, cross-site scripting, etc.</p>
<ol type="i">
<li>Connect to the EC2 instance using Putty.</li>
<li>Enter the following commands at the Linux prompt:</li>
<div class="code">
#mkdir ~/install<br />
#cd ~/install<br />
#wget http://www.modsecurity.org/download/modsecurity-apache_2.5.10.tar.gz<br />
# tar -xzvf modsecurity-apache_2.5.10.tar.gz<br />
# cd modsecurity-apache_2.5.10/rules<br />
# cp *.conf /etc/apache2/conf.d<br />
# cp base_rules /etc/apache2/conf.d/modsecurity<br />
# cp optional_rules /etc/apache2/conf.d<br />
# mkdir /etc/apache2/logs<br />
# apt-get install libapache-mod-security<br />
# a2enmod mod-security
</div>
<li>Restart Apache:</li>
<div class="code">
# /etc/init.d/apache2 restart
</div>
</ol>
<p><strong>
<li>Configure password-protection on the PHPMyAdmin directory</li>
<p></strong></p>
<ol type="i">
<li>Connect to the EC2 instance using Putty.</li>
<li>Enter the following commands at the Linux prompt:</li>
<div class="code">
# mkdir /usr/local/apache2<br />
# htdigest -c /usr/local/apache2/.htpasswd_phpmyadmin &#8220;PHPMyAdmin&#8221; phpmyadmin<br />
(Enter password)<br />
# cp /etc/apache2/mods-available/auth_digest.load /etc/apache2/mods-enabled<br />
# nano /etc/apache2/apache2.conf
</div>
</li>
<li>Add the following text to the end of the apache2.conf file:</li>
<div class="code">
&lt;Directory /usr/share/phpmyadmin/&gt;<br />
&nbsp;&nbsp;Authtype digest<br />
&nbsp;&nbsp;AuthName &#8220;PHPMyAdmin&#8221;<br />
&nbsp;&nbsp;AuthUserFile /usr/local/apache2/.htpasswd_phpmyadmin<br />
&nbsp;&nbsp;require user phpmyadmin<br />
&lt;/Directory&gt;
</div>
<li>For added security, insert the following lines inside the &lt;Directory&gt; tag above to only allow connections from certain IP addresses:</li>
<div class="code">
&nbsp;&nbsp;Order deny,allow<br />
&nbsp;&nbsp;Deny from all<br />
&nbsp;&nbsp;Allow from &lt;static IP address&gt;
</div>
<li>Restart Apache:</li>
<div class="code">
# /etc/init.d/apache2 restart
</div>
</ol>
<p><strong>
<li>Configure password-protection on the WordPress Admin directory</li>
<p></strong></p>
<ol type="i">
<li>Connect to the EC2 instance using Putty.</li>
<li>Enter the following commands at the Linux prompt:</li>
<div class="code">
# mkdir /usr/local/apache2<br />
# htdigest -c /usr/local/apache2/.htpasswd_wp-admin &#8220;WordPress Admin&#8221; wp-admin<br />
(Enter password)<br />
# cp /etc/apache2/mods-available/auth_digest.load /etc/apache2/mods-enabled<br />
# nano /etc/apache2/apache2.conf
</div>
</li>
<li>Add the following text to the end of the apache2.conf file:</li>
<div class="code">
&lt;Directory /var/www/blog/wp-admin/&gt;<br />
&nbsp;&nbsp;Authtype digest<br />
&nbsp;&nbsp;AuthName &#8220;WordPress Admin&#8221;<br />
&nbsp;&nbsp;AuthUserFile /usr/local/apache2/.htpasswd_wp-admin<br />
&nbsp;&nbsp;require user wp-admin<br />
&lt;/Directory&gt;
</div>
<li>For added security, insert the following lines inside the &lt;Directory&gt; tag above to only allow connections from certain IP addresses:</li>
<div class="code">
&nbsp;&nbsp;Order deny,allow<br />
&nbsp;&nbsp;Deny from all<br />
&nbsp;&nbsp;Allow from &lt;static IP address&gt;
</div>
<li>Restart Apache:</li>
<div class="code">
# /etc/init.d/apache2 restart
</div>
</ol>
<p><strong>
<li>Configure password-protection on the Webalizer directory</li>
<p></strong></p>
<ol type="i">
<li>Connect to the EC2 instance using Putty.</li>
<li>Enter the following commands at the Linux prompt:</li>
<div class="code">
# mkdir /usr/local/apache2<br />
# htdigest -c /usr/local/apache2/.htpasswd_webalizer &#8220;Webalizer Stats&#8221; webalizer<br />
(Enter password)<br />
# cp /etc/apache2/mods-available/auth_digest.load /etc/apache2/mods-enabled<br />
# nano /etc/apache2/apache2.conf
</div>
</li>
<li>Add the following text to the end of the apache2.conf file:</li>
<div class="code">
&lt;Directory /var/www/webalizer/&gt;<br />
&nbsp;&nbsp;Authtype digest<br />
&nbsp;&nbsp;AuthName &#8220;Webalizer Stats&#8221;<br />
&nbsp;&nbsp;AuthUserFile /usr/local/apache2/.htpasswd_webalizer<br />
&nbsp;&nbsp;require user webalizer<br />
&lt;/Directory&gt;
</div>
<li>For added security, insert the following lines inside the &lt;Directory&gt; tag above to only allow connections from certain IP addresses:</li>
<div class="code">
&nbsp;&nbsp;Order deny,allow<br />
&nbsp;&nbsp;Deny from all<br />
&nbsp;&nbsp;Allow from &lt;static IP address&gt;
</div>
<li>Restart Apache:</li>
<div class="code">
# /etc/init.d/apache2 restart
</div>
</ol>
</ol>
<p>&nbsp;</p>
<h2 style="color:darkblue">IV. References</h2>
<p><strong>1. Amazon Web Services Technical Documentation</strong><br />
<a href="http://aws.amazon.com/documentation">http://aws.amazon.com/documentation</a></p>
<p><strong>2. Official Ubuntu Documentation</strong><br />
<a href="https://help.ubuntu.com">https://help.ubuntu.com</a></p>
<p><strong>3. RubyOnRails.org</strong><br />
<a href="http://rubyonrails.org/download/">http://rubyonrails.org/download/</a></p>
<p><strong>4. Python Programming Language &#8212; Official Website</strong><br />
<a href="http://www.python.org">http://www.python.org</a></p>
<p><strong>5. The Django Project</strong><br />
<a href="http://www.djangoproject.com/">http://www.djangoproject.com/</a></p>
<p><strong>6. Moving WordPress</strong><br />
<a href="http://codex.wordpress.org/Moving_WordPress">http://codex.wordpress.org/Moving_WordPress</a></p>
<p><strong>7. easyDNS</strong><br />
<a href="http://www.easydns.com">http://www.easydns.com</a></p>
<p><strong>8. OWASP ModSecurity Core Rule Set Project</strong><br />
<a href="http://www.owasp.org/index.php/Category:OWASP_ModSecurity_Core_Rule_Set_Project">http://www.owasp.org/index.php/Category:OWASP_ModSecurity_Core_Rule_Set_Project</a></p>
<p></br><br /></br></p>
]]></content:encoded>
			<wfw:commentRss>http://www.RayAcayan.com/projects/the-amazon-ec2-blog-migration-project/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Mobile Cloud Project, Part 1.1: Basic AWS</title>
		<link>http://www.RayAcayan.com/projects/the-mobile-cloud-project-part-1-1-basic-aws/</link>
		<comments>http://www.RayAcayan.com/projects/the-mobile-cloud-project-part-1-1-basic-aws/#comments</comments>
		<pubDate>Thu, 22 Oct 2009 17:14:03 +0000</pubDate>
		<dc:creator>Ray Acayan</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[Amazon EC2]]></category>
		<category><![CDATA[Amazon S3]]></category>
		<category><![CDATA[Amazon Web Services]]></category>
		<category><![CDATA[AWS]]></category>
		<category><![CDATA[Canonical]]></category>
		<category><![CDATA[Cloud Security Alliance]]></category>
		<category><![CDATA[Consulting]]></category>
		<category><![CDATA[Elastic IP]]></category>
		<category><![CDATA[FileZilla]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[On-Demand Instance]]></category>
		<category><![CDATA[PuTTY]]></category>
		<category><![CDATA[Reserved Instance]]></category>
		<category><![CDATA[SFTP]]></category>
		<category><![CDATA[SSH]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.rayacayan.com/blog/?p=940</guid>
		<description><![CDATA[I. Overview The Mobile Cloud Project is my proof-of-concept for developing and hosting a scalable mobile application platform on the Amazon Web Services cloud.. Part 1.1 of this project provides a basic overview of Amazon Web Services and describes my procedure for building Ubuntu Linux virtual servers (Reserved and On-Demand instances) on Amazon EC2. Please [...]]]></description>
			<content:encoded><![CDATA[<p></br></p>
<h2 style="color:darkblue">I. Overview</h2>
<p>The <a href="/projects/the-mobile-cloud-project/"><b>Mobile Cloud Project</b></a> is my proof-of-concept for developing and hosting a scalable mobile application platform on the Amazon Web Services cloud..</p>
<p><a href="/projects/the-mobile-cloud-project-part-1-1-basic-aws"><b>Part 1.1</b></a> of this project provides a basic overview of Amazon Web Services and describes my procedure for building Ubuntu Linux virtual servers (Reserved and On-Demand instances) on Amazon EC2.</p>
<p>Please see the <a href="/projects/the-mobile-cloud-project/"><b>main project page</b></a> for more information on the other parts of this project.<br />
<br /></br></p>
<h2 style="color:darkblue">II. Consulting</h2>
<p>I do my best to explain the concepts and techniques behind my projects.  If you like my work and can use my expertise in your projects, I am available for <span id="consulting_page" onmouseover="consulting_mouseOver()" onmousemove="consulting_mouseMove()" onmouseout="consulting_mouseOut()"><a href="http://www.RayAcayan.com/consulting/"><strong>consulting</strong></a></span> at a competitive rate.<br />
<br /></br></p>
<h2 style="color:darkblue">III.  Overview of Amazon Web Services</h2>
<p>Amazon Web Services (AWS) is a collection of technologies that enable us to host our applications on Amazon&#8217;s server and network infrastructure (the &quot;cloud&quot;).  AWS can provide an individual or startup with the potential computing power of thousands of networked servers, petabytes of storage space, and fault-tolerant capabilities, which rival the infrastructure of large corporations that possess multiple data centres and IT departments.  You require no physical hardware, network infrastructure, electricity, nor legions of IT staff, in order to run your powerful virtual enterprise in the cloud.  The scalability of AWS makes it an ideal solution for hosting the back-end platform for popular mobile apps used by millions of users.</p>
<h3 style="color:darkgreen">1. Amazon EC2</h3>
<p>An &quot;instance&quot;, or virtual server, is the basic unit of computing resource in the Amazon Elastic Compute Cloud (EC2).   You can create as many instances as you need, and pricing is based on instance type, &quot;size&quot;, and hourly usage.  A Reserved Instance is a dedicated virtual server which is often kept running all the time, while an On-Demand instance is usually turned on only as required.</p>
<h3 style="color:darkgreen">2. Amazon S3</h3>
<p>Amazon Simple Storage Service (S3) is a virtual data storage area.   A &quot;bucket&quot; is analogous to a filesystem that can store objects or files.  You can create as much data storage as you need in S3, and pricing is based on storage size and amount of data transferred.</p>
<h3 style="color:darkgreen">3. Elastic IP Addresses</h3>
<p>An Elastic IP address is an Internet-routable static IP address that is allocated to your AWS EC2 account.  You can map an Elastic IP address to any running instance (which has a private IP address), and quickly remap to a different instance if the other instance fails.  Network address translation is enabled automatically via 1:1 NAT.  There is no charge for elastic IP addresses while in use.<br />
<br /></br></p>
<h2 style="color:darkblue">IV. Procedure</h2>
<p>In this procedure, I will demonstrate how to create two EC2 instances: a Reserved Instance called &#8220;Galactica&#8221; (which will eventually host this blog and related web apps) and an On-Demand instance called &#8220;Pegasus&#8221; for future use.</p>
<h3 style="color:darkgreen">1. Sign up for a free AWS account</h3>
<ol type="i">
<li>Go to <a href="http://aws.amazon.com"><b>http://aws.amazon.com</b></a> and click &quot;Sign Up Now&quot;.</li>
<li>Fill out the requested information.</li>
</ol>
<h3 style="color:darkgreen">2.  Sign up for Amazon EC2 and S3</h3>
<ol type="i">
<li>Go to <a href="http://aws.amazon.com/ec2"><b>http://aws.amazon.com/ec2</b></a> and click &quot;Sign Up for Amazon EC2&quot;.</li>
<li>Review the pricing details and enter your credit card and billing information.</li>
<li>Complete the identity verification by telephone.</li>
<li>You are now signed up for both EC2 and S3.</li>
</ol>
<h3 style="color:darkgreen">3. Sign in to the AWS Management Console</h3>
<ol type="i">
<li>Go to <a href="http://aws.amazon.com/console"><b>http://aws.amazon.com/console</b></a> and click &quot;Sign in to the AWS Console&quot; (EC2).</li>
</ol>
<h3 style="color:darkgreen">4. Create Key Pairs</h3>
<p>You will need to create a key pair for each instance you plan to launch.  This allows you to access your instance securely via SSH (Linux) or RDP (Windows).</p>
<ol type="i">
<li>In Windows Explorer, create the folders &#8220;C:\aws&#8221; and &#8220;C:\aws\ec2&#8243;</li>
<li>Click &quot;Key Pairs&quot; in the left menu, click &quot;Create Key Pair&quot;, and enter a name for this key pair (e.g. &quot;Galactica&quot;).</li>
<li>Save the &#8220;Galactica.pem&#8221; private key file in the C:\aws\ec2 folder.</li>
<li>Create another key pair for the second instance (e.g. &quot;Pegasus&quot;).</li>
</ol>
<h3 style="color:darkgreen">5. Create a Security Group</h3>
<p>A Security Group is essentially a set of firewall rules that can be applied to your instances.  A cloud-based virtual server is still vulnerable to hackers just like any other server connected to the Internet.  You need to remain vigilant and follow cloud security best practices.  (See the Cloud Security Alliance <a href="http://www.cloudsecurityalliance.org"><b>website</b></a> for more information.)</p>
<ol type="i">
<li>Click &quot;Security Groups&quot; from the left menu, then click &quot;Create Security Group&quot;.</li>
<li>Enter a name for this security group (e.g. &quot;Stargate&quot;) then click &quot;Create&quot;.</li>
<li>In the &quot;Allowed Connections&quot; section, select &quot;SSH&quot; then click &quot;Save&quot;.</li>
<li>In the same section, select &quot;HTTP&quot; then click &quot;Save&quot;.</li>
<li>Add more firewall rules as required.  All other network traffic will be blocked.</li>
</ol>
<h3 style="color:darkgreen">6.  Purchase a Reserved Instance</h3>
<p>A Reserved Instance is a prepaid instance that offers &quot;significantly&quot; discounted usage fees compared to an On-Demand instance.  In this example, a &quot;Small&quot; Linux/Unix reserved instance will cost $350 for a 3-yr term and $0.03/hr (roughly $22/month) usage fees, while the same On-Demand instance will cost $0.085/hr in usage fees (as of Nov 1, 2009), or about $62/month if used 24/7.  Usage fees and discounts are calculated automatically.  For example, if you have X reserved instances, then the first X instances currently running will be charged at the discounted usage fee, while the remaining instances are charged at the on-demand usage fee.</p>
<ol type="i">
<li>Click &quot;Instances&quot; on the left menu.</li>
<li>Click on the &quot;Reserved Instances&quot; dropdown list and select &quot;Purchase Reserved Instances&quot;.</li>
<li>Select &quot;Linux/UNIX&quot; platform, &quot;m1.small&quot; instance type, &quot;Best Available&quot; zone, a term of &quot;3 years&quot;, and &quot;1&quot; instance.</li>
<li>Click &quot;Continue&quot; then click &quot;Place Order&quot; to confirm.</li>
<li>You may need to wait a few minutes until the payment is processed and the reserved instance is activated. Click &quot;Close&quot;.</li>
</ol>
<h3 style="color:darkgreen">7.  Launch AMI Instances</h3>
<p>An Amazon Machine Image (AMI) is essentially a disk image containing a pre-configured operating system and software.  You have the ability to create your own AMI disk image from an existing server or select a pre-built AMI from Amazon&#8217;s list.</p>
<ol type="i">
<li>Click &quot;Instances&quot; on the left menu, then click &quot;Launch Instance&quot;.</li>
<li>Click &quot;Community AMIs&quot; tab.</li>
<li>In the textbox to the right of &quot;All Images&quot; and &quot;All Platforms&quot;, enter &quot;ubuntu-images-us&quot; for a list of official Ubuntu releases (currently Ubuntu 9.10 Karmic as of Oct 29, 2009).</li>
<li>Select an AMI from the list. Amazon charges less for 32-bit instances, so select the cheaper 32-bit &quot;i386&quot; AMI rather than the 64-bit &quot;amd64&quot; AMI.  In this example, select the &#8220;ami-1515f67c&#8221; AMI ID and click &quot;Select&quot;.</li>
<li>On the next page, enter &quot;1&quot; instance, &#8220;Small&#8221; (m1.small) instance type, &quot;Galactica&quot; key pair, and &quot;Stargate&quot; security group, then click &quot;Launch&quot;.</li>
<li>Repeat these steps to launch another instance for the &quot;Pegasus&quot; key pair.</li>
</ol>
<h3 style="color:darkgreen">8.  Create Elastic IP address</h3>
<p>As mentioned previously, an Elastic IP address is simply an Internet-routable static IP address that is allocated to your AWS EC2 account and can be mapped (associated) with any running instance.</p>
<ol type="i">
<li>Click &quot;Elastic IPs&quot; on the left menu.</li>
<li>Click &quot;Allocate New Address&quot;, then click &quot;Yes, Allocate&quot; to confirm.</li>
<li>Check the box next to the IP address, then click &quot;Associate&quot;.</li>
<li>Select the appropriate Instance ID, then click &quot;Associate&quot;.</li>
<li>You can now configure your DNS to map your existing domain name to this Elastic IP address and access this instance over the Internet.</li>
</ol>
<h3 style="color:darkgreen">9.  Install and configure PuTTY</h3>
<p>PuTTY is a free SSH client that enables you to configure and install packages on your Amazon EC2 instance from Windows.</p>
<ol type="i">
<li>Download  PuTTY, PuTTYgen, and PSCP from:<a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html"><b>http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html</b></a>
</li>
<li>Create a folder &#8220;C:\putty&#8221; and move these files to that folder.</li>
<li>Go to Control Panel, System, Advanced system settings, Environment Variables, Add &#8220;C:\putty&#8221; to the PATH system variable.</li>
<li>Run the &#8220;puttygen.exe&#8221; application from Windows.</li>
<li>Click the &#8220;File&#8221; menu, select &#8220;Load private key&#8221;, then select C:\aws\ec2\Galactica.pem (from Step 4.iii.)</li>
<li>The application will prompt you to save the file in PuTTY&#8217;s own format and click &#8220;OK&#8221;.
<li>
<li>Click the &#8220;File&#8221; menu, click &#8220;Save private key&#8221;. Click &#8220;Yes&#8221; to save this key without a passphrase to protect it.</li>
<li>Save the &#8220;Galactica.ppk&#8221; file in the C:\aws\ec2 folder.</li>
<li>Run the &#8220;putty.exe&#8221; application from Windows.</li>
<li>Enter the Elastic IP address in both the &#8220;Host Name&#8221; and &#8220;Saved Sessions&#8221; text boxes.</li>
<li>On the left pane, click &#8220;SSH&#8221; then click &#8220;Auth&#8221;.</li>
<li>Click &#8220;Browse&#8221; then select the file C:\aws\ec2\Galactica.ppk.</li>
<li>On the left pane, click &#8220;Connection&#8221; then click &#8220;Data&#8221;.</li>
<li>Enter &#8220;ubuntu&#8221; in the &#8220;Auto-login username&#8221; text box.</li>
<li>Click &#8220;Session&#8221; at the top of the left pane, then click &#8220;Save&#8221;.</li>
<li>Click &#8220;Open&#8221; to verify that you can connect to this EC2 instance. Click &#8220;Yes&#8221; if the PuTTY Security Alert pops up.</li>
<li>You are authenticated via username and private key, so you do not need to enter a login password.</li>
</ol>
<h3 style="color:darkgreen">10.  Install and configure FileZilla</h3>
<p>FileZilla is a free SFTP client that allows you to transfer files to/from your Amazon EC2 instance.</p>
<ol type="i">
<li>Download and install FileZilla Client from <a href="http://filezilla-project.org/"><b>http://filezilla-project.org/</b></a></li>
<li>Run the FileZilla application in Windows.</li>
<li>Select Edit, Settings from the menu.</li>
<li>On the left pane, click &#8220;SFTP&#8221; then click the &#8220;Add keyfile&#8221; button.</li>
<li>Select the C:\aws\ec2\Galactica.ppk private key file then click &#8220;Open&#8221;.</li>
<li>Select File, Site Manager from the menu.</li>
<li>Click &#8220;New Site&#8221; and enter your elastic IP address in the &#8220;Host&#8221; text box.</li>
<li>In Servertype, select &#8220;SFTP &#8211; SSH File Transfer Protocol&#8221;.</li>
<li>Leave the Logontype as &#8220;Normal&#8221; and enter &#8220;root&#8221; in the User text box.</li>
<li>Click &#8220;Connect&#8221; to verify SFTP connectivity to your EC2 instance.</li>
</ol>
<h3 style="color:darkgreen">11. Install the Amazon EC2 API tools on your Windows client</h3>
<p>You will need to download your Amazon private key and cert in order to install the Amazon EC2 API tools, which are used to access additional EC2 functions (via command line or programmaticaly via the EC2 API) that are not available on the AWS Management Console web interface.</p>
<ol type="i">
<li>On your Windows machine, create the folders &#8220;C:\aws&#8221; and &#8220;C:\aws\ec2&#8243;.</li>
<li>Go to <a href="https://aws-portal.amazon.com/gp/aws/developer/account/index.html?ie=UTF8&#038;action=access-key"><b>https://aws-portal.amazon.com/gp/aws/developer/account/index.html?ie=UTF8&#038;action=access-key</b></a></li>
<li>Click the &quot;X.509 Certificates&quot; tab.</li>
<li>Click &quot;Create a New Certificate&quot;.</li>
<li>Click &quot;Download Private Key File&quot; and save the pk*.pem file to C:\aws\ec2.</li>
<li>Click &quot;Download X.509 Certificate&quot; and save the cert*.pem file to C:\aws\ec2.</li>
<li>In Windows Explorer, make a copy of the pk*.pem file and name it &#8220;ec2-pk.pem&#8221;.</li>
<li>Also make a copy of the cert*.pem file and name it &#8220;ec2-cert.pem&#8221;.</li>
<li>Download the EC2 API Tools from <a href="http://developer.amazonwebservices.com/connect/entry.jspa?externalID=351&#038;categoryID=88"><b>http://developer.amazonwebservices.com/connect/entry.jspa?externalID=351&#038;categoryID=88</b></a></li>
<li>Unzip the files into the &#8220;C:\aws\ec2&#8243; folder.</li>
<li>In Windows, click the &quot;Start&quot; menu, &quot;Settings&quot;, &#8220;Control Panel&#8221;, &#8220;System&#8221;, click &#8220;Advanced system settings&#8221;, then click &#8220;Environment Variables&#8230;&#8221;.</li>
<li>In the bottom window called &#8220;System variables&#8221;, click &#8220;New&#8230;&#8221;.</li>
<li>Enter &#8220;EC2_PRIVATE_KEY&#8221; as the Variable name, enter &#8220;c:\aws\ec2\ec2-pk.pem&#8221; as the Variable value, then click &#8220;OK&#8221;.</li>
<li>Click &#8220;New&#8230;&#8221; again in the bottom window called &#8220;System variables&#8221;.</li>
<li>Enter &#8220;EC2_CERT&#8221; as the Variable name, enter &#8220;c:\aws\ec2\ec2-cert.pem&#8221; as the Variable value, then click &#8220;OK&#8221;.
<li>
<li>In the bottom window &quot;System variables&quot;, find and select the variable named &quot;Path&quot;.<br />
Click &quot;Edit&#8230;&quot;, insert &quot;%EC2_HOME%\bin;&quot; at the beginning of the Variable value, and click &#8220;OK&#8221;.</li>
<li>In Windows, click the &quot;Start&quot; menu, click &quot;Run&quot;, enter &quot;cmd&quot;, and click &#8220;OK&#8221; to open a command prompt.</li>
<li>Enter the following command to verify that the EC2 API command-line tools are working properly:</li>
<div class="code">
C:\ec2-describe-regions
</div>
</ol>
<h3 style="color:darkgreen">12. Install software on your Amazon EC2 instance</h3>
<ul>
<li>You can now install software packages on your Amazon EC2 instance.  Keep in mind that although this is a virtual server, you still need to follow the license agreements that come with your software.</li>
</ul>
<h3 style="color:darkgreen">Optional:  Terminate the Instances</h3>
<ul>
<li>If you are just following along and no longer need these instances, you can terminate them to avoid further usage charges.  However, note that all your changes will be lost if you have not yet bundled an AMI snapshot of this instance (described in <a href="//the-mobile-cloud-project-part-1-2-aws-data"><b>Part 1.2: AWS Data</b></a>).</li>
</ul>
<ol type="i">
<li>Click &quot;Instances&quot; on the left menu.</li>
<li>Click the checkbox of the instance you want to terminate.</li>
<li>Click &quot;Instance Actions&quot; dropdown list and select &quot;Terminate&quot; to shutdown this instance.</li>
</ol>
<p>&nbsp;</p>
<h2 style="color:darkblue">V. Next Steps</h2>
<ul>
<li>In <a href="//the-mobile-cloud-project-part-1-2-aws-data"><b>Part 1.2: AWS Data</b></a>, I will explore the use of Amazon S3 and EBS for cloud-based storage and Amazon SimpleDB and RDS for database applications.</li>
<li>In <a href="//the-mobile-cloud-project-part-1-3-aws-fault-tolerance"><b>Part 1.3: AWS Fault Tolerance</b></a>, I will explore the AutoScaling and Elastic Load Balancing features of Amazon Web Services.</li>
<li>Please see <a href="//projects/the-mobile-cloud-project/"><b>The Mobile Cloud Project</b></a> page for more info on the other parts of this project.</li>
</ul>
<p>&nbsp;</p>
<h2 style="color:darkblue">VI.  References</h2>
<p><strong>1. Amazon Web Services Technical Documentation</strong><br />
<a href="http://aws.amazon.com/documentation">http://aws.amazon.com/documentation</a></p>
<p><strong>2. Cloud Security Alliance</strong><br />
<a href="http://www.cloudsecurityalliance.org">http://www.cloudsecurityalliance.org</a></p>
<p><strong>3. Ubuntu Server Edition on Amazon EC2</strong><br />
<a href="http://www.ubuntu.com/products/whatisubuntu/serveredition/features/ec2">http://www.ubuntu.com/products/whatisubuntu/serveredition/features/ec2</a></p>
<p></br><br /></br></p>
]]></content:encoded>
			<wfw:commentRss>http://www.RayAcayan.com/projects/the-mobile-cloud-project-part-1-1-basic-aws/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The QuantLib Ruby Project, Part 1</title>
		<link>http://www.RayAcayan.com/projects/the-quantlib-ruby-project-part-1/</link>
		<comments>http://www.RayAcayan.com/projects/the-quantlib-ruby-project-part-1/#comments</comments>
		<pubDate>Tue, 03 Mar 2009 06:25:13 +0000</pubDate>
		<dc:creator>Ray Acayan</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[Boost]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[Consulting]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[QuantLib]]></category>
		<category><![CDATA[QuantLib-SWIG]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[SWIG]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.rayacayan.com/blog/?p=253</guid>
		<description><![CDATA[I. Overview Part 1 of this project describes my procedure for installing a dedicated QuantLib web application server based on Linux and Ruby on Rails. QuantLib is a free open-source software library for quantitative finance, financial modeling, trading, and risk management. Written in C++, this library is typically used in standalone applications at financial institutions. [...]]]></description>
			<content:encoded><![CDATA[<p></br></p>
<h2 style="color:darkblue">I. Overview</h2>
<p><a href="the-quantlib-ruby-project-part-1">Part 1</a> of this project describes my procedure for installing a dedicated QuantLib web application server based on Linux and Ruby on Rails.</p>
<p><img src="/blog/img/QuantLib.png"></img></p>
<p>QuantLib is a free open-source software library for quantitative finance, financial modeling, trading, and risk management.  Written in C++, this library is typically used in standalone applications at financial institutions.  This project shows how the powerful features of QuantLib can be implemented in web applications.  This capability allows firms to outsource their internal financial software development in favor of modern QuantLib web applications hosted by external application service providers (ASPs).</p>
<p>Ruby on Rails is a popular open source framework for developing web applications, and Linux is a robust and secure platform for hosting them.<br />
<br /></br></p>
<h2 style="color:darkblue">II. Consulting</h2>
<p>I do my best to explain the concepts and techniques behind my projects.  If you like my work and can use my expertise in your projects, I am available for <span id="consulting_page" onmouseover="consulting_mouseOver()" onmousemove="consulting_mouseMove()" onmouseout="consulting_mouseOut()"><a href="http://www.RayAcayan.com/blog/consulting/"><strong>consulting</strong></a></span> at a competitive rate.<br />
<br /></br></p>
<h2 style="color:darkblue">III. Procedure</h2>
<p><strong>1. Install LAMP Server</strong></p>
<p>A basic LAMP (Linux, Apache, MySQL, PHP) server can be installed as follows:<br />
a.) Download the latest version of Ubuntu Desktop Edition (currently 8.10) from <a href="www.ubuntu.com">ubuntu.com</a>.<br />
b.) Burn the iso image onto a CD and boot the server with that CD.  Install with default options.<br />
c.) Install packages with the following commands:</p>
<div class="code">
$ sudo apt-get install apache2 mysql-server libapache2-mod-auth-mysql<br />
$ sudo apt-get install php5-mysql phpmyadmin<br />
$ gksudo gedit /etc/php5/apache2/php.ini<br />
   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;extension=mysql.so  <-- change this in php.ini<br />
$ gksudo gedit /etc/apache2/httpd.conf<br />
   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ServerName localhost <-- change this in httpd.conf<br />
$ sudo /etc/init.d/apache2 restart<br />
// install ssh, sftp, and Firestarter firewall<br />
$ sudo apt-get install vsftpd ssh sysv-rc-conf firestarter
</div>
<p><strong>2. Install Ruby on Rails</strong></p>
<p>a.) Install full Ruby from repository:</p>
<div class="code">
$ sudo apt-get install ruby-full build-essential libssl-dev libreadline5-dev zlib1g-dev
</div>
<p>b.) Download and install the latest RubyGems package manager:</p>
<div class="code">
$ wget http://rubyforge.org/frs/download.php/60718/rubygems-1.3.5.tgz<br />
(Note: See <a href="http://rubyforge.org/frs/?group_id=126">http://rubyforge.org/frs/?group_id=126</a> for the latest RubyGems version)<br />
$ tar -xzvf rubygems-1.3.5.tgz<br />
$ cd rubygems-1.3.5<br />
$ ruby setup.rb
</div>
<p>c.) Install Rails via RubyGems:</p>
<div class="code">
$ sudo gem install rails<br />
<br />
Note: If this doesn&#8217;t work, try:<br />
$ sudo apt-get install rails<br />
$ gem install -v=2.2.2 rails
</div>
<p>d.) Install Ruby MySQL driver:</p>
<div class="code">
$ sudo apt-get install libmysqlclient15-dev<br />
$ sudo gem install mysql
</div>
<p><strong>3. Install QuantLib</strong></p>
<p>a.) The Boost C++ libraries must be downloaded and installed first:</p>
<div class="code">
$ mkdir ~/install<br />
$ cd ~/install<br />
$ wget http://downloads.sourceforge.net/project/boost/boost/1.38.0/boost_1_38_0.tar.bz2<br />
$ tar -xjvf boost_1_38_0.tar.bz2<br />
$ cd boost_1_38_0<br />
$ ./configure<br />
$ make<br />
$ sudo make install
</div>
<p>b.) Download and install the latest version of QuantLib:</p>
<div class="code">
$ cd ~/install<br />
$ wget http://downloads.sourceforge.net/quantlib/QuantLib-0.9.7.tar.gz<br />
$ tar -xzvf QuantLib-0.9.7.tar.gz<br />
$ sudo ln -s /usr/local/include/boost-1_38/boost /usr/local/include/boost<br />
$ cd QuantLib-0.9.7<br />
$ ./configure<br />
$ make<br />
$ sudo make install
</div>
<p>c.) Download and install the latest version of QuantLib-SWIG.  SWIG (Simplified Wrapper and Interface Generator) is a tool that connects C/C++ programs with web programming languages such as Ruby, PHP, Python, and Perl.</p>
<div class="code">
$ cd ~/install<br />
$ wget http://downloads.sourceforge.net/quantlib/QuantLib-SWIG-0.9.7.tar.gz<br />
$ tar -xzvf QuantLib-SWIG-0.9.7.tar.gz<br />
$ cd QuantLib-SWIG-0.9.7/Ruby<br />
$ ruby setup.rb wrap<br />
$ ruby setup.rb build<br />
$ ruby setup.rb test<br />
$ sudo ruby setup.rb install<br />
<br />
Note: If these commands don&#8217;t work, try:<br />
$ sudo apt-get install quantlib-ruby
</div>
<p><strong>4. Test and Verify</strong></p>
<p>You should now be able to run the Ruby examples in QuantLib-SWIG-0.9.7/Ruby/examples:</p>
<div class="code">
$ cd ~/install/QuantLib-SWIG-0.9.7/Ruby/examples<br />
$ ruby american-option.rb<br />
$ ruby bermudan-swaption.rb<br />
$ ruby european-option.rb<br />
$ ruby swap.rb
</div>
<p></br></p>
<h2 style="color:darkblue">IV. Future Enhancements</h2>
<p>In <a href="/blog/projects/the-quantlib-ruby-project-part-2/"><b>Part 2</b></a> of this project, I will use this QuantLib Ruby platform to explore some simple design patterns used in developing QuantLib web applications for quantitative finance.<br />
<br /></br></p>
<h2 style="color:darkblue">V. References</h2>
<p><strong>1. Ubuntu.com</strong><br />
<a href="http://www.ubuntu.com/">http://www.ubuntu.com/</a></p>
<p><strong>2. RubyOnRails.org</strong><br />
<a href="http://rubyonrails.org/download/">http://rubyonrails.org/download/</a></p>
<p><strong>3. QuantLib.org</strong><br />
<a href="http://quantlib.org/extensions.shtml">http://quantlib.org/extensions.shtml</a></p>
<p><strong>4. SWIG</strong><br />
<a href="http://swig.sourceforge.net/">http://swig.sourceforge.net/</a></p>
<p></br><br /></br></p>
]]></content:encoded>
			<wfw:commentRss>http://www.RayAcayan.com/projects/the-quantlib-ruby-project-part-1/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

