Archive for category For Developers
Installing a LAMP server in the Amazon EC2 cloud
Posted by Adam in For Developers on January 24, 2011
The Decision to move to Amazon
From 2008-2010 I hosted my own Ubuntu server that handled all of my web hosting needs, as well as well as taking care of MySQL, CoucheDB, Subversion, and a few other needs. This server was where I hosted all of my personal projects, the main, Casa Nova Designs site and this blog. As time went on there were several issues that lead me to want to move my server to the cloud.
Bandwidth
My server was hosted on a business class cable connection, and it was difficult to justify purchasing a better connection given the amount of traffic that I was generating. I did want a better connection so my access times would be faster, and Amazon definitely had that capability.
Scalability
Amazon allows you to scale up the resources you are using without physically purchasing machines, they charge by the hour for usage so you only pay for what you use, if you get a spike in usage in the morning and usage tapers off you can easily scale back what you’re using without wasting resources.
Freedom to experiment
Because you can launch virtual machine instances easily and also kill them easily you can easily fire up an instance to take a new operating system, server, program etc for a spin, when you’re done you can kill it, and only pay a small amount for the learning experience. Traditionally this would require much more overhead or it would require you to run a virtual machine on a local machine that may or may not have the necessary resources to do a proper real world test.
Moving From our LAMP server to EC2
First things first
In order to use Amazon Web Services you’ll need an Amazon account. You can create one at aws.amazon.com after you’ve created an account you’re ready to begin.
Launching an Instance
Amazon Web Services servers are instances, instances are virtual machines that are hardware independent.
Selecting an Image
Instances are instantiated with images (AMIs), images are snapshots of virtual machines that come preconfigured to perform a specific task. Amazon has thousands of images to choose from, and once you’re up and running you can save your running instances as images, this is handy for numerous reasons, you can use them to save templates for new instances (generic web servers, db servers etc) or to back up a running instances at a specific state. Ubuntu maintains images of their latest version as well as their long term service releases, so it’s easy to get an Ubuntu machine up and running. You can find a list of the latest Ubuntu images at http://uec-images.ubuntu.com/releases/ and Ubuntu’s documentation for getting ubuntu up and running at http://www.ubuntu.com/cloud/public/deploy .
Setting Instance Details
At this point you can select what kind of resources you want your instance to have access to. Obviously the larger the instance you run the more expensive it will be per hour. Amazon has a large number of instance types available for selection, everything from very small machines for low traffic usage to GPGPU clusters and HPC clusters. You can read more about the instance types that are available at http://aws.amazon.com/ec2/#instance. On the next screen you will be asked to name the instance, you can also store other tag information here for your use.
Creating a Key Pair
At this point you will be asked to select or create a key pair. Amazon uses key pairs to authenticate ssh logins and for other api requests. You will need to create a key pair if you want to be able to access an instance.
Configuring a security group
Amazon allows for the creation of security groups, which are basically firewall templates, using this facility is how you set which ports will be accessible to the outside world. I haven’t ever needed to stray from the default security group but your mileage may vary.
Ready Set Go
After you’ve completed all of the configuration you’re ready to launch your instance. This may take a few minutes depending upon the size of the image you’re launching (I assume that because Amazon may have to move image information over the network that that is why this process takes so long sometimes).
Connecting and Setting up LAMP
Set IP and DNS
Initially Amazon allows you to access your machine via a global domain name that they provide, but they do not give it its own IP. I planed on running this particular instance as a web server so I went ahead and took care of that first. First go to the configuration page for elastic IPs, the link is titled “Elastic IPs”, create an elastic and associate it with the AMI you just created. Set your DNS servers appropriately to point to this IP.
SSH in
Amazon requires you to use shared keys to connect to their servers, remember that key you downloaded earlier? Now’s the time to use it.
ssh -i casanova-key username@example.com
Once you’ve connected to this machine, you can install the LAMP stack run
sudo tasksel --section server
Now select the packages that you’d like to install (LAMP server obviously) and hit ok. You now have a LAMP server installed!
Future Articles
Getting a LAMP server up and running is only the first step, there are various tools to manage your Amazon AMI instances, and the scaling of your webservers and MySQL servers. I have had some experience with this in the past few weeks as this blog has begun to develop a larger following. I plan to write up more about this issue in the future.
Regards,
Adam
OS X keyboard shortcuts for Ubuntu
Posted by Adam in For Developers on January 22, 2011
The Problem
I’ve been using both OS X and Ubuntu for about a year now. I started using Ubuntu almost 5 years ago as my primary operating system. I didn’t think that I’d ever need to change to anything else, until the University of Tennessee and the NSF were kind enough to buy me a Mac Book Pro. As someone who always considered himself a Linux user I was surprised at how much I loved my OS X machine, in fact, I found that I loved the Emacs style keybindings that it had to offer. In OS X you can type Ctrl+A to go to the beginning of a line, Ctrl+E to go to the end of a line and Ctrl+K to kill a line. I use Emacs everyday and having these key bindings in other applications just feels right to me.
An Easy Fix
I posted a question about how to solve this problem on Reddit and received a quick response.
Changing Ubuntu Keybindings
Install gconf-editor
In a terminal run:
sudo apt-get -y install gconf-editor && gconf-editor
When the configuration editor opens go to desktop > gnome > interface > gtk_key_theme and change this value to “Emacs”
Once you close the editor you’re done setting changing the key bindings for Ubuntu!
But what about Firefox?
If you use keyboard shortcuts religiously like I do, you’ll quickly notice that Ctrl+K doesn’t work in Firefox any more and you have to grab your mouse to do a Google search (gasp!). This is an easy fix too. In the location bar in Firefox navigate to about:config and change the ui.key.accel value to 224 to use the meta key (Command key on a Mac keyboard like I’m using) , 18 to use the alt key, or 17 to use the ctrl key. More information about customizing firefox can be found at http://www.mozilla.org/unix/customizing.html.
Wasn’t that easy?
Thanks to this simple change my Ubuntu machine is much more usable and intuitive. Do you have more Ubuntu keyboard shortcut tips? Please share them in the comments.
Thanks,
Adam
Local web development vs remote web development
Posted by Adam in For Developers on January 12, 2011
Local Workflow
There are two primary development workflows web developers use. One option is to install all necessary servers, libraries, databases etc on their working machine, do their editing their and then push the changes (hopefully through some sort of code revision system, but often through ftp) to the production server.
Pros
- Ability to work without network connection
Cons
- You must install entire server environment on your personal machine, this may be a bad thing for a laptop with limited resources
- You have to keep your working machine’s environment up to date with the versions the server is using
- You usually won’t want to keep a test dataset in a database on your working machine so you’ll need to make a remote connection to your db server ANYWAY eliminated the ability to work without a network connection
- To show clients the current version you have to push changes to a server.
Remote Workflow
Some developers choose to set up a development server (which can either be a separate machine or simple a separate subdomain on the production server). Their code lives there, when they make changes on their working copy there (again, hopefully using some sort of code revision system like subversion or git). This model allows you to run code in an environment more similar to what it will actually be run on in production. It also allows you to allow collaborators, backers or clients to view the current working copy of the code. You obviously don’t want to be working on the code for a production site (you aren’t that good, you will break things, and for a site with any reasonable amount of users this is unacceptable), but this model works well for working on development code.
Editing code that lives on a remote server. The simplest solution for editing code on a remote server is to ssh in the machine and use a command line editor such as vi, emacs or nano to edit the code. This is somewhat distasteful to some developers especially those who are used to GUI text editors. SSHFS allows a developer to mount a directory on a remote machine as a directory on their local machine in a way that is transparent to the operating system. This is an ideal solution because it allows you to edit code with the tools you’re used to using. We plan on making a blog post about how sshfs and autofs make web development easier, but until then check out google for info about them.
Pros
- Code is run on an environment more like what it will be in production
- Database connections are easier
- It is easy to show clients the code you’re currently working on
- It is often times easier to push changes to the production version of the site
Cons
- Network connection is required to do work
- Requires setup to edit code on your local machine while it is on the remote machine
- This problem is relatively easily solved, we’ll discuss this issue in a later post
Conclusion
Here at Casa Nova Designs we have found the remote workflow meets our needs and allows for more rapid development. This article is the first in a series about what our development environment is like, and how we’ve solved common web design head aches to streamline our workflow. In the next article we’ll show you how to use sshfs and autofs to mount remote file systems.
Regards,
Adam
Computer Science for Web Designers, 3 great resources
Posted by Adam in For Developers on December 1, 2009
Who Wants to Be a Computer Science Major?
For those of you who don’t know. I’m a Computer Science student at the University of Tennessee Knoxville. I got into web design before I was in college and I’ve found throughout my academic journey that being a good C/C+/Python programmer has led me to be a good PHP/javascript programmer. I love web design because it’ s not entirely scientific, it’s much more people based, but often times when we as web design professionals must design highly scalable websites, or websites that need to be easily maintained it is neccassary that we be familiar with Computer Science principles and be accustomed to the general thought process of a Computer Scientist. I whole heartedly believe that as you grow to be a better academic programmer you will grow to be a better web professional. For those of you who have already left your college days behind you I’ve compiled a few wonderful resources for begining your journey into the realm of academic computing.
![]()
Located at: http://code.google.com/edu
Google code is a wonderful resource for web designers because Google’s business is web, but it’s methodology is very academic. Google’s code university is a great way to keep up to date with the new and innovative things happening at google.
Located at: http://ocw.mit.edu
MIT, one of the world’s premere universities for Computer Science has graciously opened up their lecture halls to the masses. They’ve included everything from introduction to computer science to some of their much more advanced courses.

http://academicearth.com
Academic Earth is a wonderful resource for all subjects. It’s computer science courses include lectures from top schools such as Berkley, Stanford, and MIT.
What to Take Away
Some of the lectures included material that is at a graduate level, unless you’re particularly interested or talented don’t expect to understand everything that’s talked about in these courses. Remember YOU aren’t being graded over this information and even if you only understand 40% of the material that’s it’s still going to help you as you approach your day to day problems and stretch your thinking into new directions. I hope you find these resources helpful, happy coding.






