Installing a new Drupal site with Git
If you have many Drupal websites on your server, you might want to use a Git repository to ease the upgrades. There is a Drupal repository on GitHub at https://github.com/drupal/drupal.git that contains all the releases and is up-to-date with the development CVS used at Drupal.
Prerequisites:
- If you don’t have yet a local Git repository for Drupal on your server, these are the steps to clone one in /var/git/drupal:
mkdir /var/git
cd /var/git
git clone https://github.com/drupal/drupal.git
- We’ll assume you place your Drupal website in /var/www/$SITE/drupal.
In this article, I’ll show you how to install a new Drupal website from a Git repository. As an example we’ll suppose you want to install a Drupal 6.22 — of course, you should use the latest release for a new installation.
export CURRENT_RELEASE=22
export CURRENT=drupal-$VERSION.$CURRENT_RELEASE
Install drupal by cloning the local Git repository (See the prerequisites if you don’t have a local Git repository). The variable $SITE should contain the name of the directory holding your website in /var/www:
mkdir /var/www/$SITE
cd /var/www/$SITE
git clone /var/git/drupal
Now you choose the release of Drupal you want to use (in our example it is 6.22). The nice thing about Git is that your drupal contains all the versions. You use the command “checkout” to select which version to use.
git tag To list the existing Drupal version
git checkout DRUPAL-$VERSION-$CURRENT_RELEASE
Now, we’ll create a Git branch named after your site that derives from this current release. Because branches are cheap in Git we don’t need to shy away from structuring a nice setup with the original branch “CVS” alongside yours — this might prove handy in the future at upgrade time:
git branch This should list both branches
Now continue the installation by running the installation program from the browser as this is the recommended way for the newer Drupal versions.
When you’re finished, commit your changes and tag this new branch:
git add .
git commit -m "`eval echo $SITE $CURRENT online`"
git tag -a \
"$SITE-$CURRENT" -m "`eval echo ${SITE} ${CURRENT}`" Tagging the new branch
git tag This will list the tags
You now have a perfect setup for future Drupal upgrades.
Add new comment