【问题标题】:Drush command(s) run on Drupal 6 sites, but not Drupal 7?Drush 命令在 Drupal 6 站点上运行,但在 Drupal 7 上不运行?
【发布时间】:2014-07-14 14:10:52
【问题描述】:

我遇到了客户的 Drupal 网站问题。他安装了许多 D6,还有一个他刚刚开始的新 D7。 所有这些网站都在同一个共享主机包中。

问题在于在 D7 站点上运行某些drush 命令。 D6 站点上没有问题。 D7网站上drush up的具体错误如下:

foo@bar [~/www/foo]# drush up
Command pm-update needs a higher bootstrap level to run - you will need to invoke drush   [error]
from a more functional Drupal environment to run this command.
Command pm-update needs the following modules installed/enabled to run: update.           [error]
The drush command 'up' could not be executed.                                             [error]
Drush was not able to start (bootstrap) the Drupal database.                              [error]
Hint: This may occur when Drush is trying to:
 * bootstrap a site that has not been installed or does not have a configured database. In
this case you can select another site with a working database setup by specifying the URI
to use with the --uri parameter on the command line. See `drush topic docs-aliases` for
details.
 * connect the database through a socket. The socket file may be wrong or the php-cli may
have no access to it in a jailed shell. See http://drupal.org/node/1428638 for details.

Drush was attempting to connect to:
 Drupal version         :  7.28
 Site URI               :  http://default
 Database driver        :  mysql
 Database username      :  username_foo
 Database name          :  database_foo
 PHP configuration      :
 PHP OS                 :  Linux
 Drush version          :  7.0-dev
 Drush temp directory   :  /tmp
 Drush configuration    :
 Drush alias files      :
 Drupal root            :  /home/foo/www/foo
 Site path              :  sites/default

我能找到的一切(实际上是错误消息中的link)都说解决方案是将settings.php文件中的host值从localhost更改为127.0 .0.1。但是,这不是我们的解决方案。

  • 前端站点连接数据库没有问题,drush 本身在很多情况下似乎也是如此。
  • drush sql-connect 将生成一个可用于连接 MySQL 的字符串。
  • drush sql-cli 将成功连接 MySQL
  • settings.php 文件肯定位于名为 default(路径:www/foo/sites/default)的文件夹中,我在指定 --root--uri 选项时遇到完全相同的错误。
  • Drush 最初是一个 ~5.x 版本,它也有同样的问题。我们更新到 ~7.x 以尝试消除错误。 settings.php 中的主机值一直是 localhost127.0.0.1,结果同样糟糕。

我们已验证 MySQL 可通过 PHP CLI 中的套接字使用。 Drush 是最新的并且是全新安装的。 Drupal 7 站点是全新安装的。

我很茫然。为什么这适用于 D6 站点,而不适用于 D7?有什么建议吗?

【问题讨论】:

    标签: php drupal drupal-7 drush


    【解决方案1】:

    您的 settings.php 文件是否位于名为“default”的文件夹中?如果没有,您可能需要使用 --uri=mysite.com-l mysite.com 告诉 Drush 在哪里可以找到它。

    有多种方法可以指定 Drush 将针对哪个 Drupal 站点。最基本的选项相当冗长;运行:

    $ drush --root=/path/to/drupal --uri=http://example.com status
    

    你可以用稍微不同的语法做同样的事情:

    $ drush /path/to/drupal#example.com status
    

    您还可以通过将 cwd 设置为包含您站点的 settings.php 文件的文件夹来隐式指定 Drupal 站点:

    cd /path/to/drupal/sites/default # 或 /path/to/drupal/sites/mysite.com,视情况而定

    $ drush status
    

    在上述所有情况下,如果 settings.php 位于名为“default”的文件夹中,则无需指定 --uri 组件;例如,您可以 cd /path/to/drupal 后跟 drush status,然后会找到正确的 Drupal 站点。如果 settings.php 不在名为“default”的文件夹中,则需要指定 --uri 或 cd 到包含 settings.php 文件的文件夹。

    Source

    【讨论】:

    • 感谢您给予希望,但 settings.php 肯定位于名为 default:www/foo/sites/default 的文件夹中,并且在指定 --root 和 --uri 选项时出现完全相同的错误。如果我 cd 进入 www/foo/sites/default 目录,仍然会出现同样的错误。 :(
    • 你启用更新模块了吗??
    • 从 UI 启用更新模块并尝试运行 drush up
    • 会尝试的。谢谢。
    • 尽你所能尝试,这就是我所做的。尝试从失败中吸取教训:)
    【解决方案2】:

    根据这条消息:

    pm-update 需要安装/启用以下模块才能运行:update

    Drush 需要启用更新模块,因此以下命令应该可以解决问题:

    drush -y en update
    

    【讨论】:

      猜你喜欢
      • 2021-02-22
      • 1970-01-01
      • 1970-01-01
      • 2019-01-22
      • 1970-01-01
      • 1970-01-01
      • 2015-02-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多