Setting up SSH / Drush on a Go-Daddy Shared Hosting Plan

Yeah you read that right!

The details surrounding this is quite complicated ... so i won't bore you with history. I will just tell you how to do it (which is all I want when I spent more hours that I can remember looking for a solution!)

Let's get somethings straight: I am assuming that you know very little about web hosting, servers and the like. So, I am going to be way more detailed so that beginners can use this too!

Jump to how to do this and skip all the n00bie stuff

What is GoDaddy

Probably the biggest hosting provider in the world. I have been with them for years and actually like their service. I have an Unlimited plan (Unlimited Space and Transfer, 1000 Email Accounts, Unlimited MySQL Databases) using a Linux stack. This costs me around $14 a month. And at $10 per year per domain name ... this just rocks. The server used to get kinda slow at times; but ever since I have enabled SSH access to the account, things are really fast for me. So, the good out weighs the cons. Note: GoDaddy won't just "turn on" SSH .... they really will move your hosting to another box / framework. This process took two - three weeks for me. Also, the databases for all my Drupal installs needed to change. Go Daddy moved my databases, however I had to adjust the pointers (in settings.php

What is SSH (and BASH, btw)

SSH is a program and protocol for securely logging in to and running programs on remote machines across a network. You use SSH with a command line interface (CLI) ...remember the black screen, green text terminals like this that existed before good looking interfaces that you can navigate with a mouse, those!

Over the summer I embraced BASH (here and here), started to use Ubuntu (I created a partition on my HP) and live on the command line. I used to transfer files with FTP but now I do everything from the command line. Linux machines (like my GoDaddy web server and my Ubuntu partition) and Macs are based on the Unix operating system. Getting to the command line is easy on those platforms. On Windows you can't use the C Prompt because that is a command line for MS DOS (even though Windows XP and upward don't use MS DOS any more ... but you get the idea). To do the same on Windows you can use Cygwin or PuTTY. I use Cygwin because it acts just like BASH ... and the PuTTy interface has always-ed confused me.

So, that was long ... so to recap and put this in perspective: SSH is a protocol (an agreement between computers of how things should be done). You use SSH through a command line environment like BASH (which ships with every Unix OS in the world ... like Linux and Macintosh). You can "get it " for Windows by installing Cygwin or PuTTy. Ask GoDaddy to enable SSH on your account, take a vacation (because it takes a while to set up) or, if you don't know BASH, read up on how to use BASH.

What is Drush

Drush is awesome! Drush is a command line shell and Unix scripting interface for Drupal, a veritable Swiss Army knife designed to make life easier for those of us who spend some of our working hours hacking away at the command line.

Basically, Drush allows you to run php scripts from the command line ... giving you an easier way of maintaining your sites. Remember that Drupal is set up for multi-site installations right out of the "tar.gz" (it doesn't come in a box!) And alot of the way Drupal does things have been a mystery to me until I started to use the command line. Here is a scenario: before BASH and Drush, if i wanted to enable a module (like "image") on my multi-site i had to:

  1. go to the Drupal project page
  2. download the tar.gz
  3. "yes, I want to extract the folder that is within the tar.gz"
  4. open up my ftp program
  5. transfer the file to the right folder

With Drush, I go to the root of my multi-site installation and type: $ drush dl image and WHAM it is done. And when updates happen for modules ... man what a time suck.

Drush needs to live out side of your multi-site install; it isn't a module that you enable the usual module way. So, for that you happen: you need to set up your server directory in the "right" way.

Setting up your server directory

Ok, we have all done this: install Drupal in your site root so that when you FTP into your root you see the directory to your right. The problems with this are:

  • You can only have that one, singular multi-site install
  • You can't have any protected files "out side" that singular install
  • You can't enable "Drush" because, well, Drush has to live outside of your multi-site directory

Ok, so how do you do it? Try this:

  • At your server root (the folder that is designated as "html" or "www" ) create a folder /directory for your multi-site.
  • Name it whatever makes sense to you. I have mine as "johnvsc-root" that I use for my person sites / projects. I have one that I use for clients as "disorder-root" (for disorderDesign). For my "johnvsc-root" I have this site (johnzavocki.com) set as the default site. in "disorder-root", I have Open Atrium installed as a project management site for my clients. I was surprised that a mutlisite worked very easily on my GoDaddy account. The trick was my .htaccess file. I won't post it here, but if you contact me, I will send you a copy of it :) Once that was set, my clean-urls worked with no problem!
  • Outside of my HTML directory, I have a directory called tools, and that is where I put Drush

.

I thought about posting a visual of my server structure, but I decided against it. I am already exposing more than I really should to the world... so forgive me!

So, the idea here is to NOT use the root of the HTML directory to put your drupal install in. The ideal is to create a subdirectory (or directories) in HTML to put your Drupal sites... or other sites as well. That is a no brainer for system admins... but for n00bies, it is. Also, in you GoDaddy Hosting Control Panel, you need to go to Domain Management and point your domains to that HTML sub folder. So, for johnzavocki.com, I have it pointing to "/johnvsc-root" and for another site that i have "Sharing Needles with Johnny", I have that also pointing to "/johnvsc-root".

Remember that in Multisite installs, you can have several subfolders in the "sites" directory that contain the files, modules and theme that are used for a particular site. So, in the "johnvsc-root" the "default" folder is for this site (johnzavocki.com) and along side of it I have a folder called "sharingneedleswithjohnny.com" that has the files for sharing needles. That is a little crazy, because I can grab a file in that sharing needles directory from this site, like this ... see the url?

Final Thoughts Before the Good Stuff

One of the things that I learned in graduate school was that in order to have success as a painter, you have to set your painting up for success. To do the above should take you some time to do... if your don't have it set up already. Get SSH enabled and take some time to learn the BASH shell before you go moving stuff around. Pay to have a developer partition your computer to put Ubuntu on it, if you work in Windows. Why? Because:

  • setting it up yourself is quite daunting if you haven't done it before
  • you won't get un-inspired because of the time it will take to do
  • you will probably screw up your hard drive ... because everyone screws up their hard drive the first time you do it
  • you don't wanna lose all the information you got in your hard drive
  • if you are a Windows user, it helps to work in your server environment so that you gain understanding with it. WAMP is great but working in a similar environment as your server really goes along way!

Another reason: My wife was interested in Drupal development and quickly became discouraged because of the steep learning curve. If I had just installed a copy of it on her machine and said, "here you go, have fun" she probably would have had fun with it. The "Confidence Factor" is huge: beginning from a place of empowerment cannot be understated. Once that you have the confidence that it actually works, then you can pick and hack at it. As developers that is how we learn, we pick and hack. But you can't effectively pick and hack at something doesn't work. You need to break something that works to day "Oh, that does that".

To this point, I completely disagree with n00bies installing their set up before playing with Drupal. I am more like: here let me set up your box for you... now here is what I did. Have fun and go hack at it (BUT DONT HACK CORE!!!)

Setting up Drush

  1. Set up SSH access
  2. SSH into your server
    $ SSH username@domain-name.com
    then enter the password
  3. create a folder outside of your subdirectory (like "tools") and "cd" into it
  4. get Drush from d.o Today the current version is http://ftp.drupal.org/files/projects/drush-All-Versions-2.1.tar.gz so
    $ wget http://ftp.drupal.org/files/projects/drush-All-Versions-2.1.tar.gz
  5. untar it in the directory:
    $ tar -zcvf drush-All-Versions-2.1.tar.gz
  6. go to your root
    $ cd ~/
  7. edit your .bashrc or .bash-aliases which ever you have
    $ vi .bashrc
  8. create an alias:
    1. look for where the alias are defined by typing "/alias" and pressing enter
    2. you can navigate there by using your arrow keys.
    3. at the appropriate place, press "i" to enter "insert mode" and enter
      alias drush='/usr/local/php5/bin/php5-cli ~/tools/drush/drush.php'
      Now take note of what this is doing: i create an alias called "drush", I want it to use/run the php5-cli (that is the command line interface (CLI) for php5) and the '~/tools/drush/drush.php' indicates where drush is in my directory. If you didn't create a "tools" directory at you root, this ain't gonna work... you have to enter the path for your directory that you set up!
    4. once you have entered the alias, hit "esc" to get out of "insert" mode
    5. save the file my typing ":wq!"
  9. exit the terminal and SSH back into your server with a new terminal (you need to do this because the .bashrc reloads with a new SSH connection
  10. type
    $ drush help
  11. if you see a whole lot of help commands, you did it! if you don't .... well, review what cha did and check for errors!

For me, the hard part was finding the path to : /usr/local/php5/bin/php5-cli that Drush needs to use to run. That wasn't fun. Also, I get an error when I run Drush that says:
/usr/local/php5/bin/php5-cli: Symbol `client_errors' has different size in shared object, consider re-linking
and I haven't found a solution for this. If you know one, please let me know. Also, any tips or trick would be helpful!

Ok, now maybe I can enjoy Thanksgiving.