3

I keep getting the following error, although I've turned off SafeMode in my .ini file, and confirmed it's off with a PHP status page.

The following restricted PHP modes have non-empty values: open_basedir. This configuration is incompatible with drush. Please check your configuration settings in /usr/local/php-5.2.17/etc/php.ini or in your drush.ini file;

safe_mode            Off        Off
memory_limit        168M       168M
open_basedir    no value   no value

UPDATE: I think it's worth noting that this is on MediaTemple's Grid Service (gs). It looks like the PHP CLI is actually using a different .ini file with open_basedir set. So I'm still trying to figure that part out.

1

6 Answers 6

3

My solution was to add this line to my .bash_profile

alias drush='/usr/bin/php5 -c /home/000000/etc/drush.ini ~/bin/drush/drush.php'

It turns out the CLI on MediaTemples Grid Service uses a different PHP.ini file. So that line basically tells it to find your drush.ini file to override some settings. Make sure to replace the 000000 in with your server number. Thanks to kiamlaluno and MediaTemples support folks for the help.

2
  • Making an alias to drush is discouraged in Drush-5. Drush-4 has this advice: Feb 17, 2012 at 0:26
  • Making an alias to drush.php is not covered in the Drush-5 README.txt because it is hard to get right; calling the drush script and using drush.ini is easier. The README.txt in Drush-4 has some advice on how to correctly make an alias to drush.php; please consult that before following the advice above. You must include a --php= option, etc.; if you do not call Drush correctly, then certain commands will fail (e.g. pm-update). Feb 17, 2012 at 0:38
2

The error you are seeing is reported by Drush, which verifies the "open_basedir" directive contains an empty value, and returns an error if the value is not empty.

Drush can use the php.ini file used by PHP or its own INI file ("drush.ini"), which is looked for in the following directories:

  1. Drush installation folder
  2. User's .drush folder (i.e. "~/.drush/drush.ini")
  3. System wide configuration folder (i.e. "/etc/drush/drush.ini")

The code I am referring to is contained in the _drush_environment_check_php_ini() function, and it is the following one:

  $ini_checks = array('safe_mode' => '', 'open_basedir' => '', 'disable_functions' => array('exec', 'system'), 'disable_classes' => '');

  // Test to insure that certain php ini restrictions have not been enabled
  $prohibited_list = array();
  foreach ($ini_checks as $prohibited_mode => $disallowed_value) {
    $ini_value = ini_get($prohibited_mode);
    $invalid_value = FALSE;
    if (empty($disallowed_value)) {
      $invalid_value = !empty($ini_value);
    }
    else {
      foreach ($disallowed_value as $test_value) {
        if (strstr($ini_value, $test_value) !== FALSE) {
          $invalid_value = TRUE;
        }
      }
    }
    if ($invalid_value) {
      $prohibited_list[] = $prohibited_mode;
    }
  }
  if (!empty($prohibited_list)) {
    drush_log(dt('The following restricted PHP modes have non-empty values: !prohibited_list. This configuration is incompatible with drush.  !php_ini_msg', array('!prohibited_list' => implode(' and ', $prohibited_list), '!php_ini_msg' => _drush_php_ini_loaded_file_message())), 'error');
  }

As you can see, the function returns an error if the "safe_mode" directive, or the "open_basedir" directive contains a non-empty value.

3
  • I guess I understand that. It's more confusion because my PHP.ini clearly has no value for open_basedir and safe_mode is off and I've verified those settings through the browser. Sorry if this is basic server setup but is Drush looking at a different PHP.ini than the browser or something? If so what steps would I take to find the .ini file that Drush is using?
    – Eric I.E.
    Sep 1, 2011 at 12:14
  • I am sorry: I forgot replying about that. What I mean in my answer is that Drush doesn't check if the safe mode is enabled, and then check if the "open_basedir" directive contains any value.
    – apaderno
    Sep 1, 2011 at 12:45
  • That makes sense. I checked open_basedir by running php -i in the console and it is indeed using a different php.ini for the CLI than the website. So it has open_basedir => /nfs:/tmp:/usr/local:/etc/apache2/gs-bin => /nfs:/tmp:/usr/local:/etc/apache2/gs-bin
    – Eric I.E.
    Sep 1, 2011 at 13:29
2

@Eric I.E. You're correct. That way solves the issue. But we do need to make a copy of drush.ini from http://drupalcode.org/project/drush.git/blob_plain/refs/heads/master:/examples/example.drush.ini Also make sure "open_basedir = " on an uncommented line.

1

For those who couldn't fill in the missing blanks here, your drush.ini file will need the line, in addition to being sourced from the alias in .bash_profile:

open_basedir = 
1

install drush on CentOS with Plesk

I tried to install drush 7.x-5.9 on on a CentOS system with the Plesk panel.

I was still getting this error:

drush

sh: /tput: No such file or directory The following restricted PHP modes have non-empty values: safe_mode. [error] This configuration is incompatible with drush. Please check your configuration settings in /etc/php.ini or in your drush.ini file; see examples/example.drush.ini for details. sh: /wget: No such file or directory Unable to create a temporary directory.
[error] tempnam(): Unable to access filesystem.inc:461
[warning] sh: /curl: No such file or directory

This is how I fixed it

sudo -s
wget http://ftp.drupal.org/files/projects/drush-7.x-5.9.tar.gz    
tar -zxf drush-7.x-5.9.tar.gz  -C /usr/local/share    
ln -s /usr/local/share/drush/drush /usr/bin/drush    
cd /usr/local/share/drush    
cp ./examples/example.drush.ini drush.ini   
vi drush.ini

Uncomment the following lines (at the bottom) by removing the ";" on the beginning of the line.

safe_mode =
open_basedir =

save the file

Tell dush to use this ini file export DRUSH_INI='/usr/local/share/drush/drush.ini' Add above line also to your ~/.bashrc file

0

Because (as @greg_1_anderson said) making an alias for drush.php is not covered in drush-5.x Readme file. A better solution is to copy the server's default configuration php.ini file to $HOME/.drush or to /etc/drush.

Then, edit it to set open_basedir to no value and add any other custom configuration for drush.

Also, check this answer for php.ini code sample.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.