Hi,
Could someone help me to get Drush working
I am installing Drush using PUTTY on a Semi-Dedicated Basic hosting account. I was able to install Drush using PUTTY, but with some warnings. I also tried to update a test Drupal site, but it didn't work. I copied the log of both actions below.

I used these instructions to install DRUSH: Installing Drush On Any Linux Based Server Out There

What my server includes:

mylogin@mycpanel.com [~]# uname -a
Linux sds3.linuxhostingserver.com 2.6.32-504.3.3.el6.x86_64 #1 SMP Wed Dec 17 01                 :55:02 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
mylogin@mycpanel.com [~]# lsb_release -a
-jailshell: lsb_release: command not found
mylogin@mycpanel.com [~]# cat /etc/*release
cat: /etc/*release: No such file or directory
mylogin@mycpanel.com [~]# cat /etc/issue*
cat: /etc/issue*: No such file or directory
mylogin@mycpanel.com [~]# cat /proc/version
Linux version 2.6.32-504.3.3.el6.x86_64 (mockbuild@c6b8.bsys.dev.centos.org) (gc                 c version 4.4.7 20120313 (Red Hat 4.4.7-11) (GCC) ) #1 SMP Wed Dec 17 01:55:02 U                 TC 2014
mylogin@mycpanel.com [~]# pear version
PEAR Version: 1.9.5
PHP Version: 5.4.42
Zend Engine Version: 2.4.0
Running on: Linux sds3.linuxhostingserver.com 2.6.32-504.3.3.el6.x86_64 #1 SMP W                 ed Dec 17 01:55:02 UTC 2014 x86_64
mylogin@mycpanel.com [~]# pear channel-discover pear.drush.org
Adding Channel "pear.drush.org" succeeded
Discovery of channel "pear.drush.org" succeeded

Log of Drush Install

mylogin@mycpanel.com [~]# pear install drush/drush

Warning: popen() has been disabled for security reasons in Guess.php on line 242

Warning: fgets() expects parameter 1 to be resource, null given in Guess.php on                  line 243

Warning: pclose() expects parameter 1 to be resource, null given in Guess.php on                  line 252
downloading drush-6.2.0.0.tgz ...
Starting to download drush-6.2.0.0.tgz (505,989 bytes)
.............................done: 505,989 bytes
install ok: channel://pear.drush.org/drush-6.2.0.0
mylogin@mycpanel.com [~]#

Log of an attempted Drupal Update using Drush

mylogin@mycpanel.com [~/public_html/drupaltestsite]# drush up
exec() has been disabled for security reasons bootstrap.inc:638      [warning]
The following restricted PHP modes have non-empty values:                [error]
disable_functions. This configuration is incompatible with drush.
Please check your configuration settings in /usr/local/lib/php.ini or
in your drush.ini file; see examples/example.drush.ini for details.
exec() has been disabled for security reasons exec.inc:150             [warning]
exec() has been disabled for security reasons exec.inc:150             [warning]
exec() has been disabled for security reasons exec.inc:150             [warning]
unlink(/home/mylogin/php/drush/lib/package.xml): No such file or      [warning]
directory drush.inc:691
The drush command 'up' could not be found.  Run `drush cache-clear       [error]
drush` to clear the commandfile cache if you have installed new
extensions.
Drush needs a copy of the PEAR Console_Table library in order to         [error]
function, and the attempt to download this file automatically failed.
To continue you will need to download the 1.1.3 package from
http://pear.php.net/package/Console_Table, extract it into
/home/mylogin/php/drush/lib directory, such that Table.php exists at
/home/mylogin/php/drush/lib/Console_Table-1.1.3/Table.php.
mylogin@mycpanel.com [~/public_html/drupaltestsite]#

Can you tell me what I need to do to get DRUSH operating properly?
Best Wishes,
Stephen

Comments

Stephen Winters’s picture

In the log of the attempted Drupal Update (in previous message) I saw these instructions:

Drush needs a copy of the PEAR Console_Table library in order to         [error]
function, and the attempt to download this file automatically failed.
To continue you will need to download the 1.1.3 package from
http://pear.php.net/package/Console_Table, extract it into
/home/mylogin/php/drush/lib directory, such that Table.php exists at
/home/mylogin/php/drush/lib/Console_Table-1.1.3/Table.php.

So I went to this location:
http://pear.php.net/package/Console_Table/download/1.1.3

and I saw and used this code:
Easy Install
pear install Console_Table-1.1.3

Attempted Table Installion

Here is the log of my attempted table installation.

mylogin@mycpanel.com [~/php]# cd /php/drush/lib
mylogin@mycpanel.com [~/php/drush/lib]# pear install Console_Table-1.1.3
WARNING: "pear/Console_Color" is deprecated in favor of "pear/Console_Color2"
Did not download optional dependencies: pear/Console_Color, use --alldeps to download automatical           ly

Warning: popen() has been disabled for security reasons in Guess.php on line 242

Warning: fgets() expects parameter 1 to be resource, null given in Guess.php on line 243

Warning: pclose() expects parameter 1 to be resource, null given in Guess.php on line 252
pear/Console_Table can optionally use package "pear/Console_Color" (version >= 0.0.4)
downloading Console_Table-1.1.3.tgz ...
Starting to download Console_Table-1.1.3.tgz (9,253 bytes)
.....done: 9,253 bytes
install ok: channel://pear.php.net/Console_Table-1.1.3
mylogin@mycpanel.com [~/php/drush/lib]#

Best Wishes,
Stephen

Stephen Winters’s picture

Tried Drush Update again

I saw that the attempted table installation had some warning messages in the log. But, I thought I would try a Drush update again to see if it would work. This is a log of that attempted update.

mylogin@mycpanel.com [~/public_html/drupaltestsite]# drush up
exec() has been disabled for security reasons bootstrap.inc:638      [warning]
The following restricted PHP modes have non-empty values:                [error]
disable_functions. This configuration is incompatible with drush.
Please check your configuration settings in /usr/local/lib/php.ini or
in your drush.ini file; see examples/example.drush.ini for details.
exec() has been disabled for security reasons exec.inc:150             [warning]
exec() has been disabled for security reasons exec.inc:150             [warning]
exec() has been disabled for security reasons exec.inc:150             [warning]
unlink(/home/mylogin/php/drush/lib/package.xml): No such file or      [warning]
directory drush.inc:691
The drush command 'up' could not be found.  Run `drush cache-clear       [error]
drush` to clear the commandfile cache if you have installed new
extensions.
Drush needs a copy of the PEAR Console_Table library in order to         [error]
function, and the attempt to download this file automatically failed.
To continue you will need to download the 1.1.3 package from
http://pear.php.net/package/Console_Table, extract it into
/home/mylogin/php/drush/lib directory, such that Table.php exists at
/home/mylogin/php/drush/lib/Console_Table-1.1.3/Table.php.

Manually Installed Table

Since the log said that I need to manually install the table, I went to this location: http://pear.php.net/package/Console_Table and downloaded the 1.1.3 table. I then went into my Cpanel and uploaded the table zip file to /home/mylogin/php/drush/lib/ and extraced the file into that location. Then I attempted to clear the Drush cache, as shown in the log below. (I got interrupted yesterday morning in the middle of this and had to come back to this morning (1:43 am), so I'm not sure if I remember everything I did, have included the log anyway.

mylogin@mycpanel.com [~/public_html/drupaltestsite]# drush cache-clear drush
exec() has been disabled for security reasons bootstrap.inc:638      [warning]
The following restricted PHP modes have non-empty values:                [error]
disable_functions. This configuration is incompatible with drush.
Please check your configuration settings in /usr/local/lib/php.ini or
in your drush.ini file; see examples/example.drush.ini for details.
exec() has been disabled for security reasons exec.inc:150             [warning]
exec() has been disabled for security reasons exec.inc:150             [warning]
exec() has been disabled for security reasons exec.inc:150             [warning]
unlink(/home/mylogin/php/drush/lib/package.xml): No such file or      [warning]
directory drush.inc:691
The drush command 'cache-clear drush' could not be found.  Run `drush    [error]
cache-clear drush` to clear the commandfile cache if you have
installed new extensions.
Drush needs a copy of the PEAR Console_Table library in order to         [error]
function, and the attempt to download this file automatically failed.
To continue you will need to download the 1.1.3 package from
http://pear.php.net/package/Console_Table, extract it into
/home/mylogin/php/drush/lib directory, such that Table.php exists at
/home/mylogin/php/drush/lib/Console_Table-1.1.3/Table.php.

mylogin@mycpanel.com [~/public_html/drupaltestsite]# cd
mylogin@mycpanel.com [~]# drush cache-clear drush
exec() has been disabled for security reasons bootstrap.inc:638      [warning]
The following restricted PHP modes have non-empty values:                [error]
disable_functions. This configuration is incompatible with drush.
Please check your configuration settings in /usr/local/lib/php.ini or
in your drush.ini file; see examples/example.drush.ini for details.
exec() has been disabled for security reasons bootstrap.inc:638                                    [warning]
'drush' cache was cleared.                                                                         [success]

Morning Check

This morning I went into my Cpanel files section and verified that the table is located at: /home/mylogin/php/drush/lib/Console_Table-1.1.3/Table.php.

Now, to check the situation this morning, I cleared the drush cache and I also attempted a drush update so that I could get a current log printout:

Cleared Drush Cache

mylogin@mycpanel.com [~/public_html/drupaltestsite]# drush cache-clear drush
exec() has been disabled for security reasons bootstrap.inc:638      [warning]
The following restricted PHP modes have non-empty values:                [error]
disable_functions. This configuration is incompatible with drush.
Please check your configuration settings in /usr/local/lib/php.ini or
in your drush.ini file; see examples/example.drush.ini for details.
exec() has been disabled for security reasons bootstrap.inc:638        [warning]
exec() has been disabled for security reasons bootstrap.inc:638        [warning]
exec() has been disabled for security reasons bootstrap.inc:638        [warning]
'drush' cache was cleared.                                             [success]
mylogin@mycpanel.com [~/public_html/drupaltestsite]#

Attempted Drush Update

mylogin@mycpanel.com [~/public_html/drupaltestsite]# drush up
exec() has been disabled for security reasons bootstrap.inc:638      [warning]
The following restricted PHP modes have non-empty values:                [error]
disable_functions. This configuration is incompatible with drush.
Please check your configuration settings in /usr/local/lib/php.ini or
in your drush.ini file; see examples/example.drush.ini for details.
exec() has been disabled for security reasons bootstrap.inc:638        [warning]
exec() has been disabled for security reasons bootstrap.inc:638        [warning]
exec() has been disabled for security reasons bootstrap.inc:638        [warning]
exec() has been disabled for security reasons exec.inc:150             [warning]
proc_open() has been disabled for security reasons backend.inc:376     [warning]
proc_open() has been disabled for security reasons backend.inc:376     [warning]
mylogin@mycpanel.com [~/public_html/drupaltestsite]#

Stephen

Stephen Winters’s picture

Where is the usr folder?

In the log I see these instructions:

disable_functions. This configuration is incompatible with drush.
Please check your configuration settings in /usr/local/lib/php.ini or
in your drush.ini file; see examples/example.drush.ini for details.

I have looked all through the cPanel files section and can not find the "usr" folder, in which the php.ini file is supposed to be located. However, in looking through the Drush Status report (below) I see that there is a usr folder listed by PHP executable AND PHP configuration. Yet, I still haven't found it. I need to find it so that I can check my configuration settings.

Drush Status

This morning I discovered the Drush Status command.

mylogin@mycpanel.com[~/public_html/drupaltestsite]# drush status
exec() has been disabled for security reasons bootstrap.inc:638      [warning]
The following restricted PHP modes have non-empty values:                [error]
disable_functions. This configuration is incompatible with drush.
Please check your configuration settings in /usr/local/lib/php.ini or
in your drush.ini file; see examples/example.drush.ini for details.
exec() has been disabled for security reasons bootstrap.inc:638        [warning]
exec() has been disabled for security reasons bootstrap.inc:638        [warning]
exec() has been disabled for security reasons bootstrap.inc:638        [warning]
 Drupal version                  :  7.25
 Site URI                        :  http://default
 Database driver                 :  mysql
 Database username               :  ********
 Database name                   :  ********
 Database                        :  Connected
 Drupal bootstrap                :  Successful
 Drupal user                     :  Anonymous
 Default theme                   :  bartik
 Administration theme            :  seven
 PHP executable                  :  /usr/bin/php-cli
 PHP configuration               :  /usr/local/lib/php.ini
 PHP OS                          :  Linux
 Drush version                   :  6.2.0
 Drush configuration             :
 Drush alias files               :
 Drupal root                     :  /home/mylogin/public_html/drupaltestsite
 Site path                       :  sites/default
 File directory path             :  sites/default/files
 Temporary file directory path   :  /tmp

Stephen

Stefan Lehmann’s picture

I don't know much about the cPanel shell, but it looks like you'd have to edit the PHP configuration file to get drush running properly. It's probably rather a question for your hoster, if the php.ini can be edited and if so how.

I could imagine that they restrict access to that file in that shared environment and that you can't do much about it.

I like cookies!

Stephen Winters’s picture

Stefan, thanks for you input. I'm a little hesitant to contact the web host because, at this point, I don't know what I'd ask them to do. Because they are an India based company I have to be very specific in what I say to them, otherwise they don't understand. So, before I contact the web host I thought I'd do a little more research and see what I can figure out.

In doing more research I ran across this web page: [SOLVED] [HOWTO] How to install Drush via PHP PEAR on your cPanel/WHM shared hosting server account On the page I found a link to this page: http://www.6by9.net/drush-on-an-hosting-fix-using-custom-php-ini/ .
On that page
"The fix is easy – you simply have to give drush its own php.ini file with looser security. The benefit here is that the Apache web server will run PHP in a more locked-down mode, but drush will operate with full permissions. SSH into your server and run the following commands:"

mkdir -p ~/.drush
cp -i /usr/local/lib/php.ini ~/.drush/

Using PUTTY in my home directory I entered the above code. Then, to see if it changed anything, I again entered a Drush Status command:

mylogin@mycpanel.com [~]# mkdir -p ~/.drush
mylogin@mycpanel.com [~]# cp -i /usr/local/lib/php.ini ~/.drush/
mylogin@mycpanel.com [~]# drush status
exec() has been disabled for security reasons bootstrap.inc:638      [warning]
The following restricted PHP modes have non-empty values:                [error]
disable_functions. This configuration is incompatible with drush.
Please check your configuration settings in
/home/mylogin/.drush/php.ini or in your drush.ini file; see
examples/example.drush.ini for details.
exec() has been disabled for security reasons bootstrap.inc:638        [warning]
 PHP executable        :  /usr/bin/php-cli
 PHP configuration     :  /home/mylogin/.drush/php.ini
                          /home/mylogin/.drush/php.ini
 PHP OS                :  Linux
 Drush version         :  6.2.0
 Drush configuration   :
 Drush alias files     :
Stephen Winters’s picture

In comparing the above Drush Status readout and the previous one I see that most of the errors remained. However, one thing that I see that did change was that a new php.ini file location has been added:

PHP configuration : /usr/local/lib/php.ini
to
PHP configuration : /home/mylogin/.drush/php.ini

That puts the php.ini file in a position that I can access it. I don't have time to do anything else this morning, but I'll look again when I get back to this.
Stephen

Stephen Winters’s picture

Now that I have a php.ini file located where I can find it "/home/mylogin/.drush/php.ini" I opened the file in my cpanel editor. I followed the below instructions, found on the linked page:

http://www.6by9.net/drush-on-an-hosting-fix-using-custom-php-ini/

Edit the text file ~/.drush/php.ini and make sure the line with disable_functions is empty:

disable_functions =

That’s it! You can run drush status to make sure everything is working properly. If drush reports additional errors, you may need to make further changes to the php.ini file.

On line 188 in the php.ini file I found this text
disable_functions = "show_source, system, passthru, exec, popen, proc_open, allow_url_fopen"
I deleted everything on the right, so the line now looks like this:
disable_functions =
Then I saved the php.ini file.

Checked Drush Status again

I then logged back in with PUTTY and entered "Drush Status" and this is what is showed

mylogin@mycpanel.com  [~]# drush status
 PHP executable        :  /usr/bin/php-cli
 PHP configuration     :  /home/mylogin/.drush/php.ini
                          /home/mylogin/.drush/php.ini
 PHP OS                :  Linux
 Drush version         :  6.2.0
 Drush configuration   :
 Drush alias files     :

It looks incouraging, no error codes.

Another Test Drush Update

Now I navigated to my test website and did a Drush Update

mylogin@mycpanel.com [~/public_html/drupaltestsite]# drush up
 Name    Installed Version  Proposed version  Message
 Drupal  7.25               7.38              SECURITY UPDATE available


Update information last refreshed: Sat, 05/10/2014 - 16:03
Code updates will be made to drupal core.
WARNING:  Updating core will discard any modifications made to Drupal core files                           , most noteworthy among these are .htaccess and robots.txt.  If you have made an                           y modifications to these files, please back them up before updating so that you                            can re-create your modifications in the updated version of the file.
Note: Updating core can potentially break your site. It is NOT recommended to up                           date production sites without prior testing.

Do you really want to continue? (y/n): y
Project drupal was updated successfully. Installed version is now 7.38.
Backups were saved into the directory                                [ok]
/home/mylogin/drush-backups/mylogin_drupaltestsite/20150803210200/drupal.
 Block     7009  Increase {block}.title length to 255 characters.
 Node      7015  Enable node types that may have been erroneously disabled in
                 Drupal 7.36.
 Taxonomy  7011  Drop unpublished nodes from the index.
Do you wish to run all pending updates? (y/n): y
Performed update: taxonomy_update_7011                               [ok]
Performed update: node_update_7015                                   [ok]
Performed update: block_update_7009                                  [ok]
'all' cache was cleared.                                             [success]
Finished performing updates.                                         [ok]

SUCCESS, YEAH!!!!!

I finally should now be able to do the quick Drush updates on my sister's websites!!!

Stephen

Stefan Lehmann’s picture

Nice. Thumbs up! :-)

I like cookies!

mpulier’s picture

Great solution, Stephen Winters, good work! But some clarification and some mystery.

Since I already have a ".drush" directory, I used ssh and bash to run cp -i /usr/local/lib/php.ini ~/.drush/ and saw that line 188 of this new php.ini read "disable_functions =“. In other words, no functions are disabled there or in the /usr/ version.

When I then ran drush upc it worked with no warnings, but my site crashed: misconfigured somehow. To fix this I copied ".htaccess” from the backup drush had created. That got the site working OK. Drupal Reports suggested that drupal core was updated to 7.38; that maybe Cron should be triggered manually right now; and that PHP is using /usr/local/lib/php.ini .

My service provider Daily Razor said they use PHP extensions (“SLOG”, prohibiting "*exec|popen|system|passthru”; however, the Drush script is not using PHP’s “exec” but is calling "exec" via the bash shell. Oddly, drush ups produced a bunch of warnings that begin “slog_exec(): Access to function exec is denied exec.inc:150". I immediately did drush status and was rewarded with a satisfactory response. I then immediately again did drush ups and it worked with no warnings. Go figure! Somehow the shell manages to do its thing intermittently.

For me, the take-home is

  1. if you have shell access you may be able to update core with drush
  2. Stephen Winters solution may be necessary first
  3. .htaccess may need to be copied-in from the backup to get the updated site to work right
  4. repeated stabs at a mixture of drush commands may get stuff done eventually

Hope this helps someone.