How to install and config Drupal 6 via CVS and SVN on hostgrown.com

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
You are viewing a wiki page. You are welcome to join the group and then edit it. Be bold!

Thanks to Dave for giving us the tutorial on how to use CVS and SVN with Drupal. A lot of the info here were provided by Dave during HKDUG's 2nd official meeting.

John's hostgrown.com has a security measure where files cannot have permissions above 755. This gave us a few headaches when installing Drupal as a lot of the files have 775. Here are the steps I took to install D6.

1) Install / Update from CVS

How to checkout Drupal core from CVS:

http://drupal.org/node/320
"Checkout a specific Drupal version"

cvs -z6 -d:pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal co -r DRUPAL-6-6 drupal

"Checkout a specific Drupal version into a specific folder - myfolder"

cvs -z6 -d:pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal checkout -d myfolder -r DRUPAL-6-8 drupal

How to checkout Drupal modules from CVS:

http://drupal.org/node/321

"Checking out a specific version of a contrib module"

cvs -z6 -d:pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal-contrib checkout -r <version tag> -d ModuleName contributions/modules/moduleName

"Browse all modules / themes / translation files"
http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/
http://cvs.drupal.org/viewvc.py/drupal/contributions/themes/
http://cvs.drupal.org/viewvc.py/drupal/contributions/translations/

eg: to check out the latest CCK for the Drupal 6 branch, go to the modules contributions repository and CCK:

http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/cck/

In the "Sticky Tag" box, find the latest "Non-branch Tags", it is DRUPAL-6--2-1 at the time of writing, which corresponds to the latest official release - 6.x-2.1

Hence, the command to CVS checkout 6.x-2.1 version of CCK is:

cvs -z6 -d:pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal-contrib checkout -r DRUPAL-6--2-1 -d cck contributions/modules/cck

and to checkout 6.x-1.0-rc3 version of the RootCandy theme:

cvs -z6 -d:pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal-contrib checkout -r DRUPAL-6--1-0-RC3 -d rootcandy contributions/themes/rootcandy

(From Lullabot) Important Note for the geekier people out there - DO NOT USE CVS. A CVS checkout of a translation will not work because the correct structure for the files is created during the tarball packaging process.

So, simply download the language files from http://drupal.org/project/Translations and put the file in the root directory and unzip it.

How to update to a newer version:

http://drupal.org/node/93966

"Upgrading to a specific version of Drupal core"
(or roll back to an earlier version)

cvs update -r DRUPAL-6-8 -dP
cvs update -r DRUPAL-5--1-4 -dP

then, while logged in as user/1, navigate to example.com/update.php to launch the database update utility.

"Upgrading to a specific version of a Drupal contributed module"
Navigate to the directory at the root level of the contributed module, enter the command:

cvs update -r DRUPAL-6--2-1 -dP

where DRUPAL-6--2-1 is the "CVS Tag" as listed on the release notes for the module. Then, while logged in as user/1, navigate to example.com/update.php.

2) Initial Configurations

Personally, I installed Drupal in a subfolder within my web root - public_html folder. Here's the mod_rewrite codes I used.

(Please feel free to add the actual mod_rewrite codes here and give a little explanation!)

After a long struggle, I finally got the redirect to work and I was getting a 500 error, I could get to the INSTALL.txt file, but non of the php files work. I remembered Karim changed the permissions and I verified with John that he has security control on the server that prevents files from having permissions above 755. I checked with the soholife install to see how Karim had set that up, basically, I see that all php files have just 644 -rw-r--r-- and folders have 755 drwxr-xr-x . So, from my fresh Drupal checked out from CVS:

I ran this command in public_html, (where "myfolder" is my drupal install)

chmod -R g-w myfolder/

and I ran this command in myfolder

chmod 644 *.php

(I think... please feel free to correct me or provide a better way of doing this.)

Below is a copy of the stuff I typed in the March meeting thread from the Leveraging Drupal book

Dave gave us a really good tutorial before, now I'm reading the Leveraging Drupal book and the author, Victor Kane, has shared his very own best practice on setting up Drupal with CVS + SVN + Trac. Karim and I were talking about it on Friday and we thought we could spend some time to discuss about this and our own best practices on Thursday meeting.

Here's we Victor has in his book, first of all, he recommends using a dedicated server or VPS so you have total control of the server.

  1. MySQL (p.27)
  • make sure root user has password - # mysql -u root
  • login as root user, create Drupal user and database.
  • Installing Drupal 5
    • Use CVS - review HKDUG's previous CVS tutorials for details on commands - Dave's Version Control tutorial from HKDUG's 2nd official meeting and Nick's Drupal install through CVS wiki.
    • Move all files into web root, do not forget the .htaccess file - cp /tmp/drupal-5.7/.htaccess .
    • Set permission of settings.php file to 666 for installation wizard, change it back to 644 afterwards.
    • Choose mysqli if you have PHP5
    • Create user/1 admin - most experienced Drupal users only use this user on rare occasions, for upgrading and other superuser actions, to protect the session from being hijacked.
    • Consult Drupal.org's Configure Your Website to create a special admin role and everyday admin user.
    • "filesystem not writeable" error - create "files" folder in web root(?!) (eg: /var/www/hkdug is the web root, and www-data is the HTTP server user and group.) (p.37)
      # cd /var/www/hkdug
      # mkdir files
      # chown www-data:www-data files
  • CCK
    • Don't use the depreciated content type field Body, if you want a text area, you should add it yourself so that it gets treated the same as all your other fields.
    • Always use a prefix with all machine-readable field names, so that they may be easily identified in long selection lists while creating views. The prefix should identify the content type at a glance.
  • Subversion and Trac (Chapter 3)
    • Victor uses a Trac instance to visually review his repository and the commits, & to document the project milestone planning and tracking. (Bugzilla is an alternative - that is what Yahoo! uses internally, along with some smaller / lighter in house developed ticketing / issues tracking system.)
    • The sites directory is the ONLY directory you need to version, because all the rest comes straight out of a fresh Drupal release tarball.
    • Do you version your content assets?? (images, audio & video files, downloaded documents... etc) (p.58)
    • Moving the files directory under the sites directory is an efficient way to easily place images & doc file assets under version control -
      # mkdir sites/all/files
      # chown -R www-data:www-data sites/all/files
    • (Personally, I remember reading somewhere about using symlink to place files outside of drupal's directory structure for multisite or for easy upgrade. Is that a good idea? eg: http://acquia.com/node/42925)
    • When you make a commit, how do you version the state of the Drupal database??
    • Place SQL database dump inside sites directory to be included when making a commit to SVN - eg: ./sites/all/backup/db/hkdug_db_backup.sql
      # mkdir sites/all/backup
      # mkdir sites/all/backup/db
      # cd sites/all/backup/db
      # mysqldump -u db_username -p db_name > hkdug_db_backup.sql
      Enter password:
      #
    • (for more info on mysqldump, see http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html
    • (I used to use the Backup and Migrate module & it excludes the data in a few tables including cache_* & watchdog, does any of you have a script or a stored procedure to accomplish the same in command line?)
    • Later on when you check out from the repository to make a working copy of your test site, you insert the SQL file back into the database - command:
      # mysql -u db_username -p db_name < hkdug_db_backup.sql
    • Holy crap... firefox just crashed!!! I almost had a heart attack!!!! Thank god when I restore the session it kept 100% everything I typed so far!!!!!!!! I'm totally amazed!!!!!!!!!!!!!!!!!!!!! But I need to stop now, I'll continue to type more tomorrow. There's no need to reply right now, although you could. We'll talk about these on Thursday!

    • OK, continue... so one of the questions I have is how do you combine the databases when multiple devs are working on the same Drupal site?
    • Main Directory Structure for the Repository - Now it's time to set up the main directory structure for branches nd tags within the repository itself. You can list he repository with:
      # svn list http://hkdugster.sourcerepo.com/hkdugster/litworkshop/
    • Initial Import of the Codebase into the Repository - Before importing your sites directory into SVN for the 1st time, temporarily remove the ./sites/default/settings.php file because it is not convenient to place this site-specific file under version control. SVN will omit the file in future commits, or, to be sure, you can use the SVN propset ignore command:
      # cd sites/default
      # svn propset svn:ignore settings.php .
      (the trailing dot means the current folder.)
    • OR, before import, simple change the name of the settings file like mv settings.php settings.php.devbox
    • Now import the sites directory into an appropriate place in the repo:
      # svn import sites https://hkdugster.sourcerepo.com/hkdugster/litworkshop/trunk/sites -m "import roles and initial cut of basic functionality"
  • Using a Dedicated Server or VPS
    • You should create a system user with the same name as the application, so your client & staff can have secure shell & sftp access to the application, also without having to have root access to your server.
    • Same as creating the initial environment earlier, log in as root, create a system user and set of user directories:
      root@example.com:~ # adduser hkdugster
      Adding user 'hkdugster'
      Adding new group 'hkdugster' (1006) ...
      Adding new user 'hkdugster' (1006) with group 'hkdugster' ...
      Creating home directory '/home/hkdugster' ...
      ...
      Is the information correct? [y/N] y
      root@example.com:~ #
    • Still in root, navigate to the new user's directory /home/hkdugster, check out a copy of Drupal from CVS into /home/hkdugster/public_html, then issue:
      # chown -R hkdugster:hkdugster public_html/

      Now the public_html folder is owned by hkdugster user & hkdugster group. Next, issue:
      # mkdir public_html/files
      # chown www-data:www-data public_html/files/

      That's it, you don't have to log on as root anymore, do a # su - hkdugster
    • Now, check out the copy of the sites directory from repo and put it in any of your other boxes (test / laptop / live... etc)
      # mv sites sites_default
      # svn co https://hkdugster.sourcerepo.com/hkdugster/litworkshop/trunk/sites sites --username hkdugster
  • How to Easily Update the Drupal Release?
    • Skipping along... I'm in Chapter 5 here. We already know how to use CVS to easily update the Drupal core, the book adds a .cvsignore to tell CVS to ignore the sites subdirectory and especially the default settings file:
      # cd drupal
      # cat sites/default/settings.php > .cvsignore
      # cvs update -dPr DRUPAL-5-16
    • The book doesn't use CVS for modules though, it opt for using wget, Drush and Update Status! You download the modules directly onto your modules folder by:
      # cd sites/all/modules
      # wget http://ftp.drupal.org/files/projects/cck-5.x-1.7.tar.gz
      # tar xvzf cck-5.x-1.7.tar.gz

      Now, install Update Status and Drush, enable Update Status, Drush Package Manager, Drush Package Manager SVN Support, Drush Package Manager wget Support, Drush SQL commands and Drush Toolbox.
      From the command line in the Drupal root directory, run this to verify successful install of both modules:
      $ php sites/all/modules/drush/drush.php help

      You should see a help page. Then, commit the changes, dump the database state first into sites/all/backup/db/hkdug_db_backup.sql, you can do that with the drush sql dump command:
      $ drush sql dump > sites/all/backup/db/hkdug_db_backup.sql
      $ cd sites
      $ svn add all/modules/drush
      $ svn add all/modules/update_status
      $ svn commit -m "finally got smart and installed update-status and drush modules"

      Command-line Aliasing - you can populate your ~/.bash_aliases file with the following:
      alias drush='php sites/all/modules/drush/drush.php'
      alias drush checkout6='cvs -z6 -d:pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal co -r DRUPAL-6-6 drupal'

      The .bash_aliases file is read by the ~/.bashrc file, you may need to make sure the following three lines are present:
      if [ -f ~/.bash_aliases ]; then
          . ~/.bash_aliases
      fi

      With the appropriate alias installed in your bash shell environment, updating modules in the filesystem AND the repository is as easy as:
      $ drush pm refresh
      $ drush pm update -synsync

      Then, run update.php, backup database state, test, and commit with drush -svncommit

    DrupalHK

    Group categories

    HKDUG Vocabulary

    Group notifications

    This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

    Hot content this week