Installing Mercurial on a shared webhosting: Dreamhost
Today I’m starting a small series of articles about setting up a version control system and a project management tool on a shared host.
I can’t guarantee that the following steps will work with every webhost. If you have a VPS or a dedicated server you’re fine since you can do whatever you want. If not, Webfaction is offering a very powerful shared hosting or if you want to enjoy a very good shared hosting for a small the price an plenty of disk space, you can turn to Dreamhost. They ran crazy offers between Christmas and New Year day, huge 80% off on new 2 years hosting plans. Even without a special offer, this is still one of the best value in the business.
I am using a Dreamhost account for the business, for small and medium sized sites, this is just fine. The uptime is very good too: most weeks 100%.
I also have a personal Dreamhost account to play with. They offer a one-click installation for Subversion, but since I moved to Mercurial I had to setup a central repository online using Mercurial for my next projects and since Dreamhost provide plenty of dick space…
So, for Dreamhost users, here we go:
- Go to https://panel.dreamhost.com/ and log in.
- Click on Users > Manage Users, select the user you want to use and click Edit.
- In User Account Type, select Shell account and on Save Changes.
- Now you can access your Dreamhost account using SSH and go beyond what the Web panel provides you.
- if you are a Windows user you can access SSH with PuTTY, if you are running on a Mac or Unix/Linux open a Terminal window and type
ssh. - Using PuTTY or a Terminal, type
ssh user@mydomain.comwhereuseris the user with shell account access andmydomain.comis your domain. Typeyesif you are asked
Are you sure you want to continue connecting (yes/no)?
and enter your password when asked. You will be logged in your Home directory. Type
ls -lFato see its content. - You may already have a Mercurial installed somewhere in the hosting server, try to type
hg --version. In my case I had the outdated 0.9.1 version installed on my shared server. If the latest version is already there you don’t need to go further in this tutorial. - As of the 29th of January 2009, the current version of Mercurial os the 1.1.2. If there is a new version, you will have to update the next command.
- We need to download the latest version. Type
wget http://www.selenic.com/mercurial/release/mercurial-1.1.2.tar.gz - As soon as the download is over, type ls -lFa if you want to see the downloaded file.
- Next step is uncompress the archive. Type
tar xvzf mercurial-1.1.2.tar.gz. Amercurial-1.1.2directory will be created and will contain all the Mercurial files. - To get into the mercurial directory. Type
cd mercurial-1.1.2. - Next step is to compile the whole thing for your server. Type
make all. - Since our objective is to install Mercurial in our home directory, we will use a very nice option of the Mercurial makefile that makes it easy. Type
make install-home. This will create alibandbindirectories and deploy in your Home directory you very own working version of Mercurial. - And you are almost done. If you want to clean up now (or later) the downloaded Mercurial tar file and the
mercurial-1.1.2directory, come back to your root directory (your Home) and typerm mercurial-1.1.2.tar.gzandrm -r mercurial-1.1.2to save some space. - The last important step is to update the shell path to include our brand new
bindirectory in our Home to the server list of bin directories. So ourhgcommand will be found and will be useable. - Come back to your root directory (your Home) and type
nano .bashrc(orvi .bashrc) if you are using Bash shell. Typels -lFato make sure which rc file do you have. You will also need to update your shell profile file. Again if you use Bash, typenano .bash_profile(orvi .bash_profile). - What you need to type inside both files before saving them:
export PYTHONPATH=~/lib/python
export PATH=~/bin:$PATH - And you are done. Type
exitto quit the shell and close your ssh connection.To test your Mercurial installation, connect back to your account again with ssh and typehg --version. You should see:
Mercurial Distributed SCM (version 1.1.2).
If not check your
.bashrcand.bash_profilefiles.
This is just a first step. Having Mercurial installed is just the beginning. In the next article we will see how to make use of Mercurial by creating a repository for a project and sharing it over the Internet.
Please note that I assumed your server has Python installed and at least a version 2.4 or newer. Dreamhost has it. If you get ssh access on your shared host, there is solutions to install also your very own Python version in your Home directory. But I will leave that for another post.
Until next time,
Code with pleasure.
Richard Lopes
