Michael Cordell's Blog

Compiling Git on a Shared Host without administrator rights (sudo)

This is guide focuses on how to get git working on a server where you do not have administrative rights (e.g. a webhost). You must have ssh (shell) access and gcc must be working. On my server I lacked expat.h library. Rather than try to install this library, I merely compiled git without it. I have not noticed a usage problem, although the makefile suggests a problem with pulling from https.

SSH into host and account.

Check GCC is functional:

gcc --version

If a GCC version is not returned, gcc is not found, or you lack permission, the rest of the guide will not work.

Create a working directory and make sure ~/bin exists:

Make sure that the bin folder is in the $PATH. Open ~/.bashrc in your favorite editor. Add the following line: {export lineine} Save and quit. Then run: source ~/.bashrc

Download the most recent git source code. Hint: I usually copy the link address of the file to be downloaded and then paste it into the wget command to follow.

wget {source code path}

Untar the downloaded archive, and cd into the source code dir:

tar zxvf {archive name} cd git{version}

The following step is used to compile without expat.h you may try to compile without this step. If you hit the expat error come back and try this.

Open the Makefile within this directory and add the following line: NO_EXPAT=’yes’

Save and Quit.

Make and install git with the following commands:

make make install

Git should now be functional.