The first installment in this series was little more than an introduction. Now it’s time to get your hands dirty, setting up Git, and laying the groundwork for your day-to-day development tasks.
Before you get to the nitty-gritty, it’s worth taking a moment to review what exactly you’re working towards.
The setup described below is pretty simple, but can be easily expanded to accommodate more developers, or more “staging” servers.
Dealing, as it does, with the ins-and-outs of setting up your development environment, this will be the most implementation-specific article in this series. If you’re using a different operating system, or a different hosting company, you’ll most likely need to adapt a few of the step-by-step instructions accordingly.
At this stage, it’s also worth stating the obvious; that these instructions are presented as-is, without warranty or guarantee. We’re all grown-up boys and girls, and whilst these instructions worked (and continue to work) just fine for me, if you accidentally delete the internet whilst following them, it’s not my fault.
Caveats dispensed with, here’s what you’ll be setting up:
pushwhatever local changes he’s made to the “origin” repository.
Before you can start pushing and pulling your code about the place, you need to get everything set up.
If you’re feeling particularly adventurous, there’s always the option to compile and install Git manually, but unless you have very specific requirements, it’s probably not worth the effort.
Windows users may find this useful.
In a piece of tremendous good fortune, it appears that DH now installs Git as standard on new hosting accounts. To confirm that you’re all set up and ready to go, SSH into your DH account, and run the following commands:
[server]$ which git /usr/bin/git [server]$ git --version git version 220.127.116.11
If you’re one of the unlucky few not to have Git installed, the official DreamHost Wiki has detailed instructions for installing Git.
After the effortless ease with which you glided through steps 1 and 2, you may be thinking now is a good time to kick back with a self-congratulatory cup of tea.
Not so fast.
Installing Git on a MediaTemple (dv) server actually requires a (little) bit of effort, and whilst the MT knowledgebase article is a good starter for 10, it doesn’t work quite as advertised.
MediaTemple recommends using Yum to manage the installation of software on your (dv) server, but unfortunately the knowledgebase guide to installing Yum falls a bit short, neglecting to mention a number of Yum’s dependencies.
This leads to lots of errors message, typically followed by loud and sustained cursing. Not to worry, you can benefit from my bitter experience by following the Yum installation instructions below:
rpm -Uvh http://mirror.centos.org/centos/5.2/os/i386/CentOS/python-iniparse-0.2.3-4.el5.noarch.rpm
rpm -Uvh http://mirror.centos.org/centos/5.2/os/i386/CentOS/yum-metadata-parser-1.1.2-2.el5.i386.rpm
rpm -Uvh http://mirror.centos.org/centos/5.2/os/i386/CentOS/python-elementtree-1.2.6-5.i386.rpm
rpm -Uvh http://mirror.centos.org/centos/5.2/os/i386/CentOS/python-sqlite-1.1.7-1.2.1.i386.rpm
rpm -Uvh http://mirror.centos.org/centos/5.2/os/i386/CentOS/rpm-python-4.4.2-48.el5.i386.rpm
rpm -Uvh http://mirror.centos.org/centos/5.2/os/i386/CentOS/m2crypto-0.16-6.el5.2.i386.rpm
rpm -Uvh http://mirror.centos.org/centos/5.2/os/i386/CentOS/python-urlgrabber-3.1.0-2.noarch.rpm
4. Install Yum:
rpm -Uvh http://mirror.centos.org/centos/5.2/os/i386/CentOS/yum-3.2.8-9.el5.centos.1.noarch.rpm
Once that’s done, you can return to MT’s standard Git installation instructions:
rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-2.noarch.rpm
yum install git
At this point, you should have everything setup and ready to go. If you’ve had enough for one day, feel free to go and have that cup of tea now.
If you’re still bursting with Terminal energy, there are a couple of additional things you can do that will make your life at the command line at lot simpler.
As you’re going to be doing a lot of SSHing between servers, it’s worth spending a few minutes setting up some SSH keys. Otherwise you’ll spend your life mistyping passwords in the Terminal.
Here’s how to setup an SSH key on your local development machine. Do this for each remote server that you want to access via SSH (DreamHost and MediaTemple, in this setup).
key_nameis the name you wish to assign to this SSH key.
scp ~/.ssh/key_name.pub email@example.com:./key_name.pub
ssh firstname.lastname@example.org. You’ll still need to enter your password at this point.
ls -l, to list all the files and directories in the current folder. If the
.sshdirectory already exists,
cd .sshinto it, and skip to step 12.
chmod 700 .ssh
chmod 600 authorized_keys
cat ../key_name.pub >> authorized_keys
With that out the way, you can now log into your DreamHost or MediaTemple server using
ssh email@example.com, without entering a password.
It’s also worth taking the time to set up an SSH key on MediaTemple, so you can easily log into your DreamHost server from your MediaTemple server. Here’s how to do that:
You can shave even more keystrokes off your day by adding SSH “aliases” to your
config file. You can then log into your remote server by typing (for example)
ssh dh, instead of the much less catchy
To achieve this state of keyboard Zen, add the following block of code to your
~/.ssh/config file, for each server you’re connecting to.
Host shortname User username HostName remoteserver.com # You probably won't need to specify the port, so just omit the following line Port 2222