Posted on August 28th, 2012 No comments
You know you love Google’s #1 product… their impressive Google web search. If you’re like me, you use it hundreds, if not thousands of times a day.
You can use Google Search Operators, also called Google Search Modifiers, and they even offer users a whole page of Google Search Tips., including tricks like searching for recipes, using the calculator functions, and lots more.
But as good as Google’s search box is, there’s always room for improvement. Here’s a list of new and improved Google Web Search features I’d like to see. If you agree with these great feature additions I’ve suggested below, or if I forgot any, leave me a comment! I know I’d use them for sure!
Top 10 Ways Google Can Improve Search
10. Starting with something boring and annoying, how about a Tax Forms search? The one at irs.gov is alright, but let’s face it, the government could use Google’s help. The Google search 1040 site:irs.gov year:2011 type:pdf should bring up the obvious result I am after. It doesn’t. Google could help me spend even less time on the IRS website than I do already, which would be a very good thing.
9. Music Search. There’s no way to search music available in iTunes, without launching iTunes. I love music, but the search capability of iTunes and other music programs is terrible. Let me flag a song or album for later, like a wish list, and remind that I liked it. Integrate with all the streaming services like Pandora, Slacker and such. Give me Search Operators like artist:justin+bieber or label:interscope or genre:thrash+metal. (That’s three different search examples.)
8. Melodic Search. Create a musical instrument interface with which to perform song searches. As a play-by-ear pianist, I can never remember the lyrics or the names of songs, but I can play the notes! Let me play notes on an on-screen keyboard, or with my attached Midi keyboard, and find music matching the musical notes I am playing. For example, if I play C . . G C . . G C G C E G –> Google should pull up Mozart Eine Kleine Nachtmusik. This is easily implemented with widely available MIDI data.
7. Advanced Video Search. To perform an Advanced Video Search on Youtube now is an exercise in aggravation. An advanced YouTube search that worked would be really cool. Give me all the fields as operators, too, like views:1M or maru type:video views:2M..5M by:views ord:desc. This should show me maru clips between 2M and 5M views ordered by views descending. This search actually returns an incredibly random assortment of useless junk.
6. Expert Search right from the Google.com home page. Upgrade the advanced search operators, giving power users like me the utmost flexibility. For any input field on the advanced search or advanced image search, create an Advanced Search Operator for it. For example, why can’t I find cat exact:lolz type:gif w:128 h:128? I clearly am after an exact search of funny cat gif icons. I should be able to easily guess the “colon operator” for any advanced search field, and why not show me what it is when I hover over it on the advanced image search form so I don’t have to go find an obscure help doc on a different website on performing an advanced Google search.
5. Create Search Templates — Let me save and share advanced search filters and advanced images search filters and use them for later. For example, it can take a few minutes to set up a good advanced images search. Why not let me store the following for easy retrieval… for example (site:a.com OR site:b.com OR site:c.com) (type:jpeg OR type:png) (size:2mp..4mp). Clearly I am looking for jpg or png images betwen 2mp and 4mp on 3 specific websites. As a designer, if I could save those search parameters and re-use them, I could easily load it up, add a keyword, and save hours every year.
4. How about a Movie Search? Just buy IMDB.com , Blockbuster.com and RottenTomatoes.com and combine them. You know you want to. Your current Movie Showtimes Search is very embryonic. Is it too much to expect that type:movie (actor:judd+nelson AND actor:molly+ringwold) could find The Breakfast Club and 16 Candles? Results: ho-hum.
3. You can’t have a movie search without a Celebrity Search. It amazes me that I cannot set up an RSS feed for daily updates of Zoë Saldana jpegs that are at least 1280 x 1024. I clearly want wallpaper. Why not let me do celeb:zoë+saldana type:jpg size:2mp..
2. You’re obviously working on a Travel Search, otherwise you wouldn’t have bought ITA Software and Frommer’s. Are you ever going to improve Google Flight Search? I bet some readers don’t even know that exists. I hate every minute of making travel plans online, and since the internet killed the travel agent, I’m forced to do this on my own now, forevermore. Hurry up and fix it already!
1. Social Search. This is a no-brainer. I can’t search anything on Twitter, Facebook, LinkedIn, or even Google+. The state of social search is so incredibly dismal, it’s going to require an entire blog post all on it’s own. In short, if I’m logged into all of my social networks, I should be able to search them all with ease. They all provide APIs, don’t they? Don’t you have, like, fifty zillion programmers? Surely with all the work that went into Google+ you had to think about how to make all of that content searchable. It seems like the moment I link to something or share it, the sooner I can never find it again!
Now I hinted at this in #7 above, but how cool would it be to search the web with SQL? Or at least, using some SQL-like operands? By now millions of people use SQL on a daily basis, and certainly your search algorithms could be easily adapted to understand things like by:relevance ord:desc. (ORDER BY relevance DESC) or BETWEEN 2011-12-31 AND 2012-06-30? This reminds me that you could make it a lot easier to combine mulitple boolean operators. Only one or two work at a time. Why not let me use AND, OR and Parentheses? ( this OR that ) AND (brick OR brack). So I guess you could call this a bonus eleventh way Google could improve it’s search features. Call it Nerd Search.
Okay, there now, Googlebot, fans of Google, and other casual readers. What do you think?
Posted on June 2nd, 2012 No comments
A few years back, I found the iPhone app Runmeter. It keeps getting better, too, and is still one of the best $5 I ever spent. Very cool app. When you finish a run, skate or walk, it sends you a j.mp short link to a Google map of your exercise with all the stats it captured via GPS.
As a web developer interested in link shortening services, I instantly signed up to use j.mp to shorten my links.
Even though around September of 2009 bit.ly encouraged their users to switch to j.mp to make their URLs even shorter, they have now appeared to have tabled the j.mp brand along with the excellent j.mp sidebar. This wouldn’t be a big deal if the new bit.ly services were the same or better, but they’re far from it. The new bit marker is annoying and takes five times longer to shorten a link, tries to integrate with sharing sites for you and lots of other annoyances.
So they deprecated the j.mp sidebar, which as of the time of this writing is still working, but you cannot find it anywhere on the web! So frustrating.
To combat this problem, here are some instructions below — just sign up for bit.ly if you don’t already have an account, and follow the steps below.
bit.lyj.mp sidebar bookmarklet
Drag this link to your browser’s bookmark toolbar
bit.lyj.mp sidebar manual creation method
1. Create a new blank bookmark in your bookmark toolbar folder and name it j.mp sidebar (or bit.ly sidebar if you prefer)
2. Paste in the following for the URL
Posted on May 16th, 2012 2 comments
If you have a need to compile Memcache or wget on Mac OS X Lion and are wondering why you are getting the error
no acceptable C compiler found in $PATH
on Mac OS X Lion, you’re not alone.
Thanks to this post, I was able to fix my problem. Here are the steps.
- Run App Store
- Search for Xcode – it’s a free install from Apple
- Wait for awhile. Took 30min to download for me on a 20mbps connection
- Authenticate and let Xcode install. Once Xcode is installed you may be thinking you’re done. You would be wrong!
- Launch Xcode and run the mobile toolkit update (you can’t skip it, deal with it)
- Go to Xcode Preferences or press ⌘, (Command-comma)
- Click the Downloads tab -> Components list as shown below
- On the last row of the available downloads are the Command Line tools. Install them.
You should be good to go after that!
Posted on May 15th, 2012 No comments
I told you in a recent rant on this blog that I bought myself a new MacBook Pro.
It truly is a glorious computer; perhaps the best laptop on the planet. It’s blazing fast, ultra quiet, and it’s built like a Sherman tank, but is as sexy as a Ferrari. With Unix under the hood, Apache, PHP and MySQL preinstalled, it’s a web developer’s dream machine.
I always look forward to setting up a new computer for the first time, but instead of starting from scratch as is my normal approach, this time, I decided to use Apple’s built-in Migration Assistant.
How to use Migration Assistant to transfer files from another Mac is the name of KB article HT4413 at Apple.com. If you’ve already created your account on your Mac for the first time, but want to migrate a profile (your user account, applications and files) from a different machine or Time Machine backup, using Migration Assistant is the way to go.
But if you already created your login on your new Mac, read carefully:
Important info not obvious on Apple’s KB article
Using Migration Assistant, your old files will be copied to a new, alternate, secondary profile on your new Mac. In other words, if you logged in as ghoffman on your old Mac, and you already created a fresh, new profile ghoffman on your new Mac, you can’t use Migration assistant to get old ghoffman copied into new ghoffman. You can use Migration Assistant to restore ghoffman (old) to ghoffman2 or ghoffmanNEW or any other alternate named profile, just not the one you probably want.
If you have not yet created your user account on your new computer, or if you are willing to format your Mac and restore it to factory default settings, there is a little-known startup configuration mode when you first boot Mac OS X. It’s called Setup Assistant.
The first time you start up a new Mac, on one of the very first screens, even before entering your name for creating your account, you have the option of using Setup Assistant, which may be better named First-run Migration Assistant.
Using Setup Assistant at first-run is by far the fastest way to get going on a new Mac. I was extremely impressed at how simple and complete it was. Just like Migration Assistant, you have a several options as far as the source and transfer method, including using your other computer (as a disk in target mode) or from a Time Machine backup. I chose to use my Time Machine backup over FireWire 800. Other transfer options include USB, Ethernet and Wi-fi.
I was able to restore my Mac OS X Snow Leopard account on a 250GB MacBook Pro 17″ (Aug 2008) onto a new i7 processor 750GB MacBook Pro 17″ running Lion, in about 2 hours. Over 200 GB of data were restored, including my login username and password, all my keychain files, every document, every application – even Adobe Creative Suite, Microsoft Office, iTunes, iPhoto – everything! Even my ~/Sites folder for web development, with all my local MySQL databases, were perfectly restored.
I’ve really got to hand it to you, Apple. Not only is this laptop amazing hardware, but your software is extremely good, too.
Now I just need a new iPhone. And an iPad.
Posted on May 14th, 2012 No comments
I just got a new MacBook Pro with Lion installed, and I love it. I used the Setup Assistant (very similar to Migration Assistant) to transfer my account from my old MacBook Pro to my new one. The process was wonderfully simple, seamless and successfully transferred 99.99% of my files, documents, applications and settings.
After running Software Update to check for the latest system and software updates, I am told I need to download the Epson Printer Driver software update… for a whopping 922 mb!
Seriously, Epson? Sure, I have a fast connection, but not everyone does yet. Forcing your users to download a gigabyte of software when we own at most, one or maybe two of your printers? Why must I keep drivers for every printer you ever made on my computer? That’s just insane.
Your printers are pretty decent but your programmers are seriously lazy.
Here’s another way we end up paying more for everything.
The more printers Epson makes, the more code they stuff into their bloated driver download. The more we download, the more our ISP’s incrementally charge us for bandwidth.
It’s a printer for gosh sakes. Didn’t printer drivers used to fit on a floppy?
Posted on February 25th, 2012 No comments
Things I learned while attempting to build a custom WordPress plugin…
A) The documentation is far from clear.
B) There’s lots of ways of doing it
C) Many blog posts exist around the net with tutorials and examples, and many of them are outdated
D) Proper, logical coding practices and assumptions do not work.
E) You have to just mess with it until it works.
“The world is already flooded with blog posts about how great W3 Total Cache is and how terrific Super Cache is and how fantastic Bat Cache is. Surely one of these will work for me,” I think to myself.
But alas, I tested using each of these plugins on my site and none of them really did the trick. W3 Total Cache actually broke my theme completely and threw errors; Super Cache didn’t help much either. And Bat Cache was just complete rubbish. Discouraged, I decided to write my own plugin from scratch. So, off I go.
I’ll write a custom caching plugin that uses Memcache.
After a week of off-and-on development, I got my caching plugin working extremely well: What was up to 15 seconds is now sub 300ms! Same page, same WP Multi-site, one plugin with only about 300 lines of code. But it only works in a highly-controlled environment. I want to put it up on the WordPress site so others can use it, but before I can release it into the wild, I need to make sure it’s really polite about errors and easy to work with.
Specifically, I have these 3 simple goals to finish it up:
1) If you don’t have the Memcache extension installed when you try to activate the plugin, it needs to display a warning message about missing extension;
2) I want to use the standard h2 error message to display this error to the user; and
3) I want the plugin to remain deactivated if activation fails.
You would think the WordPress Codex, Plugin Resources and Plugin API Documentation would be chock full of great examples for Plugin developers, wouldn’t you? I did, too, but unfortunately this just isn’t the case.
I’ll give examples of A through E above, and hopefully explain how I was able to achieve the proper implementation points of 1, 2 and 3.
How do you handle WordPress Plugin Activation errors gracefully?
This post says to use the wp_die( ) function.
I tried that and it actually does prevent the plugin from getting activated.
This post suggests that you should just let the fatal error happen and display a slightly better error message in a status box. Terrible idea, IMO.
Better to use this. Render red error messages in h2′s like this post shows. I’m trying to combine these concepts into a single, elegant solution and having a real rough time of it.
I think the only way to do it is like HungryCoder says, you have to freaking ob_start and catch the error with output buffering…
Posted on February 18th, 2012 No comments
See, nobody’s perfect. Not even Facebook. (Ha! Far from it, right?)
I’m not able to post an update status at the moment. I thought I’d document it.
Not bad, though, Facebook IT team, I think you have, what, 99.9999% uptime?
Posted on February 4th, 2012 2 comments
Chances are you’ve heard of Memcache. Tons of websites use it to speed up page load times. I often say that Redis is like Memcache on steroids. You may not have heard of Redis, but if you’re using Memcache or APC, you should see how Redis could improve what you’re already doing. If you’re not using Memcache or APC yet, don’t bother – I urge you to take a look at Redis for a bunch of reasons.
First, Memcache is a key-value store only. You set a string value under a string key, and that’s it. With Redis, on the other hand, you have the luxury of several different types of data storage, including keys and values, but Redis also supports hashes, lists, sets and sorted sets.
An example to help explain why this is such a huge improvement. Say you have a big array of data, such as the kind that can come back from a web service request, like a parsed XML file or JSON packet. With Memcache, to store this in memory you have to serialize the data, often base64 encode the data, and then store it on the way in, and then to get a portion of the data back out again, you have to get the whole string, base64 decode it, deserialize it and then you can read from it. These extra steps needlessly chew up compute cycles.
With the same data object stored in a Redis Hash, for example, you can have instant access to the data stored in any key of the hash, you don’t have to grab the whole thing, deserialize it and all that mess. Just a single line of code, and boom, there’s your data. Much more elegant.
Another key reason Redis is superior to Memcache is that when you ask Memcache to store something, it’s in memory and that’s it. If your server goes down and you have to reboot, you have to repopulate your Memcache data over again. If your app has gotten huge, and your cache is huge, this can not only take awhile but puts a huge strain on your database server during this so-called “cache warmup” period. Unlike Memcache, Redis actually stores a copy of its data to a file on disk in the background, so if you stop and start your Redis server, it reloads everything automatically. It does this mind-blowingly fast, too, like millions of keys in seconds.
Finally, Redis supports master-slave configurations that you can use to build high-availability systems more easily. In the upcoming release (everyone is very eager for) Redis Cluster will support sharding out of the box!So, now that you want to dig in and start learning Redis, here are my…
Top 10 Redis Resources Online
NotesYou may be wondering about NoSQL and where Redis fits into this discussion. When people bring up NoSQL, I tend to think of MongoDB. Unlike Memcached and Redis, MongoDB is a general purpose document/object (think JSON) store that (strangely enough) allows you to use some SQL-like commands to retrieve subsets of your data. I think of Redis as a data structure server. You don’t use SQL to talk to Redis, so I guess it could be considered along with other NoSQL solutions. You can compare Redis to MongoDB by going to try.mongodb.org/
- Redis documentation: redis.io/commands
- Try Redis Online: try.redis-db.com
- Redis-DB Google Group List Archives: groups.google.com/group/redis-db
- Antirez (Redis developer Salvatore Sanfilippo’s) blog: antirez.com
- Recent blog posts about Redis: RSS Feed
- Q&A: stackoverflow.com/questions/tagged/redis
- The Little Redis Book – Just released openmymind.net/2012/1/23/The-Little-Redis-Book
- Slides from Redis Tutorial simonwillison.net/static/2010/redis-tutorial
- A Collection of Redis Use Cases www.paperplanes.de/2010/2/16/a_collection_of_redis_use_cases
- My GitHub Page. Chock full of Redis-related project forks. github.com/phpguru
- Bonus: Here’s a slideshow for a Redis 101 talk I gave if you’re interested.
Posted on January 19th, 2012 No comments
I’ve been running WampServer for years on my trusty Dell XPS running Windows XP Pro. A while back I installed Subversion and got it working with mod_dav and authz_svn to serve multiple repositories, each with their own user and group permissions. It was tricky to set up and there are some finer points that most documentation I read doesn’t address. I followed a few different web resources like this great beginners guide, but ultimately it boils down to the 5 simple steps below.
Just recently I needed to add a new repository. I thought I had done everything right, but when I went to use it for the first time, I got the following errors:
D:\svn\repos>svn mkdir http://localhost:8080/svn/myproject/trunk -m "Trunk" svn: OPTIONS of 'http://localhost:8080/svn/myproject': 200 OK (http://localhost:8080)
D:\svn\repos>svn ls http://localhost:8080/svn/myproject/trunk svn: URL 'http://localhost:8080/svn/myproject/trunk' non-existent in that revision
D:\svn\repos>svn ls http://localhost:8080/svn/myproject svn: Could not open the requested SVN filesystem
If you are getting any of these common errors, this post is for you.
When using svn over http, you have to use Apache’s configuration files to control access to each repository separately. Start by installing Apache, Subversion, and then referencing these three modules in your httpd.conf as follows:
LoadModule dav_module modules/mod_dav.so LoadModule dav_svn_module modules/mod_dav_svn.so LoadModule authz_svn_module modules/mod_authz_svn.so
Now we’re ready to begin.
1) Add the repository:
#> svnadmin create D:\svn\repos\myproject
*(On Unix systems, chown -R myproject so it is writable by the user Apache runs as)*
2) Edit your httpd.conf (or extras/httpd-vhosts.conf) adding something like this:
<Location /svn/myproject> DAV svn SVNPath d:/svn/repos/myproject AuthType Basic AuthName "My Project SVN Repo" AuthUserFile c:/etc/svn-auth-file Require valid-user AuthzSVNAccessFile c:/etc/svn-acl </Location>
3) Add the project to your svn auth file at c:/etc/svn-acl (it’s referenced in the Location directive in your Apache config.)
[groups] yourgroupname = yourusername, user_b, user_c
[myproject:/] yourusername = rw @yourgroupname = rw
This is what tells Apache which users and groups are allowed to access the path(s) in your repository.
4) Give yourusername an htpasswd (and user_b and user_c)
cd c:/etc/ htpasswd -c svn-auth-file yourusername
*(If that file already exists, omit the -c option)*
5) Finally, restart Apache
httpd -k restart
Then you’re ready to create trunk
#> svn mkdir http://localhost:8080/svn/myproject/trunk -m "Adding trunk" Committed revision 1.
I got the errors shown above when forgetting step one or more of these steps.
Posted on November 13th, 2011 No comments
I recently set aside an hour to read Robert Sosinski’s blog Starting Amazon EC2 with Mac OS X. What a fantastic guide that is! Thanks, Robert!
Hopefully he won’t mind my slightly modified mirror, below.
Starting Amazon EC2 with Mac OS X
Amazon EC2 (Elastic Cloud Compute) is now one of the top choices for cloud-based deployment. With EC2, you can ramp up to a massive server farm in a matter of minutes, while scaling back down to a single server when things calm down. The benefits are obvious, as you only pay for what you need and you have access to more computing power right when you need it.
EC2 works on the idea of server instances. You start with building one instance, which costs as low as a few cents per hour of operation, and you can even start free (with a t1 micro for a month!).
An instance acts just like a dedicated machine, with full root access and the ability to install any software you choose. You can chose from a variety of sizes and operating systems. An m1.small instance, for example, comes with some pretty competitive system specs including:
1.7 Ghz Xeon CPU
1.75 GB of RAM
160 GB of local storage
250 MB/s network interface
If your first instance gets some heavy traffic, EC2 can build another one automatically for another few cents an hour. Turnkey infrastructure has never been better.
First off, you have to set up your computer so you can connect to and administer your Amazon EC2 account.
If you don’t already have an account at Amazon.com, create one now.
1. Log into your Amazon.com account and then click over to the Amazon AWS subdomain and sign up for EC2. It will be linked to your Amazon.com account.
2. Once signed up, hover over the yellow “Your Web Services Account” button. Here, you should select the “AWS Access Identifiers” link.
3. Login, if prompted.
4. Select the “X.509 certificates” link.
5. Click on the “Create New” link. Amazon will ask you if you are sure, say yes. Doing so will generate two files.
A PEM encoded X.509 certificate named something like cert-xxxxxxx.pem
A PEM encoded RSA private key named something like pk-xxxxxxx.pem
6. Download both of these files.
What is PEM?
PEM (Privacy Enhanced Mail) is a protocol originally developed to secure email. Although rarely deployed for its indented purpose, it’s encoding mechanism for generating certificates is used for quite a few web services including Amazon EC2, PayPal Web Payments Pro and SSH Key Pairs.
7. Download the Amazon EC2 Command-Line Tools.
8. Open the Terminal, go to your home directory, make a new ~/.ec2 directory and open it in the Finder.
$ mkdir .ec2
$ cd .ec2
$ open .
9. Copy the certificate and private key from your download directory into your ~/.ec2 directory.
10. Unzip the Amazon EC2 Command-Line Tools, look in the new directory and move both the bin and lib directory into your ~/.ec2 directory. This directory should now have the following:
The cert-xxxxxxx.pem file
The pk-xxxxxxx.pem file
The bin directory
The lib directory
11. Now, you need to set a few environmental variables. To help yourself out in the future, you will be placing everything necessary in your ~/.bash_profile file. What this will do is automatically setup the Amazon EC2 Command-Line Tools every time you start a Terminal session. Just open ~/.bash_profile in your text editor and add the following to the end of it:
# Setup Amazon EC2 Command-Line Tools
export EC2_PRIVATE_KEY=`ls $EC2_HOME/pk-*.pem`
export EC2_CERT=`ls $EC2_HOME/cert-*.pem`
12. As you made some changes to your ~/.bash_profile file, you will need to reload it for everything to take effect. Run this:
$ source ~/.bash_profile
Creating and Connecting to a Server Instance
Launching an EC2 Instance from the Command Line on Mac OS X
Now that your computer is set up to work with EC2, it is time to make your server instance.
1. Type this into the Terminal.
$ ec2-describe-images -o amazon
What does the -o option do?
The -o option stands for owner. In this example, you are asking EC2 to describe the images that belong Amazon. To see every image available, give the -a option instead.
2. After a short wait, you will be given a list of available images which should look something like this.
IMAGE ami-20b65349 ec2-public-images/fedora-core4-base.manifest.xml
IMAGE ami-22b6534b ec2-public-images/fedora-core4-mysql.manifest.xml
IMAGE ami-23b6534a ec2-public-images/fedora-core4-apache.manifest.xml
IMAGE ami-25b6534c ec2-public-images/fedora-core4-apache-mysql.manifest.xml
IMAGE ami-26b6534f ec2-public-images/developer-image.manifest.xml
IMAGE ami-2bb65342 ec2-public-images/getting-started.manifest.xml
IMAGE ami-36ff1a5f ec2-public-images/fedora-core6-base-x86_64.manifest.xml
IMAGE ami-bd9d78d4 ec2-public-images/demo-paid-AMI.manifest.xml
Note that you can also do something like
$ ec2-describe-instances -a > ami-list-2011-11.txt
and then search the generated text file for platforms you might need, such as magento or wordpress:
$ cat ami-list-2011-11.txt | grep magento
3. Lets create something simple for now, a Fedora Core 4 machine with Apache. To do this, we need to generate a keypair. This keypair will supply the credentials we need to SSH (Secure Shell) into our server instance. To make a new keypair named ec2-keypair, type the following:
$ ec2-add-keypair ec2-keypair
4. This will create a RSA Private Key and then output it to the screen. You are going to copy this entire key, including the —–BEGIN RSA PRIVATE KEY—– and —–END RSA PRIVATE KEY—– lines to the clipboard. Now, go into your ~/.ec2 directory, make a new file called ec2-keypair, open it in your text editor, paste the entire key and save it.
5. Next, it is important to change the permissions of your keypair file, or else EC2 will not let you connect to it via SSH. To do this, just type the following in your ~/.ec2 directory:
$ chmod 600 ec2-keypair
6. Time to create your new machine. Ensure you are in your ~/.ec2 directory and type the following, substituting “ami-23b6534a” with the id of the image you wish to create.
NOTE: It is important to understand that once you tell EC2 to start creating your server instance, you will start paying 10 cents every hour until you terminate it.
$ ec2-run-instances ami-23b6534a -k ec2-keypair
RESERVATION r-xxxxxxxx xxxxxxxxxxxx default
INSTANCE i-xxxxxxxx ami-23b6534a pending ec2-keypair
7. It may take a bit for EC2 to start your new machine, but you can always check its status by typing:
RESERVATION r-xxxxxxxx xxxxxxxxxxxx default
INSTANCE i-xxxxxxxx ami-23b6534a ec2.compute-1.amazonaws.com
8. Great, your instance is up and running. Take note of your server’s web address (ec2-xx-xxx-xx-xx.compute-1.amazonaws.com) and ID (i-xxxxxxxx) as you will need both of these later in this tutorial. If you forget them, you can always type the ec2-describe-instances command again. Now, lets prep our server by enabling port 22 for SSH access and port 80 so Apache can serve web pages.
$ ec2-authorize default -p 22
PERMISSION default ALLOWS tcp 22 22 FROM CIDR 0.0.0.0/0
$ ec2-authorize default -p 80
PERMISSION default ALLOWS tcp 80 80 FROM CIDR 0.0.0.0/0
9. This is the moment you have been waiting for, connecting to your new machine. Open a new web browser window and type in your instance’s web address. You should now see an Apache welcome page.
10. Fantastic, your instance is serving the Apache test page. Now, lets SSH into the machine and check it out. Ensure you are in your ~/.ec2 directory as you will need your ec2-keypair file.
$ ssh -i ec2-keypair firstname.lastname@example.org
11. SSH will ask you if you are sure you want to connect. Just enter yes and you should be connected to your server instance.
__| __|_ ) Rev: 2
_| ( /
Welcome to an EC2 Public Image
__ c __ /etc/ec2/release-notes.txt
Terminating Your Server Instance
Keep in mind that you are still on the meter. Because of this, you should shut down your server instance if you do not plan on using it.
1. Enter the terminate command with your server’s instance ID.
$ ec2-terminate-instances i-xxxxxxxx
INSTANCE i-xxxxxxxx running shutting-down
2. Take a look to see if everything is terminated.
RESERVATION r-xxxxxxxx xxxxxxxxxxxx default
INSTANCE i-xxxxxxxx ami-23b6534a terminated
3. Done and done.
Now that you have an intro to using Amazon EC2 instances on Mac OS X, in step 7 above, you installed the tools. Check out the Amazon AWS Command Line Tools API for all the various ways you can monitor your EC2 instances and other AWS services from the command line. Here are a few more resources:
- AWS EC2 API Documentation
- Finding a suitable AMI – Amazon Machine Image
- Generating a new SSH Key-pair
- Launching an Amazon EC2 Instance
- You can even Launch EC2 Instance via the web with an HTTP Query
Amazing stuff, and more affordable than you might think. See Reserved Instances.
When starting instances, be sure to take note of the Availability Zone you’re starting your instance in. If you end up creating more servers, for example, an Apache server, a MySQL server, a Memcache or Redis Server, you’ll want to make sure you start them all in the same availability zone to avoid unecessary charges and security group headaches. More about AWS Availability Zones and AWS Security Groups over at Rightscale.