Drush

How to use your custom php.ini in Drush

The following codes shows how can we tell Drush to use our custom php.ini:

  
$aliases['wf'] = array (
  'uri' => 'http://d8webfoobar.loc',
  'root' => 'C:/WinNMP/WWW/drupal',
  'php' => 'C:/WinNMP/bin/PHP/64bit-php-7.2/php.exe',
  'php-options' => '--php-ini=C:/WinNMP/conf',
);
  

To test, execute the following command:

  
drush @wf status
  

The screenshot is the output of the command above showing that the custom php.ini is already recognized by Drush:

Tags

Get Drush to run Drupal cron regularly using crontab

Drush can Drupal cron without the need of accessing http://www.yoursite.com/cron.php?cron_key=<key>. This means we can safely remove or redirect cron.php to 404 Not Found in our .htaccess:

  
RewriteRule cron.php / [R=404,L]
  

To make our crontab script simple, we will use Drush's site aliases. Example if we are running multiple sites in our server: yoursite1.com, yoursite2.com and yoursite3.com we can assign alias @site1, @site2 and @site3 respectively. To do this:

Tags