1

I'm attempting to to install Drush 9 on Media Temple (shared hosting). We have a number of Drupal 7 (D7) sites on the server, and we've just recently started to migrate them to Drupal 8 (D8). Drush is already installed globally for the D7 sites, so I created the alias "drush9" for the D8 sites, using the following line in my .bash_profile:

alias drush9="~/domains/sitename.com/vendor/bin/drush"

But when I ran drush9 it returned this error:

Failed loading /usr/local/php-5.6.21/lib/php/20131226/php_opcache.so:  /usr/local/php-5.6.21/lib/php/20131226/php_opcache.so: cannot open shared object file: No such file or directory
The following restricted PHP modes have non-empty values:            [error]
open_basedir. This configuration is incompatible with drush.  Please
check your configuration settings in /home/999/etc/php.ini or in
your drush.ini file; see examples/example.drush.ini for details.
Execute a drush command. Run `drush help [command]` to view command-specific help.  Run `drush
topic` to read even more documentation.

I had tried to enable opcache a while ago, but apparently that library doesn't exist on the server. So, in order to eliminate this error, I disabled opcache in the php.ini.

Once disabled, I ran drush9 again, and got the following error:

The following restricted PHP modes have non-empty values: {open_basedir}. This configuration is incompatible with drush.  {Please check your configuration settings in /home/999/etc/php.ini or in your drush.ini file; see examples/example.drush.ini for details.}

After searching Stack Exchange, I found a solution to this error: Drush Open_BaseDir Error Thus, I altered my drush9 alias as such:

alias drush9="/usr/bin/php5 -c ~/domains/sitename.com/vendor/bin/drush"

Now when I run drush9, it barks about PHP deprecations:

PHP Deprecated:  Comments starting with '#' are deprecated in /nfs/c11/h04/mnt/999/domains/sitename.com/vendor/drush/drush/drush on line 1 in Unknown on line 0

This error doesn't seem right to me. I haven't altered any of the drush files, so there shouldn't be anything wrong with them. Also, drush works perfectly in my local environment. Nonetheless, I tried replacing the "#" with a ";" and the deprecation error went away, but the drush9 command wont execute. It doesn't throw any errors, it just idles.

Is there something I'm missing? Is there a best practice for installing drush 9 on a production server? Any tips are appreciated.

In case it's useful, I'm using drupalvm on my local. Drush is installed automatically with composer when the vm is spun up. I then transported the generated drush files onto the server via git.

Edit: Following Greg's advice, I corrected my drush alias. It's now entered as alias drush9='/usr/bin/php5-latest -c /home/###/etc/php.ini /home/###/domains/sitename/vendor/bin/drush. Unfortunately, it did not solve my issue. Running drush9 now throws no errors, but the command does not successfully execute. It spins endlessly.

I've also tried installing the drush launcher. I did a wget on my server, and then I pointed the alias "drush90" to the file drush.phar file location. Running drush90 outside of site directories returns:

    The Drush launcher could not find a Drupal site to operate on. Please do *one* of the following:
  - Navigate to any where within your Drupal project and try again.
  - Add --root=/path/to/drupal so Drush knows where your site is located.
  - Add a site alias so Drush knows where your site is located.

It seems to be hooked up properly, given what it returns, but running it in a site directory doesn't work. Similar to my drush9 alias, running drush90 does not successfully run drush. It spins endlessly, failing to execute, and does not throw errors.

Edit: Running drush9 -vvv -d status outside of the website directory returns:

    [bootstrap] Drush bootstrap phase: bootstrapDrupalDatabase() [0.41 sec, 9.89 MB]
 [bootstrap] Successfully connected to the Drupal database. [0.41 sec, 9.89 MB]
 [bootstrap] Drush bootstrap phase: bootstrapDrupalFull() [0.41 sec, 9.89 MB]
 [debug] Start bootstrap of the Drupal Kernel. [0.41 sec, 9.89 MB]
 [debug] Finished bootstrap of the Drupal Kernel. [0.57 sec, 14.94 MB]
 [debugnotify] Add a commandfile class: Drush\Drupal\Commands\config\ConfigCommands [0.68 sec, 17.47 MB]
 [debugnotify] Add a commandfile class: Drush\Drupal\Commands\config\ConfigExportCommands [0.69 sec, 17.53 MB]
 [debugnotify] Add a commandfile class: Drush\Drupal\Commands\config\ConfigImportCommands [0.7 sec, 17.56 MB]
 [debugnotify] Add a commandfile class: Drush\Drupal\Commands\core\BatchCommands [0.7 sec, 17.59 MB]
 [debugnotify] Add a commandfile class: Drush\Drupal\Commands\core\CliCommands [0.7 sec, 17.6 MB]
 [debugnotify] Add a commandfile class: Drush\Drupal\Commands\core\DrupalCommands [0.71 sec, 17.61 MB]
 [debugnotify] Add a commandfile class: Drush\Drupal\Commands\core\ImageCommands [0.71 sec, 17.64 MB]
 [debugnotify] Add a commandfile class: Drush\Drupal\Commands\core\LocaleCommands [0.71 sec, 17.66 MB]
 [debugnotify] Add a commandfile class: Drush\Drupal\Commands\core\QueueCommands [0.72 sec, 17.68 MB]
 [debugnotify] Add a commandfile class: Drush\Drupal\Commands\core\RoleCommands [0.72 sec, 17.71 MB]
 [debugnotify] Add a commandfile class: Drush\Drupal\Commands\core\StateCommands [0.73 sec, 17.76 MB]
 [debugnotify] Add a commandfile class: Drush\Drupal\Commands\core\UserCommands [0.73 sec, 17.79 MB]
 [debugnotify] Add a commandfile class: Drush\Drupal\Commands\core\ViewsCommands [0.74 sec, 17.86 MB]
 [debugnotify] Add a commandfile class: Drush\Drupal\Commands\core\WatchdogCommands [0.74 sec, 17.92 MB]
 [debugnotify] Add a commandfile class: Drush\Drupal\Commands\pm\PmCommands [0.75 sec, 17.97 MB]
 [debugnotify] Add a commandfile class: Drush\Drupal\Commands\pm\ThemeCommands [0.76 sec, 18.01 MB]
 [debugnotify] Add a commandfile class: Drush\Drupal\Commands\sql\SanitizeCommands [0.76 sec, 18.02 MB]
 [debugnotify] Add a commandfile class: Drush\Drupal\Commands\sql\SanitizeCommentsCommands [0.76 sec, 18.03 MB]
 [debugnotify] Add a commandfile class: Drush\Drupal\Commands\sql\SanitizeSessionsCommands [0.76 sec, 18.05 MB]
 [debugnotify] Add a commandfile class: Drush\Drupal\Commands\sql\SanitizeUserFieldsCommands [0.77 sec, 18.06 MB]
 [debugnotify] Add a commandfile class: Drush\Drupal\Commands\sql\SanitizeUserTableCommands [0.77 sec, 18.07 MB]
 Drupal version   : 8.4.2                                                                
 Site URI         : default                                                              
 DB driver        : mysql                                                                
 DB hostname      : internal-db.s###.gridserver.com                                   
 DB port          :                                                                      
 DB username      : db###                                                             
 DB name          : db###_analytics                                                   
 Database         : Connected                                                            
 Drupal bootstrap : Successful                                                           
 Default theme    : nellek                                                               
 Admin theme      : seven                                                                
 PHP binary       : /usr/local/php-7.0.6/bin/php                                         
 PHP config       : /nfs/c11/h04/mnt/###/etc/php.ini                                  
                    /nfs/c11/h04/mnt/###/users/.home/.drush/drush.ini                 
 PHP OS           : Linux                                                                
 Drush script     : /home/###/domains/sitename/vendor/bin/drush   
 Drush version    : 9.0.0-beta7                                                          
 Drush temp       : /tmp                                                                 
 Drush configs    : /nfs/c11/h04/mnt/###/domains/sitename/vendor/ 
                    drush/drush/drush.yml                                                
 Drush aliases    :                                                                      
 Install profile  : standard                                                             
 Drupal root      : /nfs/c11/h04/mnt/###/domains/sitename/web     
 Site path        : sites/default                                                        
 Files, Public    : sites/default/files                                                  
 Files, Temp      : /tmp 

Running drush9 cr outside of the website directory errors out:

    drush9 cr

Fatal error: Uncaught TypeError: Return value of Doctrine\Common\Annotations\AnnotationRegistry::reset() must be an instance of Doctrine\Common\Annotations\void, none returned in /nfs/c11/h04/mnt/###/domains/sitename/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationRegistry.php:55
Stack trace:
#0 /nfs/c11/h04/mnt/###/domains/sitename/web/core/lib/Drupal/Component/Annotation/Plugin/Discovery/AnnotatedClassDiscovery.php(113): Doctrine\Common\Annotations\AnnotationRegistry::reset()
#1 /nfs/c11/h04/mnt/###/domains/sitename/web/core/lib/Drupal/Core/Entity/EntityTypeManager.php(106): Drupal\Component\Annotation\Plugin\Discovery\AnnotatedClassDiscovery->getDefinitions()
#2 /nfs/c11/h04/mnt/###/domains/sitename/web/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php(174): Drupal\Core\Entity\EntityTypeManager->findDefinitions()
#3 /nfs/c11/h04/mnt/###/domains/sitename/web/core/lib/Drupal/Componen in /nfs/c11/h04/mnt/###/domains/sitename/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationRegistry.php on line 55
 [error]  Drush command terminated abnormally due to an unrecoverable error.
Error: Uncaught TypeError: Return value of Doctrine\Common\Annotations\AnnotationRegistry::reset() must be an instance of Doctrine\Common\Annotations\void, none returned in /nfs/c11/h04/mnt/###/domains/sitename/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationRegistry.php:55
Stack trace:
#0 /nfs/c11/h04/mnt/###/domains/sitename/web/core/lib/Drupal/Component/Annotation/Plugin/Discovery/AnnotatedClassDiscovery.php(113): Doctrine\Common\Annotations\AnnotationRegistry::reset()
#1 /nfs/c11/h04/mnt/###/domains/sitename/web/core/lib/Drupal/Core/Entity/EntityTypeManager.php(106): Drupal\Component\Annotation\Plugin\Discovery\AnnotatedClassDiscovery->getDefinitions()
#2 /nfs/c11/h04/mnt/###/domains/sitename/web/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php(174): Drupal\Core\Entity\EntityTypeManager->findDefinitions()
#3 /nfs/c11/h04/mnt/###/domains/sitename/web/core/lib/Drupal/Componen in /nfs/c11/h04/mnt/###/domains/sitename/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationRegistry.php, line 55
  • @kenorb I apologize, it does point to drush, but I failed to copy the entire path when I updated my post. I just updated my post to reflect the actual path being used. – Kellen Nov 8 '17 at 15:50
  • @kenorb That's part of why this is so difficult to troubleshoot. I can't determine what the issue is because drush9 simple won't execute. Even with those flags attached, no logs or messages are generated. I'm forced to cancel the drush command using Control+C. Oddly enough, it executes when I run it outside of the website root. I'll paste what it returns in my next comment. – Kellen Nov 8 '17 at 16:04
  • @kenorb I am on macOS, but Control+T doesn't return anything. Wouldn't that command depend on what the server environment is running? The process remains stuck. I've pasted what verbose returns, running drush9 outside of the website directory. See my post above ^ – Kellen Nov 8 '17 at 16:13
  • 1
    Your output doesn't look like it's ran outside of Drupal, as it's connecting to your db (Connected) and recognises your Site path (sites/default). Are you sure you're running it outside of website directory? Can you post similar output when you're running it within Drupal folder? For sure it should display anything. – kenorb Nov 8 '17 at 17:08
  • 1
    What you're trying to solve now? As it seems running drush outside of folder works now (after MySQL fixes) as per drush status. drush cr errors sounds like problems with the code which needs to addressed (ideally as a separate question, as it could generate further errors after that), could be related to PHP incompatibility. Secondly you're mixing PHP 5.6 with 7.x in your outputs, so you need to decide on one version on which your website works correctly. It seems you've multiple config and code issues, so it would be good if you clarify which one is your main issue and focus on that. – kenorb Nov 8 '17 at 17:51
2
+50

You've multiple configuration issues which you should solve them one by one.


ERROR 2002 (HY000): Can't connect to local MySQL server through socket /var/run/mysqld/mysqld.sock.

Make sure your MySQL server is up-and-running and that your socket file exists at /var/run/mysqld/mysqld.sock. If the service is running correctly, but your socket path is not correct, you can either change it in php.ini or in your settings file.

Check your SQL connection by:

drush sql-connect

and make sure you're using the right details.

Also make sure that MySQL and PHP are using the same socket file. Check by these commands:

mysql_config --socket
php -i | grep -w default_socket # Use /usr/bin/php5 in your case.

See also: I've got `PDOException: SQLSTATE[HY000] [2002] No such file or directory` when using drush


Fatal error: Uncaught TypeError: Return value of Doctrine...

This is related that you're running your Drush under PHP 7.0.x where Doctrine\Common\Annotations uses syntax introduced in PHP 7.1.source

This also shows that your alias actually doesn't run Drush under PHP5.6 as you would expect.


The drush process remains stuck.

You should run drush with -vvv (verbose) and -d (debug) flags to check for any issues.

If the process is still completely stuck, you can use debugger such as strace on Linux to find more details about it, e.g.

strace -f /path/to/php drush status
  • 1
    I really appreciate all of your help so far. So, I solved the error being thrown when running drush9 -vvv -d status outside of the website directory. I've update the output that command produces. See my original post. I checkout the MySQL and PHP sockets. MySQL returns: /var/run/mysqld/mysqld.sock and PHP returns: mysql.default_socket => no value => no value mysqli.default_socket => no value => no value pdo_mysql.default_socket => /var/run/mysqld/mysqld.sock => /var/run/mysqld/mysqld.sock – Kellen Nov 8 '17 at 16:58
3

You have a typo in your alias above. The -c flag should be followed by the path to your php.ini file.

alias drush9='/usr/bin/php5 -c /path/to/php.ini ~/domains/sitename.com/vendor/bin/drush

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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