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
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.drush
outside of folder works now (after MySQL fixes) as perdrush 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.