Home > Mercurial > Installing Mercurial on a shared webhosting: Dreamhost

Installing Mercurial on a shared webhosting: Dreamhost

January 30th, 2009

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.com where user is the user with shell account access and mydomain.com is your domain. Type yes if 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 -lFa to 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. A mercurial-1.1.2 directory 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 a lib and bin directories 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.2 directory, come back to your root directory (your Home) and type rm mercurial-1.1.2.tar.gz and rm -r mercurial-1.1.2 to save some space.
  • The last important step is to update the shell path to include our brand new bin directory in our Home to the server list of bin directories. So our hg command will be found and will be useable.
  • Come back to your root directory (your Home) and type nano .bashrc (or vi .bashrc) if you are using Bash shell. Type ls -lFa to make sure which rc file do you have. You will also need to update your shell profile file. Again if you use Bash, type nano .bash_profile (or vi .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 exit to quit the shell and close your ssh connection.To test your Mercurial installation, connect back to your account again with ssh and type hg --version. You should see:
    Mercurial Distributed SCM (version 1.1.2).

    If not check your .bashrc and .bash_profile files.

 

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

Click to share
  • Digg
  • Reddit
  • Furl
  • Slashdot
  • DotNetKicks
  • Technorati
  • StumbleUpon
  • del.icio.us
  • Facebook
  • LinkedIn
  • MySpace
  • Google Bookmarks
  • email
  • Share/Bookmark

Read more...

Mercurial , , ,

  • Thanks you, I am using dreamhost right now and I goona try it
  • wBrewer
    I am trying this tutorial and I keep getting this error. I've checked both .bashrc and .bash_profile. I don't see anything wrong. Here is the error:

    Traceback (most recent call last):
    File "/home/<WEBSITE>/bin/hg", line 11, in ?
    from mercurial import demandimport; demandimport.enable()
    ImportError: cannot import name demandimport
  • Hi,

    What I am thinking is that you may have mix versions of libraries used by Mercurial. Even without knowing it.
    First thought, check if the machine doesn't already have Mercurial installed. Remove the path from your .bashrc and .bash_profile files and type hg. Then try hg -version.
    I assume your are installing on a Dreamhost account.

    Cheers,
  • Nice one! I wasn't aware of the make install-home option...that makes things super easy. Sometimes searching to see if someone has already done something you're about to do really pays off, even when you think you know how to do it already! :)
blog comments powered by Disqus