How To fix the Drush error "exec() has been disabled for security reasons bootstrap.inc"

  • Posted on: 5 October 2015
  • By: Michael

I occasionally have to deal with shared hosting. Which I'll admit, I'm not real happy about as I generally have to install a bunch of my default tools, most of which then have to be 'fixed' to work on [insert cheap hosting firm's name]'s concept of security.

As I just did this (again), here is the 'patch' for drush to make it 'play nice.'

Summary Procedure

Copy php.ini to a drush usable location and edit for your problems.

Detailed Procedure

The Error:

# drush status
exec() has been disabled for security reasons bootstrap.inc:645      [warning]
exec() has been disabled for security reasons bootstrap.inc:645      [warning]
 PHP executable        :  /usr/bin/php-cli       
 PHP configuration     :  /usr/local/lib/php.ini 
 PHP OS                :  Linux                  
 Drush version         :  6.6.0                  
 Drush configuration   :                         
 Drush alias files     : 

Your first step is to identify where your existing php.ini is. Thankfully the drush status above tells you, "/usr/local/lib/php.ini".

Your next step depends on if you are on shared or dedicated hosting.

For Shared Hosting:

Copy your system php.ini to either $HOME/.drush or your actual drush directory.

For Dedicated Server:

Copy your system php.ini to /etc/drush/php.ini.

Then remove 'exec' from the 'disable_functions' list in the php.ini you've copied.

$ grep disable php.ini 
; This directive allows you to disable certain functions for security reasons.
disable_functions = show_source, system, shell_exec, passthru, popen, proc_open

Afterwards they should look like:

$ grep disable php.ini 
; This directive allows you to disable certain functions for security reasons.
disable_functions = show_source, system, shell_exec, passthru, popen, proc_open
 
$ drush status
 PHP executable        :  /usr/bin/php-cli                      
 PHP configuration     :  /etc/drush/php.ini /etc/drush/php.ini 
 PHP OS                :  Linux                                 
 Drush version         :  6.6.0                                 
 Drush configuration   :                                        
 Drush alias files     : 

# # #

All for today!

Michael

Footnotes:

As I want want all users on my servers to use the same drush php.ini, I place drush's php.ini in /etc/drush.

Comments

You can also do this in your ~/.drush/drush.ini Just uncomment the line:
;disable_functions =
by removing the semicolon.
Clear the Drush cache with:
drush cc all
then run
drush st
If you see your drush.ini file listed in the section "PHP configuration" then you should be good to go, otherwise set the environmental variable DRUSH_INI to the path to your drush.ini file DRUSH_INI=/home/username/.drush/drush.ini
Clear Drush's cache again and then check the status to ensure that Drush now sees your php.ini overrides in drush.ini

For more information on this from Drush itself run:
drush docs-ini-files
If you do not have a drush.ini you can create one by running:
drush docs-ini-files > ~/.drush/drush.ini

testing new comment display, will be deleted

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
CAPTCHA
You know what to do...
2 + 11 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.