Wednesday, June 13, 2012

Installing Localtunnel on Mac OSX

Localtunnel is a nifty little application that allows you to share your local webserver with the outside world.  The flow is pretty simple:

  • Run your local webserver
  • Localtunnel spits out a URL for you (ie: 'http://localtunnel.com/abcdefg')
  • Share the localtunnel URL with anyone and they should be able to access your 'localhost' remotely over the web, as long as localtunnel continues to run in the background.
This is ideal for sharing quick demos/prototypes.  It is not a good temporary hosting solution because localtunnel shuts you out after ~20 mins if the service is not actively used.  

Installing this *should* be pretty easy but about a million posts online show that there is a little hidden step that makes this 10 minute process take 2 hours to figure out:
  • You need ruby to install localtunnel according to their documentation:
    • Download XCode through the app store
    • Open XCode:
      • Navigate to XCode ->Preferences->Downloads
      • Install 'Command Line Tools'
  • Open up terminal and run 'sudo gem install localtunnel'
  • run 'localtunnel 80'.  You should get a message saying 'Failed to authenticate.'  To get around this, you need to upload a public key.
    • Make sure you have a public key
      • Run 'cd ~/.ssh'
        • If the directory doesn't exist, created it by running 'mkdir ~/.ssh' and navigate into it by running 'cd ~/.ssh'
      • If you do not have a private/public key pair (ie: id_rsa), create one by running 'ssh-keygen -t rsa -b 4096'
    • Run 'localtunnel -k ~/.ssh/id_rsa.pub 80' and enter your passphrase.
    • The service should now be running.  Take the url displayed and type it in your browser; you should be taken directly to your localhost index page.

Saturday, June 9, 2012

Installing MySQL on OSX Lion

Setting up your dev environment can be a b*itch-and-a-half.  There are dozens of StackExchange articles about installing each tool/framework, but people change their setup so frequently that it's hard to tell which dependencies they have that you don't.  For my own benefit, I've decided to document how I set up my own system after a clean install of Mac OSX Lion, so all dependencies are accurately captured.  Hope this is of use to someone else as well.

Quick tips to set up MySQL on your intel Mac OSX Lion machine

  • Download the MySQL .dmg file here
  • Within the .dmg file:
    • Run the large MySQL .pkg file
    • Run the MySQLStartupItem.pkg file
    • Run MySQL.pref_Pane
      • Active MySQL server
      • If you don't want to deal with this again, select the option to automatically start MySQL when your computer boots
Now, run the following commands in terminal
  • Add mysql to your PATH
    • Run 'sudo nano -S /etc/profile'
    • Add the line 'export PATH=$PATH:/usr/local/mysql/bin' and save changes
    • Open a new Terminal window for changes to take effect
  • Enable a root password for your DB
    • Run 'mysqladmin -u root password', where 'password' is your secure DB password.
  • Run 'mysql -u root -p'.  You should now have command-line access to your local MySQL DB.