Quantcast
Channel: Web Host
Viewing all articles
Browse latest Browse all 31

Installing drush for Drupal on cPanel/WHM Server or OS X Lion

$
0
0

Drush is a command line utility for administering Drupal websites, what you can do in the backend GUI you can do three times as fast on the command line. Version 5 of Drush can administer Drupal versions 6, 7 and 8. The only prerequiste that you need for this is command line access to your server. Learning Drush is quite easy, this tutorial covers the install and basic commands.

Getting Drush Installed on a cPanel/WHM Server

drush project page drupal

 
 - Go to the Drush project page and copy link address
 
 - Connect into your server via command line and go to your home directory
 
cd
 
- Get the drush tarball by pasting in the link copied above
 
wget http://ftp.drupal.org/files/projects/drush-7.x-5.8.tar.gz
Or in a Mac OS X Server since 'wget' is not installed by default use 'curl'
 
curl -O http://ftp.drupal.org/files/projects/drush-7.x-5.8.tar.gz
 
 - Extract it (the resulting folder will be named 'drush')
 
tar -zxvf drush-7.x-5.8.tar.gz
 
 - Remove the original archive file
 
rm drush-7.x-5.8.tar.gz 
 
Check that it has execution permissions for the user
 
chmod u+x drush/drush
 
Add it as an alias in .bash_profile or .bashrc
 
alias drush='~/drush/drush'
 
or in the path
 
PATH=$PATH:$HOME/bin:/root/drush
 
Reload the shell
 
source ~/.bash_profile
 
Test by typing drush at the command prompt and you should see all the available commands that you can use.
 
drush drupal commands
 
To verify that the installation is ok run:
 
# drush core-status
 
To display version number and php location - to see additional information about your Drupal Site run the command at the root level of your drupal install.
 
Thats pretty much there is to the install, to use it navigate to the Drupal installation and run the drush commands from there - so for example if you wanted to upgrade to the latest incremental version of Drupal and update all your modules:
 
cd home/public_html/
 
drush up
Drush up to date on Drupal
 
To update only specific modules you would run:
drush up modulename modulename
So the above example is updating 2 modules - the module name is the name in brackets lowercase and underscores as in the screen grab above.
 
To update just Drupal core you would run:
drush up drupal
If you get an error about the backup folder being a security risk, this may well be referring to 'Backup & Migrate' default backup folder, just rename it and set another one outside of the web root and then it will be OK.
 
To clear the Drupal cache:
 
drush cache-clear

The drush utility is very comprehensive to learn more check out the drush page.

 

BackUp and Restore

One command backups and restores - complete with files and database....could you ask for anymore?

drush archive-dump

drush archive-restore

For the restore you need to point directly to the archive and declare the current site and confirm the overwrite - like so (approximate path, depending on your host):

drush archive-restore /path-to-archive/archive-dump/date.20121010112546/site.date20121010_112546.tar.gz --destination=/home/pathtodomain/public_html/ --overwrite

It is good practice to always take a backup before an upgrade in particular an upgrade to core Drupal, do the archive-dump, do the upgrade and if it breaks you can restore very easily and when upgrading Drupal via Drush make sure you do it when you are in the document root of your Drupal install.

Upgr​ading drush

To upgrade drush when new versions are released on a cPanel server it still has to be done via the command line using the command as below:

drush dl drush --destination=/path/to-the-drush-install-folder/

 

"Install location /root/drush already exists. Do you want to overwrite it? (y/n): y"
                                                                                                                          
"Drush successfully updated to version 7.x-5.8.  "
 

Using drush as root

If you use drush as the root user on a domain in a multi domain VPS type server and update Drupal/modules  - this will remove the regular user/group names of the domain and assign unknown owner/groups in random number strings which will cause major errors.

You will need to reissue the user + group names to the file and folders of the domains including the .htaccess files

chown -R user:group *
chown -R user:group .htaccess

Viewing all articles
Browse latest Browse all 31

Trending Articles