[Drupal] How to clear cache effectively on a Multi-site?

| | 1 min read

If you have a multi-site installation that has multiple settings.php files, say '/sitename1.com/settings.php' and '/sitename2.com/settings.php' and so on. Trying to run Drush commands to clear cache from different directories and changing directories all the time is going to be a mess.

If you run a Drush command from the root directory, you will probably run into errors instead. Because, all what you need is a valid Drupal installation to run Drush command against and you are not telling where to look for the 'sites/default/settings.php' file.

Do you want to clear cache from any directory of your multi-site without any issues? If yes, here is a real quick solution for you.

If it is from the root folder, use just the --uri (URI of the drupal site to use) option with 'drush cc all' command. For example, clearing cache on a site called mysite.com:

$drush --uri=http://sitename.com cc all 

If it is from outside of the root directory, add --root (path to the root directory) as well to tell Drush command.

drush --root=/home/public_html/mysite --uri=sitename.com  cc all