Nodding Politely

-- javier pedemonte

Setup Octopress on GoDaddy

I’ve had a GoDaddy hosting account for far too long, but decided to use it anyway, to host an Octopress instance. Yes, I know I can use GitHub Pages or Heroku for free, and they would be much simpler to use. But I felt like taking on a challenge. Below is (roughly) the steps I had to take to host Octopress on a GoDaddy Linux server.

Required Software

I followed the Octopress installation and setup docs as best I could. But if you are trying to setup on GoDaddy, you’ll immediately discover that the GoDaddy Linux servers are missing some essential software – in particular, rsync and git.

First, let’s check what version the server is running and which CPU architecture (32 or 64 bit):

1
2
cat /etc/redhat-release   # OS version
uname -a                  # CPU arch (amongst other things)

At the time I ran this command, the returned values were CentOS release 5.5 (Final) and 64-bit (i386 or i686) for the CPU arch.

I then searched online for appropriate RPMS for rsync and git and installed them in my home directory on the GoDaddy server. First with rsync:

1
2
3
4
5
6
7
8
9
10
11
12
# on GoDaddy server

# get rsync RPM
curl -O http://mirror.centos.org/centos/5/os/i386/CentOS/rsync-3.0.6-4.el5.i386.rpm

# unpack RPM locally
#  You may want to do this in a temporary folder, so that the unpacking doesn't
#  litter the $HOME dir.
rpm2cpio rsync-3.0.6-4.el5.i386.rpm | cpio -id

# copy rsync app to local bin dir
cp usr/bin/rsync ~/bin

Then with git (if you choose to also host your remote git repository):

1
2
3
curl -O http://download.fedora.redhat.com/pub/epel/5/i386/git-1.7.4.1-1.el5.i386.rpm
rpm2cpio ../git-1.7.4.1-1.el5.i386.rpm | cpio -id
cp usr/bin/git* ~/bin/

Note: The URLs above may no longer be valid for the hosting system you use. Make sure you have the right one.

However, it’s still not 100% perfect, since the apps we added aren’t in the path when using a non-interactive session to the GoDaddy server. We need to tell the local app where to look for any of its dependencies on the server. For example, to do a clone of a git repository on that server, it would look something like this:

1
2
3
4
5
# The -u option tells git where to find the necessary app on the server.
git clone -u bin/git-upload-pack myexample.com:git/octopress.git

# rsync has a similar option
rsync --rsync-path=bin/rsync foo/ baz/

Octopress Configuration

In general, I followed the documentation, especially Deploying with Rsync.

In the Rakefile, I had to change how rsync was invoked, in order to specify the necessary --rsync-path:

Rakefile
1
2
3
4
5
6
7
8
 desc "Deploy website via rsync"
 task :rsync do
   puts "## Deploying website via Rsync"
-  ok_failed system("rsync -avze 'ssh -p #{ssh_port}' --delete #{public_dir}/ #{ssh_user}:#{document_root}")
+  ok_failed system("rsync --rsync-path=bin/rsync -avze 'ssh -p #{ssh_port}' --delete #{public_dir}/ #{ssh_user}:#{document_root}")
 end

 desc "deploy public directory to github pages"

Setup Git Repository

I decided to host my own version control repository, again on the GoDaddy server. I followed the instructions here to first set up my remote repository and then to update the git config. One thing different is that I didn’t input the pwd URL as the new repo URL (git config branch.master.remote origin) – instead, I have myexample.com:git/octopress.git, where “myexample.com” is an entry in .ssh/config:

.ssh/config
1
2
3
Host myexample.com
User myusername
IdentityFile ~/.ssh/identity

The main reason I created this config file is because my GoDaddy username is different than my local username, and i got tired of always doing ssh -i ~/.ssh/identity myusername@myexample.com. With that config, I can now just type ssh example.com. It’s also useful for the Octopress scripts.

Now, after creating the repository on the server, running any git commands locally won’t work, complaining that it can’t find git-upload-pack. You can fix that by specify that executables location on the server:

1
2
3
4
5
# clone
git clone -u bin/git-upload-pack myexample.com:git/octopress.git

# pull
git pull --upload-pack bin/git-upload-pack

An easier way is to add these to the .git/config file, under the heading for the GoDaddy server:

.git/config
1
2
3
4
5
[remote "origin"]
	url = myexample.com:git/octopress.git
	fetch = +refs/heads/*:refs/remotes/origin/*
	receivepack = bin/git-receive-pack
  uploadpack = bin/git-upload-pack

With that, it should all work.

References

Here are some sites that helped me with this task:

Subversion on GoDaddy shared hosting

Using Git on Godaddy’s Ssh-Enabled Virtual Webhosts