AWS: The Complete Guide to Setting up a Simple Webserver

In short, I got sick and tired of paying $700/month for a cabinet in a datacenter and hosting my own servers. The failover was never REALLY truly redundant and my firm is just too small to justify hosting its own infrastructure. I’ve never been a fan of hosting services because I’ve always found them too limiting. I consider myself to be a damn good systems administrator and not having access to router configs and having root access to the machines were nonstarters for me. I’m set in my ways.

While my experience so far has been excellent, there are a number of pitfalls that you need to be aware of, and I will be sure to address those towards the end. This guide is intended for non-technical people to do very technical things so expect a LOT of explanation.

Sign up for Amazon Cloud Services

First, go to and create an account. You’ll have to enter your billing info, but as long as you stay within the free tier, you won’t be charged anything.

Set up your virtual machine

Next, you’ll want to create an EC2 instance. AWS Free Tier gives you 750 hours per month of Linux or Windows EC2 Micro Instances. There’s roughly that many hours in a month, so as long as you only have one micro instance, you should be completely free. For 99% of small business websites, this is PLENTY, though Amazon does offer a variety of configurations!

1. Sign in to the AWS Management Console. It’s a link under the dropdown in the top right with the credentials you already created.
2. Click on EC2
3. Click the button marked “Launch Instance”.
4. Click “Classic Wizard” and continue.
5. Select a 64 bit Amazon Linux AMI type server. This is a CentOS based linux server for those who are curious.
6. Set the number of instances to 1 and make sure that you have Micro for the type. The availability zone shouldn’t make a huge difference unless you’re latency sensitive and you know where your users are concentrated. If this isn’t you, select “no preference” on the dropdown and continue. On the next page, all of the defaults are fine, so go ahead and hit continue again.
8. On the next page, you’ll have to give server a name. Give your server a name in value box next to name and hit continue.
9. In order to access the server from your local machine, you will need to create a key pair. This will become important later when we discuss how to connect to the server, but for now just enter a name under “Create a New Key Pair” and click “Create & Download your Key Pair”. This will download a .pem file. NOTE: THIS FILE IS IMPORTANT Put it somewhere secure and preferably backed up.
10. To set up the firewall of the server, we need to allow webserver and administrative related traffic in but block out anything that might be malicious. See the settings in the image below:
11. Click “Launch” and you’ll have to give it a few minutes while AWS runs off and builds your configuration.

While we’re waiting, I want to get one last step out of the way so that we’re on top of things for what’s next. If you go to the instances menu item on the left, you’ll bring up a list that contains your server. Clicking on the server instance will bring up some information about your server on the bottom. Scroll down to “Public DNS” and copy the value to the right of it. You’re going to be using this address quite a bit. If you have registered a domain that you want to point to this server, now would be the time to do it. Go to your domain registrant and paste the Public DNS value into wherever your forwarding to. I host through godaddy, so I went to my DNS manager and changed the “@” record to the copied value.

Now let me explain a bit about what you’ve done so far. Those with a technical background can skip to the next section.

A virtual machine is a piece of software that emulates a computer’s hardware. You can put any operating system on it and it will just run. Virtual Machines are great for things like creating software testing environments because you can very quickly set up a “brand new clean” virtual machine, perform whatever tests you need, then throw it out and start fresh. You can vary hardware configurations such as memory, processor architecture, and hard drive size relatively easy. Amazon EC2 instances are virtual machines with public IP addresses that can be accessed from the internet, so they are ideal for our purposes. So far you’ve created a virtual server and made note of its public address, possibly hooking it up to a domain if you have one.

Get Connected to your VM

I’m running a mac using parallels, so I can explain how to connect your server to both environments. In my windows environment, I use WinSCP for file transfers and Putty for shell access. So go ahead and download both of those programs first. Next, dig up that .pem file that I told you was super important. You’re going to have to do a bit of work to get that .pem file to work with putty because it can only really use its proprietary format (don’t ask me why).

1. Open PuTTYgen.
2. Find .pem file. Click Conversions -> Import key.
3. Open the PEM file. The Key pane should populate with a public key, private key fingerprint, comment, and passphrase.
4. Change the comment from “imported-openssh-key” to whatever you named your key pair in step 9 above.
5. Pick a passphrase and click “Save private key.”
6. You’re going to store your key in a timesaver called Pagent, so go ahead and open it. When you open Pagent you’ll just see a new icon in the systemtray.
7. Right click on the new icon in the systray and click “Add Key”
8. Open your PPK file that you created with PuTTYgen and enter the passphrase you created.
9. Close the window
10. Grab the address of the server. Open Putty and paste the public address you copied into the Host Name input.

For Winscp, you’re just going to click the “new” button, and enter all of your hostname and login credentials like you did for Putty. There’s a “Private Key File” option that you’ll use to specify that same .PPK file that you created for Putty. After you’ve done this, go ahead and try to connect to browse the filesystem of your server.

On the mac side, I use the terminal to issue commands on the server. There’s a bit of set up involved to make it easy.
1. Take the key pair file (this is the .PEM, not the .PPK) and copy it to “/[your user id]/.ssh/”
2. Start up the Terminal application. I just go to the search bar and type “Terminal”
3. type “ssh ec2-user@[your server's host address]“. The command will ultimately end up looking something like this: ssh

Get services running on the VM

Now that our server us up and running and we have access to it, it’s time to issue a bunch of linux commands. I’m going to tell you what they are, then explain.

1. Connect to your server either using putty or mac terminal. The default login is ec2-user
2. Type in (“run” for future reference) sudo su. This will switch users to the root user. The root user is allowed to do whatever it wants whereas when you logged in as ec2-user, you’re highly restricted. If you’re on a PC, you can just copy the command text from here, go into your putty window and right click.
3. yum update – yum is a package manager. It connects to a repository of all of the latest greatest software available for this installation of linux and installs whatever software pacakges you tell it to. Think of it as the equivalent of windows update on steroids.
4. yum install httpd mysql mysql-server php php-mysql php-xml php-pdo php-odbc php-soap php-common php-cli php-mbstring php-bcmath php-ldap php-imap php-gd nano sysstathttpd is also known as Apache. It’s a webserver that will ultimately serve up your html pages and php scripts. MySQL is a database server that will be required by our later installations of drupal and wordpress. PHP is a very powerful scripting language that is required by wordpress and drupal. It’s an interpreted language that outputs text (html, css, javascript, or whatever you tell it to really) to a browser. Nano is a text editor that we’ll use when we’re not editing files in winscp. Sysstat is used to get system monitor like information.
5. Fire up the webserver by running service httpd start
6. Fire up the database server by running service mysqld start
7. Let’s create a user ID and password for the mysql server and then restart the service mysqladmin -u root password [new password] and then run service mysqld restart
8. Test everything out to make sure that it worked. cd /var/www/html/
nano index.php type in <?php phpinfo(); ?> and then CTRL + O then CTRL + X. Now open a web browser and navigate to your hostname (if you’ve already forwarded your domain here, go ahead and give that a shot). The page should open with detailed information about your php settings.
9. [Optional] To make your life easy from a permission standpoint, it can’t hurt to make some folders easily accessible by ec2-user so that you can copy and run from your webserver. chown -R ec2-user /var/www

Install web software

In this section, our ultimate goal is to install a CMS such as wordpress or drupal, but first we’re going to make our lives easy from a database standpoint by installing phpMyAdmin.

1. Go ahead and download phpMyAdmin from the link above. Unzip into a folder and copy that folder to /var/www/html/ using winscp (or a copy command if you’re on a mac).
2. Change the name of the folder to something you can remember. “db_admin,” for example.
3. From a web browser, navigate to the folder you just installed. “,” for example.
4. PhpMyAdmin will allow you to create databases, which will be used by wordpress and/or drupal. You can create the databases now, but I would actually recommend waiting because web software will usually create the databases for you.
Screen Shot 2013-05-06 at 10.16.26 AM
5. Using the steps above, follow this exact procedure to copy wordpress and drupal to their own folders. The installations themselves are pretty self explanatory, but if you need help I might be talked into doing a step-by-step guide for each of those.

Optimize Machine

I had this really nasty issue of the virtual machine running out of memory and mysql blowing up and crashing. I made some changes to my my.cnf file that made the installation significantly more stable but I was still left feeling like I wasn’t leaving myself enough room for error, so I also created a swapfile just to put my mind at ease.

You’ll want to navigate to /etc/my.cnf and open in an editor. If you login as root (sudo su just like before) you can edit in nano, or you can use chown to allow you to edit the file in winscp as ec2-user. The changes I made to my my.cnf file are as follows:

# Set internal buffers, caches and stacks very low
key_buffer = 320K
table_cache = 10
sort_buffer_size = 320K
read_buffer_size = 320K
read_rnd_buffer_size = 24K
net_buffer_length = 24K
thread_stack = 320K

innodb_buffer_pool_size = 10M

To add a swapfile, issue the following commands in this exact order:

sudo dd if=/dev/zero of=/var/swapfile bs=1M count=2048
sudo chmod 600 /var/swapfile
sudo mkswap /var/swapfile
echo /var/swapfile none swap defaults 0 0 | sudo tee -a /etc/fstab
sudo swapon -a

Options. In English [Part 2]

I wrote the first installment of this series over two years ago, promising to explain the practical ramifications of the the basics that I’d covered using the tools of the trade. After enough procrastinating, I’ve finally gotten around to doing the second installment.

Questions Answered

Before I begin I wanted to address a number of questions that were emailed to me between my last options article and this posting. If you have any other questions, shoot me an email. justin [dot] braun [at] scaleddynamics [dot] com.

Q: What are some different risk management styles?  Especially ones that would make options more attractive than futures.

Managing risk is ultimately looking at your trading strategy and asking “what can go wrong?”

A popular strategy for day traders is to make sure that they go home flat (not have a position on) every night. Historically, this would limit the amount of money they can lose by avoiding price gaps between sessions. Many exchanges place daily price floors and ceilings on how far a tradeable instrument can move from its opening price (or in some cases, previous day settles) in a day. Further, the less time you have a position on, the less opportunity you have to lose money. High frequency traders take this to the extreme, trying to hedge or even take profit from a trade microseconds after a position is put on. Options are significantly less liquid and with the exception of trading deeps against futures, exiting positions every day would require the trader to give up an unrealistic amount of edge.

If you’re long options, these limits are built into how little the option can decrease in value. Buying a combination of puts and calls will typically yield a long volatility position. With a long volatility position you will lose money in the form of theta decay every day as the time value of the position diminishes, but make money during large price moves or during increases in volatility. The advantage of such trades are that your capital-at-risk is roughly equivalent to the price of the options you purchased, and watching your erosion is a daily expected occurrence.

If you’re short options, time is literally on your side in the sense that you collected a cash premium for something that will diminish in value every day….. or go in the money and cost you a fortune. Writing premium (or selling calls and/or puts) is a very risky  proposition, but it will pay you consistently… until it doesn’t.

Q: How important is it to know the actual math behind the greeks? 

Not at all!! If I were asked to explain the math that goes into any of the models I write about, I’d be immediately exposed as a quack! I can only add, subtract, multiply, and, on a good day, divide. With that said, my customers can attribute millions of dollars of profit to the systems I’ve built. What is important is a qualitative understanding of the meaning behind each greek and how a given action (getting a fill, change in underlying, change in volatility,passing of time, change in interest rates) will change your position and exposure.

Q: How is Implied Volatility calculated?

Most options models use a partial differential equation to calculate their values, meaning that the equations are unidirectional. You can’t get the inputs from the result. Since volatility is an input, you need to take a guess what the volatility is most likely to be, and then search for the correct value by moving inputs up and down until you get the right value. This is very computationally expensive, but not as bad as it sounds. The Newton Rhapson method is the most commonly used way to search for the correct values in an efficient manner.

In practice the better your first guess is, the smaller a net the algorithm has to cast to search for the proper value. You might search for a known volatility of a nearby strike, or a previously known volatility, for example.

Setting up a Trade

From the beginning, the power of options are that they give you significantly more control over how much exposure you wish to obtain, and they allow you to make bets on more than just direction. Unlike futures, fair value is stupid-easy to calculate. You choose an underlying instrument, pick a pricing model, and voila, you have fair-value. None of the nuances of the multitude of models out there matters close to expiry and/or near-the-money. While nothing stops you from having one and trading based on it, an opinion about whether the underlying market will go up or down isn’t necessary.

To that point, say that you have no clue whether the price of gold is going to go up or down, but you do think that the market is a bit too quiet compared to other commodities. You think that regardless of what happens, gold is in for a big change in price, but you’re not sure what direction it’s going to move. The trade: Buy Straddles or Strangles.

A Straddle is the buying of a call and put at the same strike price, and a Strangle is the buying of a call and put at different strike prices. The difference is that the capital at risk of a strangle is a fraction of that of a straddle, and the comparative payout is larger as well.

As of this writing, gold is trading at around 1465. The June 1465 calls and puts are trading around roughly 35 at approximately 21.3% volatility. Let’s plug this into the formula engine inside of SD Gatekeeper and simulate what a straddle trade might look like.

Formula Audit

First let me explain how my formula engine works. Each function outputs the result of a calculation with various arguments. I can either use static values for arguments, or pull directly from an instrument feed. In this example, I am doing a combination of both, pulling the strike price and expiration date directly from the Jun13 1465C instrument, and setting the futures (underlying), interest rate, and volatility manually. Using the same inputs, the following formulas produce the following values:

B76.Price.Call(Future: 1465, Strike: Primary.Strike, Rate: Rate, Time: Primary.YearsToExpiry, Volatility: Volatility) = 35.36

B76.Price.Put(Future: 1465, Strike: Primary.Strike, Rate: Rate, Time: Primary.YearsToExpiry, Volatility: Volatility) = 35.36

B76.Price.Call(Future: 1470, Strike: Primary.Strike, Rate: Rate, Time: Primary.YearsToExpiry, Volatility: Volatility) = 37.97

B76.Price.Put(Future: 1470, Strike: Primary.Strike, Rate: Rate, Time: Primary.YearsToExpiry, Volatility: Volatility) = 32.98

(38+33) - (35.4 + 35.4 ) = .2


Assuming that you could buy both put and calls at 35.4 (gold options tick in .1) when the futures were at 1465, and assuming that you could sell them at 38 and 33, you’d have locked in a profit of .2 (or 2 price increments) on a $5 price move in the underlying.

Now let’s see what that same move would look like with a Straddle. This time we’ll buy a call and put that are $5 out of the money.

B76.Price.Call(Future: 1465, Strike: 1470, Rate: Rate, Time: Primary.YearsToExpiry, Volatility: Volatility) = 32.98

B76.Price.Put(Future: 1465, Strike: 1460, Rate: Rate, Time: Primary.YearsToExpiry, Volatility: Volatility) = 32.86

B76.Price.Call(Future: 1470, Strike: 1470, Rate: Rate, Time: Primary.YearsToExpiry, Volatility: Volatility) = 35.48

B76.Price.Put(Future: 1470, Strike: 1460, Rate: Rate, Time: Primary.YearsToExpiry, Volatility: Volatility) = 30.56

(35.5+30.6)-(33+32.9) = .2

In both cases, a profit of .2 was locked in however the picture is not so simple. First, the strangle position cost less to purchase (70.8 vs 65.9) so the returns of the straddle are larger. Further, in the example shown I was using a flat volatility of 21.3%. In real life, volatility changes from strike-to-strike. When viewed on a graph, volatility tends to have a specific shape.


The green line in the middle represents where implied volatility is at each strike. Note that the line slopes slightly down to the right (higher strikes). This means that the options will get cheaper as prices increase. In this case, you’ll make more money on a break in the underlying than you would a rally.

In my next installment, we’ll cover how changes in volatility will affect this trade, discuss more strategies, and if I’m feeling super ambitious, we’ll even do some real execution.

Walk for HD – May 19, 2013

While most of this blog has been about self-improvement and making more money, today I want to talk a bit about Huntington’s disease. According to Wikipedia,

Huntington’s disease (HD) is a neurodegenerative genetic disorder that affects muscle coordination and leads to cognitive decline and psychiatric problems. It typically becomes noticeable in mid-adult life. HD is the most common genetic cause of abnormal involuntary writhing movements called chorea, which is why the disease used to be called Huntington’s chorea.

The disease is hereditary. It is not contagious and doesn’t spread due to infection, but rather it is passed down from one generation to the next. The Huntington’s gene is dominant, meaning that if one of your parents has it, you will have a 50/50 chance of being born with it as well.

The following is a MASSIVELY oversimplified explanation of how Huntington’s works: DNA has four kinds of nucleotides that comprise its “code.” They are guanineadeninethymine, and cytosine, represented as letters G,A,C,T. My understanding is that people with Huntington’s disease have too many expressions of GAC in a certain part of their 4th chromosome. That repetition of GAC is more or less an instruction for the body to make a protein that prevents nerve cells from doing their job. These proteins build up in the body over time and people begin to show symptoms as they age.

There is a ton of great research and even the possibility of a new treatment that can “reset the clock” on Huntington’s; but actually getting to the point where it becomes a viable treatment is a ways away. This is worrisome to me because the disease only really affects 30k people in the US. Compared to heart disease, cancer, and other number one health related killers in the US, my worry is that new treatments could get lost in the political red tape required to get drugs approved in this country.

As a result, my firm, Scaled Dynamics, is participating in a fundraiser to promote Huntington’s Disease treatment and research. Scaled Dynamics will match any money that my employees wish to donate from their paychecks. All of the proceeds will go to the Skewes, Vasquez, and Young HD Fundraising Page where they will ultimately go to the HSDA. You can read about the HSDA and their work here.

If you would like to donate, or would like to walk with us, please find this information below:

The Illinois Chapter of the Huntingtons Disease Society of America presents the 9th Annual TEAM HOPE WALK!  Help us to continue funding the mission of the Huntingtons Disease Society of America!  The past 8 Walks have helped raise over $375,000!  NEW THIS YEAR!!!! The Walk has been moved to the Naperville Riverwalk in downtown Naperville, Illinois.  The Riverwalk offers a walker, wheel chair, wagon, and stroller friendly path.  Dogs are very welcome as long as they remain on a leash.  The Riverwalk is WELL shaded.  Please remember to bring enough non-alcoholic drinks for yourself as well as any dogs you bring along.  After the Walk, stick around for our family style hotdog lunch (be sure to bring your lawnchair), games for the kids, and great conversation with friends. The Riverwalk also offers a playground for the young ones that attend as long as their parents are with them.  We will start at the Grand Pavillion at the far west end of the “Beach” parking lot.  We hope to see you there!!  More information can be found on our chapter website at

Date Sunday, May 19, 2013
Location Naperville ,  Illinois
Contact Dave Hodgson


About the HSDA:

The Huntington’s Disease Society of America is the largest 501(c)(3) non-profit volunteer organization dedicated to improving the lives of everyone affected by Huntington’s Disease. The Society works tirelessly to provide the family services, education, advocacy and research to provide help for today, hope for tomorrow to the more than 30,000 people diagnosed with HD and the 250,000 at-risk in the United States. The Society is comprised of 45 local chapters and affiliates across the country.

Update: Apr 27, 2013: I’ve just been made aware that t-shirts are also available here