Before I install Drupal

Whenever I start a new drupal project, my first task is to setup a version control repository. I have used CVS for 8 years but now that I had a taste of SVN, that is all I am using. Once I setup the repositary I create the folder for the project:

svn mkdir file:///var/svn/myproject -m "Creating initial folder for my project"

Then I download the latest version of the drupal series I want to install. Since a number of critial modules are not yet ported to Drupal 6 (views, cck, panels to name a few) I stick to Drupal 5 for now.


Then I follow the vendor branch instruction in the SVN book so I can keep track of changes while having the ability to modify the core files (fixed bugs, add features). NOTE: I avoid making core changes but it happened a couple of time that it was innevitable.

tar xfz drupal-5.7.tar.gz
svn import drupal-5.7 file:///var/svn/vendor/drupal/5.x/current -m "Importing Drupal 5.7 source as a vendor branch."
svn cp file:///var/svn/vendor/drupal/5.x/current file:///var/svn/vendor/drupal/5.x/5.7 -m "Tagging the 5.7 release."

The next step bring the drupal source into my actual project.

svn cp file:///var/svn/vendor/drupal/5.x/5.7 file:///var/svn/myproject/trunk -m "Bringing Drupal 5.7 into my project as the trunk"

This needs an explanation. What I am doing here is creating the trunk of my project from a copy of the 5.7 release. I am doing this so that I can upgrade to drupal 5.8+ in the future even if I changed some core files. The trunk is my project root folder which happens to be the document root when using drupal. That is why I make it my trunk.

Some people will instead checkout the CVS version of drupal in your trunk and since CVS plays well with SVN, you get the same advantages. Since I like doing things differently some times, I prefer doing it using svn vendor branches.

I want to work in my project so I need to check it out!

svn checkout file:///var/svn/myproject/trunk myproject
cd myproject

Drupal requires you to create a folder called "files" which will contain public files. But SVN will not know about this will and will put a question mark (?) when issuing "svn status". What I do is I tell svn to ignore this folder using svn properties.

mkdir files
chmod 777 files
svn propset svn:ignore "files" .
svn commit -N . -m "The files folder contains dynamic files"

The current folder is the document root where the files folder is located. By doing this, the files folder will be ignore by SVN which is a good thing. This folder contains dynamic files created by the application. It is exacly like the database. The database cannot be controlled by SVN because the database is dynamic.

In order to install Drupal, the settings.php file needs to be writable so the install script can modify its contain. Config files that contains passwords or contains settings that change from one user to another should not be in SVN. That is why I recommend that you rename the file to a "distributed" copy and tell svn to ignore the settings.php.

svn move sites/default/settings.php sites/default/settings.php-dist -m "The real settings.php should not be versionned"
svn setprop svn:ignore "settings.php" sites/default -m "The real settings.php should not be versionned".

The installer still need a writable settings.php and we'll get one from the distributed copy:

cp sites/default/settings.php-dist sites/default/settings.php
chmod 666 sites/default/settings.php

Now I can run the install script and follow the instructions to install Drupal.

mostly correct

Minor error:

svn setprop svn:ignore "files" . -m "The files folder contains dynamic files"

That's actually propset, and it does not take -m as argument.

By the way your captcha is often unreadable.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote>
  • You may post PHP code. You should include <?php ?> tags.
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. Beside the tag style "<foo>" it is also possible to use "[foo]". PHP source code can also be enclosed in <?php ... ?> or <% ... %>.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options