skip to Main Content

I install And run drush as explained in this article:
My server is cloudlinux and cagefs.drupal7

Drush Use global php.ini File instead of drish.ini file and this issue makes some errors for open_basedir and disable_finctions functions.

when I run drush status command.give me following:

> The following restricted PHP modes have non-empty values:           
> [error] open_basedir and disable_functions. This configuration is
> incompatible with drush.  Please check your configuration settings in
> /opt/cpanel/ea-php56/root/etc/php.ini or in your drush.ini file; see
> examples/example.drush.ini for details. is_dir(): open_basedir
> restriction in effect.                        [warning]
> File(/usr/share/drush/commands) is not within the allowed path(s):
> (/home/:/usr/lib/php:/usr/local/lib/php:/usr/local/bin:/usr/share/drush:/usr/share/drush/commands:/etc:/tmp)
> preflight.inc:518  PHP configuration      : 
> /opt/cpanel/ea-php56/root/etc/php.ini
>                            /home/username/.drush/drush.ini  PHP OS                 :  Linux  Drush script           :  /usr/local/bin/drush  Drush
> version          :  8.1.9  Drush temp directory   :  /tmp  Drush
> configuration    :  Drush alias files      :

So drush for me uses /opt/cpanel/ea-php56/root/etc/php.ini instead of /home/username/.drush/drush.ini

How Can I use drush.ini file instead of server php.ini file ?

I dont want edit global php.ini file for security reasone.

2

Answers


  1. Have you tried adding EXPORT PHP_INI=”/home/username/.drush/drush.ini” to your .bashrc file?

    Login or Signup to reply.
  2. This is quite an old question, but I suspect that it is one that many people still puzzle over. Here is a solution that works for me (I’m using Ubuntu linux 18.04, but this should work for any unix system.)

    1. Create a directory, e.g. /home/username/.drushrc
    2. In this directory, create a file named ‘php.ini’, containing the php settings that you want to override. For example:

      disable_functions=
      open_basedir=
      
    3. In your Drupal docroot directory, create a shell script, e.g. named ‘mydrush’, containing:

      #!/bin/sh
      PHP_INI_SCAN_DIR=:/home/username/.drushrc ./drush $*
      

      The PHP_INI_SCAN_DIR environment variable specifies additional directories that php will look in to find .ini files when it starts up. The colon at the start of the assignment means that the directory you specify will be appended to the existing list of directories that php scans.

    4. Make your shell script executable:

      $ chmod +x mydrush
      
    5. You can now call drush from your docroot directory using the command ./mydrush, for example:

      $ ./mydrush status
      

    Alternatively, you could set the environment variable PHP_INI_SCAN_DIR in your ~/.bashrc file. This would avoid the need for the ‘mydrush’ file, but it would change the php initialisation settings for every command-line invocation of php – not just when you’re running Drush – and that may not be what you want. If you do change ~/.bashrc, then you need to open a new window for the changes to take effect.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search