如何用Drush (notes )更新Drupal 7网站
MARCY
・9 分钟阅读
>
这是我刚刚更新Drupal 7网站的方式Drush ,请注意,下面一些命令的输出是Drupal8的早期版本,但是这些命令也可以与Drupal7一起使用。
首先,执行以下操作:
- 备份Drupal 7数据库和文件
- 备份站点特定文件
- .htaccess
- robots.txt
- sites/default/settings.php
然后运行以下命令:
drush sset system.maintenance_mode 1
drush cr
drush up drupal
drush updb
drush entup
drush sset system.maintenance_mode 0
drush cr
如果没有数据库或实体更新,则不需要中间的那两个命令,因此你可能只需要运行以下drush命令:
drush sset system.maintenance_mode 1
drush cr
drush up drupal
drush sset system.maintenance_mode 0
drush cr
也就是说,如果不确定的话,运行这些命令没有害处。
作为一个重要提示,我使用Drush 8运行这些命令。看起来命令与Drush 9.不同
注意:我创建了一个名为drush8的别名来运行这些命令,因为它们与Drush 8一起运行,(使用Drush 8更新Drupal 7网站有点令人困惑,),
这是如何使用Drush更新Drupal7网站的简短答案,如果你对更多信息感兴趣,请参阅下面的,(注释是晦涩的,但希望有用。)
从drush update drupal命令输出
以下是运行drush up drupal
命令的输出:
$ drush up drupal
Update information last refreshed: July 22, 2017 - 12:00pm
Name Installed Version Proposed version Message
Drupal 8.3.4 8.3.5 Update available
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 any
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 update
production sites without prior testing.
Do you really want to continue? (y/n): y
Project drupal was updated successfully. Installed version is now 8.3.5.
Backups were saved into the directory /root/drush-backups/.../20170722180058/drupal. [ok]
No database updates required
(Note: Even though it says no database updates are required, I attempted them
to see what would happen.)
$ drush updb
No database updates required [success]
$ drush entup
No entity schema updates required [success]
Cache rebuild complete. [ok]
Finished performing updates.
关于Drupal 7Drush过程和命令的注释
有一个官方Drupal 7更新文档链接 。
整个过程相关的注释:
- 要确定哪些软件包可以更新(不改变东西),请执行以下操作:
drush ups
(aka,drush pm-updatestatus
),
- 在运行数据库备份之前清除缓存
drush cr
(或drush cc all
,如果你愿意),
- 将Drupal 7站点置于维护模式
drush sset system.maintenance_mode 1
- Drupal 7命令:
drush vset --exact maintenance_mode 1
drush cache-clear all
- 更新drupal核心
drush up drupal
(与:drush pm-update drupal
相同)- 注意:
drush pm-update
与运行drush pm-updatecode
和drush updatedb
相同
- 若要更新单个模块,如视图模块,请执行下列操作:
drush up views
- 仅应用安全更新:
drush up --security-only
- 应用必需的数据库和实体更新(理论上这不是必需的,因为
drush up
应该这样做),drush updb
#数据库更新drush entup
#实体更新
- 如果一切正常,请将你的站点重新联机:
drush sset system.maintenance_mode 0
drush cr
- Drupal 7命令
drush vset --exact maintenance_mode 0
drush cache-clear all
除了更新Drupal内核,我还运行了这些命令来更新显示的Drupal模块:
drush sset system.maintenance_mode 1
drush cr
drush up login_security
drush up metatag
drush up mollom
drush up similarterms
drush up token
drush updb
drush sset system.maintenance_mode 0
drush cr
其他drush命令
要获得你的Drupal网站的概述,请使用drush status
:
$ drush status
Drupal version : 8.3.4
Site URI : http://default
Database driver : mysql
Database hostname : localhost
Database port : 3306
Database username : omitted
Database name : omitted
Drupal bootstrap : Successful
Drupal user :
Default theme : omitted
Administration theme : omitted
PHP configuration : omitted
PHP OS : Linux
Drush script : /usr/local/bin/drush
Drush version : 8.1.2
Drush temp directory : omitted
Drush configuration :
Drush alias files :
Install profile : standard
Drupal root : omitted
Drupal Settings File : sites/default/omitted
Site path : sites/default
File directory path : sites/default/files
Temporary file directory path : omitted
Sync config path : sites/default/files/omitted
要确定可以更新哪些软件包/模块,而不进行更改(仅查询),请使用drush pm-updatestatus
,或它别名drush ups
:
$ drush ups
Checking available update data ... [ok]
Checking available update data for Drupal. [ok]
Checking available update data for AddToAny (addtoany). [ok]
Checking available update data for Login Security (login_security). [ok]
Checking available update data for Metatag (metatag). [ok]
Checking available update data for Mollom (mollom). [ok]
Checking available update data for PHP Filter (php). [ok]
Checking available update data for Similar By Terms (similarterms). [ok]
Checking available update data for SMTP Authentication Support (smtp). [ok]
Checking available update data for TOC API (toc_api). [ok]
Checking available update data for TOC filter (toc_filter). [ok]
Checking available update data for Token (token). [ok]
Name Installed Propose Message
Version d
version
Drupal 8.3.4 8.3.5 Update available
Login Security (login_security) 8.x-1.0 8.x-1.2 Update available
Metatag (metatag) 8.x-1.0-beta9 8.x-1.1 Update available
Mollom (mollom) 8.x-1.1 8.x-1.2 Update available
Similar By Terms (similarterms) 8.x-1.2 8.x-1.3 Update available
Token (token) 8.x-1.0-alpha2 8.x-1.0 Update available
如果出于某些原因,你需要所有可用扩展的列表,包括模块和主题:
drush pm-list
drush pml
清除缓存:
drush cr
drush cc all
要启用/禁用模块,请执行以下操作:
drush pm-enable project_name
drush pm-disable project_name
Drush 帮助:
drush help
drush topic