Install Drupal with CVS!


Very often, the wonderful Drupal security team comes up with a new security release of Drupal core itself.

When that happens, you want to upgrade relatively quickly (after waiting for 24 hours to make sure no-one is having problems...) you don't want to just copy the new version over the old, since it is possible that a single file is split into two, for example, or one is removed, and you don't want conflicting code hanging around in your file system. And you certianly don't want to be futzing around deleting stuff manually.

You want a clean, accurate and fast install every time.

Clean Original "Virgin" Install

(This assumes that nothing has ever been installed before. For a site running on a Drupal core  not originally installed with CVS see the next section.)

To do that, make sure you carry out original install of Drupal core via CVS, then it is just a matter of a simple CVS update command specifying the new Drupal release.

To checkout a specific Drupal release (here 6.8) to a new specific sub-directory which will become Drupal document root, here "www", execute the following:

$ cvs -z6 co -d www -r DRUPAL-6-8 drupal

Executing this statement on the command line will create a new Drupal document root just below the current directory, called "www". If I omit "-d www", then it will create a new Drupal document root called "drupal".

Just visit homepage to see which is the current release, and which releases you should be upgrading to.

What if I am running a site where Drupal core was not checked out with CVS?

Well, a lot of us have sites we wish Drupal core had been installed via CVS, so we could just carry out the upgrade instructions in the following section. However, if the Drupal core was simply untarred from an installation tarball or FTP'd into place, you can neither carry out the upgrade, nor can you safely checkout anything (CVS won't overwrite stuff, and some new files will come down, leading to a big mess and unpredictable results).

You are going to have to futz around deleting the existing core very carefully, and then do the checkout into a blank space - but at least it will be the last time! The following would typically be the procedure to follow:

  1. Make a complete backup of the site (including SQL dump of the database). That way if this procedure doesn't work for you, you have a safe path backwards.
  2. Especially keep a handy copy .htaccess, robots.txt, default/settings.php and any other core file you might have modified or which needs special handling in your situation.
  3. Log in as user #1 (full permissions).
  4. Physically delete all of Drupal core (the subdirectories, and the document root files like update.php, etc., but excluding any custom or asset files, and excluding the directories under sites that contain contribution and custom modules and themes).
  5. Go to one step above document root, and check out the current stable version of Drupal from CVS as shown above.
  6. Make sure your custom information is present in default/settings.php
  7. Run the spanking new update.php

The ideal with default/settings.php would be:

  1. Move default/settings.php to a safe place, out of the Drupal file system after step 4.
  2. Merge in your custom settings.php content (especially the database access info) to a copy of the new settings.php (Drupal 5.x) or copy the new default.settings.php to a new settings.php and merge your custom settings into that file. Then run update.php

Upgrading to new release

However you got here, your Drupal core is a working copy of a CVS tagged release of Drupal. So you can now enjoy the benefits of being able to upgrade with a simple checkout statement for the remaining life of the site!

This is to be executed within document root! That is, if I had created a new Drupal install at document root "www", I would change directory to www and then executing the following will upgrade to Drupal 6.9:

$ cvs update -dPr DRUPAL-6-9

If you omit "r{release tag}", in this case "DRUPAL-6-9", you will check out HEAD, which you won't be wanting to do on a production site!

Simple, clean, efficient, easily reversible: you can't beat it.

As a CVS n00b, I ran into a

As a CVS n00b, I ran into a little snag for this part... I did a checkout via # cvs -z6 co -r DRUPAL-6-9 drupal to update one of my existing sites after I read about it in the book... but it didn't seem to actually update anything.

I'm guessing that's why I should use the "update" command you reference above. Or was the problem that I hadn't downloaded it from CVS in the first place?

At any rate, I ended up downloading it via CVS into a new directory, then I just copied over my sites directory from my existing site into that one and replaced the live directory with that one.

Then I ran into another problem - I got the white screen of death. I "fixed" it by running update.php, and I'm still not sure why or how that fixed it, or why it was broken in the first place. Uuugh!

Congrats on taking the plunge

I have added a new section above, "What if I am running a site where Drupal core was not checked out with CVS?". Please let me know if it helps.

The whole thing is a little scary the first couple of times you do it, that's why obviously it's better to do this on a test site first a few times. But once you get used to it, as the saying goes, you never go back!




I'm hooked!

I noticed that after demonstrating how to use CVS, for the rest of chapter 2 and 3 you use the tarball method. Was I correct in assuming that was just for example's sake? I just kept using CVS for everything (installation on local, test, and production sites).

I wanted to reach the widest possible range of Drupal users

That's why in the Drupal installation section, even Fantastico is mentioned as a way (albeit not that recommended) to install Drupal.

The tarball method is covered also, for those that want to use it. But the CVS method is underlined in the book as being the best route to follow.

You do well to take that road.

Victor Kane