Install Subversion on Bluehost, configuring subversion client on Windows and Mac OS X

Been using Version Control System on our company projects for a couple of years now. I’ve installed Subversion before on a dedicated Linux hosting(Known Host) and everything is straightforward since I have root access.

Recently my personal hosting account with bluehost got renewed and I’m not really utilizing the server that much I figured to try installing subversion on Bluehost to make my hosting more useful. As far as I have tried I can only connect via svn+ssh and not through http as I dont have access to apache to add mod_dav_svn.so on my shared hosting account unless I upgrade to a dedicated host which is not what I want. I documented the steps I took just in case someone will find them useful on setting up theirs.



On my initial setup I used a Windows machine(I’m using Windows 7 64bit)

1. First is you need to enable SSH access on your account. Login to your account and request to enable SSH if not yet enabled. (The SSH option is disabled by default you need to submit a ticket to have it activated) Got mine activated within an hour.

2. Once enabled you should be supplied with a hostname, login user and password

3. Download the following applications: Putty and PuttyGen from http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

and TortoiseSVN from http://tortoisesvn.net/

4. Using putty connect to your host by entering the hostname and default port 22, enter your username and password on the command prompt type window.

5. Next is to create src directory and download the latest subversion package.

mkdir src
cd src
wget http://subversion.tigris.org/downloads/subversion-1.6.9.tar.bz2
wget http://subversion.tigris.org/downloads/subversion-deps-1.6.9.tar.bz2
tar -xvjpf subversion-1.6.9.tar.bz2
tar -xvjpf subversion-deps-1.6.9.tar.bz2
cd subversion-1.6.9
./configure --prefix=$HOME --without-berkeley-db --with-ssl LDFLAGS="-L/lib64"
make
make install

that should install subversion on your server
6. Create a svn directory and then the repository folder

cd
mkdir svn
cd svn


svnadmin create --fs-type fsfs projects
chmod -R 755 projects

7. If you have an existing website under public_html you can import it now to your repo

svn import /home/USER/public_html/mywebsite file:///home/USER/svn/projects/mywebsite --message="Importing website"

8. Edit your .bashrc file in vi and add the following then exit and save.

PATH=$PATH:$HOME/bin

9. Next test out if all is working


svn list svn+ssh://
USER_NAME@www.YOUR_DOMAIN.com/home/USER/svn/projects/mywebsite

10. Next is for setting up your subversion client to connect to the repo URL for Windows. Create a keypair on the server, this is going to be used for authentication.


cd
ssh-keygen -b 1024 -t dsa -f mykey


mkdir ~/.ssh
chmod 700 ~/.ssh
cp mykey.pub ~/.ssh/authorized_keys

11. Download the key to your computer using your FTP client.
12. Convert the key in puttygen, open up puttygen then on Conversions menu load the key and click on Save Private Key and save it as mykey.ppk

13. Test the key
open putty and create a new session like this:
Session->HostName: www.yourdomain.com
Session->Protocol: SSH
Session->Saved Sessions: yourdomain
SSH->Prefered SSH Protocol version: 2
SSH->Auth->Private Key file for auth: browse and select mykey.PKK
Go back to Session node and hit “save” button. You will see “yourdomain” in the list of available sessions.
Click “open” and you should see a telnet login prompt.
Use your username and if everything is ok, you don’t have to provide a password to your system.

14. On Windows 7 go to config file and edit with notepad.
C:\Users\YOUR_LOCAL_USERNAME\AppData\Roaming\Subversion\config

Look for the section [tunnels] and add the following line

ssh = c:\\Program\ Files\\TortoiseSVN\\bin\\TortoisePlink.exe

15. Finally checkout go to the folder you want to store the files and, if you already installed TortoiseSVN you should have a right click option SVN Checkout. For the URL of the repository simply enter the svn+ssh URL you tested earlier.

svn+ssh://
USER_NAME@www.YOUR_DOMAIN.com/home/USER/svn/projects/mywebsite

That should get you up and running on your Windows machine.

Now for your Mac machine, first download the scplugin, this is the mac counterpart of TortoiseSVN. Currently the contextual menu and icon badging is not working right on Snow Leopard or on Lion.

1. First launch Terminal from the Utilities and create a key, leave passphrase as blank
ssh-keygen -t dsa
2. Next is SCP the key to your server using the username, domain name and password
scp ~/.ssh/id_dsa.pub username@domainname.com:

The key should be uploaded successfully to your server

3. Next login to your server
ssh username@domainname.com
mkdir .ssh # if it's not already there
cat id_dsa.pub >>.ssh/authorized_keys
rm id_dsa.pub # cleanup

4. That should be it you should not be prompted to enter your password when you login to your server either from SSH or SCP and even on the scplugin.

5. Open up Finder and browse to the folder you want to Checkout for your files. On the Finder Toolbar if you installed it right you should see the scplugin toolbar, click on that and choose Checkout, then enter your svn+ssh URL.

svn+ssh://
USER_NAME@www.YOUR_DOMAIN.com/home/USER/svn/projects/mywebsite

That should be it, you should be up and running.

Resources:
http://www.tabruyn.com/site/index.php?option=com_content&view=article&id=55:tortoisesvn-subversion-and-bluehost&catid=36:digital&Itemid=58
http://www.bluehostforum.com/showthread.php?12099-Setting-up-Subversion-on-Bluehost
http://blog.macromates.com/2005/subversion-support-and-ssh-key-pairs/

One thought on “Install Subversion on Bluehost, configuring subversion client on Windows and Mac OS X

  1. Downloading subversion can be easy or difficult depending on the method you use. If you go the simple route, and use a subversion download you can benefit from the ease of the process. However, certain circumstances seem to permit different tasks- such as downloading subversion to bluehost. Best of luck to you in this endeavor.

Leave a Reply

Your email address will not be published. Required fields are marked *