From 0 to Drupal with Drush on MacOSX 10.6+
Drush is a powerful scripting interface and shell for Drupal that lets you manage your Drupal systems quickly and easily from the command line. With just a few commands you can:
- Install and configure a brand new Drupal site
- Enable and disable modules
- Download and install new modules and plugins
- Test your Drupal site
- Backup, update and migrate your databases
- Control many supported modules
- And much much more…
Just thinking about all the clicking and waiting required to accomplish some of these tasks gives both my mouse hand a cramp and my head an ache.
This guide assumes that you have some familiarity with Unix and some Drupal experience, if not have no fear Web Courses Bangkok now offers both Drupal and Unix training online, and on location.
Download and install MAMP, it bundles Apache, MySQL and PHP
Fire up your trusty terminal, or the my personal favorite iTerm2
MAMP puts it’s webroot here: /Applications/MAMP/htdocs
We’re going to create a symbolic link for convenience, to save some typing
$ cd ~ $ ln -s /Applications/MAMP/htocs htdocs
Since we’re going to be using the Apache and Mysql commands that come with MAMP instead of installing our own, we need to add MAMPs binaries to our PATH. Edit your shell’s init script (.profile, .bashrc, .zshrc). I’m running zsh, so I added the following to the end of my .zshrc file:
Install the powerful package management system Homebrew by running the following command:
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.github.com/gist/323731)"
Install wget (web get) with Homebrew, this let’s you download stuff from the web directly to your shell directory
$ brew install wget
Download PEAR, PHP’s package management system
$ wget http://pear.php.net/go-pear.phar $ php -d detect_unicode=0 go-pear.phar
Make sure PEAR works, it should display a list of sub commands
If this doesn’t work make sure to add ‘Users/ACCOUNT/pear/bin’ to your shells PATH (as we did in step 2). I’m still running ZSH so I added the following to our recently added export line:
Don’t forget to replace ACCOUNT with your user account. Close and reopen your terminal if needed.
Install Drush with the following PEAR command
$ pear channel-discover pear.drush.org $ pear install drush/drush
Apply the following fix for the latest MAMP 2.0 found here
Create the missing directory:
$ sudo mkdir -p /Applications/MAMP/bin/php5/bin
Symlink to the proper binary
$ sudo ln -s /Applications/MAMP/bin/php/php5.2.17/bin/php /Applications/MAMP bin/php5/bin/php
Make sure you can execute it
$ sudo chmod a+x /Applications/MAMP/bin/php5/bin/php
Enter your htdocs folder and create a Drupal 7 website using Drush!
$ cd ~/htdocs $ drush dl drupal $ drush site-install standard --account-name=admin --account-pass=admin --dburl=mysql://root:root@localhost/YourMySQLDatabase
Visit you new Drupal website here http://localhost:8888/drupal-7.X
Replace the X with the version of drupal you installed with Drush.
Rejoice, you can now use drush!
Drupal Courses in Bangkok
To learn more and take your Drupal knowledge to the next level check out our Drupal and Unix training available both online, and on location.
Free SEO Guide
- An interview with Atikun, our new team member!
- Tutorial – Geometric Design Tool
- 10 ways to track time of your projects
- Some incredibly useful inspiration websites for designers and developers
- How to Install Custom Font on Your Website
- Tutorial: How to Create Your Own Custom Brushes in Illustrator
- 9 Ways to Keep your Website Running Smooth