Last updated: Dec 21, 2014
Table of Contents
IntroductionI LOVE Drupal for creating websites. I am not quite an expert yet, I have created 3 or 4, but I have learned a great deal and I will share that with you here. I also have been using it since Drupal 5 I also plan on updating this site to Drupal once I clear out my backlog of stuff to add.
If you feel any of the content in this document is wrong or there is something that I should add, I would appreciate it if you would contact me and let me know. Thanks!
[Table of Contents]
DrushOne of the best things about Drupal, is the command line tool Drush which is short for drupal shell. This makes administering a Drupal site much easier, although you should be somewhat familiar with the command line (don't fear the command line!). Below are some useful tips and commands (for version 5) for Drush that I have come across. Also, make sure you are in the root of your Drupal site directory when you are executing drush commands, otherwise you will get strange error messages.
- It is recommend you install Drush via the PHP package tool PEAR. These are the commands I used to successfully install it on both Ubuntu and CentOS based systems:
- sudo pear channel-discover pear.drush.org
- sudo pear install drush/drush
- I do NOT recommend installing via the OS'es package management tool (ie. apt-get or yum). I did this the first time and I had problems with it. I removed it and installed the PEAR version and so far so good. For more install instructions, check here.
- If you are using Drush with xampp and get the following message when trying to do something in drush Drush was not able to start (bootstrap) the Drupal database and the debug command drush -d 3 shows this error message SQLSTATE[HY000]  Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' a quick hack to get this working is find out where xampp is using the mysql socket with the command: ps -ef | grep mysql.sock and make a link to it with sudo ln -s /opt/lampp/var/mysql/mysql.sock /var/run/mysqld/mysqld.sock
Note - I had to create the dir "/var/run/mysqld" first. Make sure you replace "/opt/lampp" with the location you have xampp installed. Also if you are running another instance of mysql on the same box this will mess it up.
Upgrading a new minor Drupal release - Drupal occassionally comes out with security updates. I keep a development version of my websites to test first before making any changes on the production sites. Here is the method I use to update the development site first then the production site using Drush:
- First use the Backup and Migrate module within Drupal (you have this installed right? If not, then install it with Drush using the command: drush dl backup_migrate and drush en backup_migrate), which is located under the menu "Configuration->System->Backup and Migrate" to save the most recent version of your database.
- I then use the Backup/Migrate module on my dev environment to restore the latest version of the database I just saved on the production. If it has been awhile I will also make sure I have all of the same Drupal modules installed.
- Go through the dev site and make sure everything is ok.
- Update just the modules: drush up --no-core (drush pm-update --no-core)
- Test the dev site again and make sure everything is still ok.
- Update core on dev: drush up (drush pm-update)
- Test the dev site one last time and make sure everything is still ok.
- Check if the new vesion shows correctly: drush st (drush core-status)
- If everything is good on the dev site, I perform the same commands on the production site.
- Install Drupal via Drush:
- Change into the directory you want to install drupal: cd
- Download drupal: drush dl drupal
- Check the status of your Drupal install: drush st
- Download a new module: drush dl <module name>
*Note, sometimes it is confusing to determine what the name of the module is to download. I found if you go to the module's page on drupal.org, the ending of the url is what you want to use. For example, for the module "CKEditor Link" the url is: http://drupal.org/project/ckeditor_link so to download it with drush use the command: drush dl ckeditor_link
- Enable the module you just downloaded: drush en
- You can combine the download and enabling of modules in one command:
drush en <module name> (if drush can't find the module, it will ask if you want to download it)
- Check the version of drush you are running: drush --version
- Have drush update itself: drush self-update
- Main Drush Support Page (with links to documentation and where to go for help)
- All Drush Commands
- Drush FAQ (a bit old but still mostly relevant)
[Table of Contents]