As a “note to self,” I just updated this Drupal 8 website in less than three minutes. Actually, what I did was (a) test the Drupal update on a Test server, and then (b) did the update here in less than three minutes.
The following block shows my Cliffnotes on performing the update. If you’re familiar with Drupal, these notes may make sense, and help you when you need to perform an update of your own.
UPDATE: Once you get to a certain level of Drupal — I don’t remember the exact version but somewhere around 8.43 or 8.5 — you shouldn’t use Drush to update your website any more, you should use Composer. I write about this in my article, A Drush 9 list of commands for Drupal 8.
Update Drupal 8.1.3 to 8.1.8 (Test Server)
Update Drupal 8.1.3 to 8.1.8 (on the test server)
=================================================
# create a new database on my test server
mysql -u root -p
create database aad8prod;
use aad8prod;
# create a mysql user and grant permissions
GRANT ALL PRIVILEGES
ON aad8prod.*
TO 'prod_user'@'localhost'
IDENTIFIED BY 'prod_password'
WITH GRANT OPTION;
# restore the production database to my test server
source aa.com.sql.20160814;
# update the drupal8 config with the new username and password
# sites/default/settings.php
$databases['default']['default'] = array (
'database' => 'aad8prod',
'username' => 'prod_user',
'password' => 'prod_password',
'prefix' => '',
'host' => 'localhost',
'port' => '3306',
'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
'driver' => 'mysql',
);
# Test server notes
- had to disable the 'trusted_host_patterns' in settings.php
- drupal error message was:
The provided host name is not valid for this server.
- made sure everything is working on the test server
- i turn off my wifi to make sure i don't accidentally do
something on the prod server
Performing the Drupal Update (Test server)
Performing the Drupal Update (Test server)
------------------------------------------
# download latest drupal version (8.1.8)
- unpack it
- follow the instructions in /core/UPDATE.txt:
- MINOR AND PATCH VERSION UPDATES
- if needed, make a backup copy of your settings.php file
- backup .htaccess and robots.txt
- cp settings.php settings.php.pre20160814 (sites/default)
- cp .htaccess .htaccess.pre20160814
- cp robots.txt robots.txt.pre20160814
- unpack drupal update files somewhere so you can quickly and easily
copy them after you remove the old files
- in this case i put mine in:
- ../drupal-8.1.8
- take the website offline
- admin/config/development/maintenance
- cd to the drupal8 root directory
- `drush cr`
- my cache database tables are several GB; flush them
- rm -rf core vendor
- rm *php
- rm composer*
- rm web.config
- unpack new files
- cp -R ../drupal-8.1.8/* ../drupal-8.1.8/.htaccess .
- run update.php via browser
- http://aad8:8888/update.php
- this shows an update page with no css
- 'tmp' directory on Test server was messed up
- check that everything is working
- go back online
- admin/config/development/maintenance
Potential Test Server problems
"Couldn't write file" error message (Test server)
-------------------------------------------------
- looked in reports
- may have to do with:
- couldn't write .htaccess file
- couldn't use temporary directory b/c it was looking for
the temp directory i use in production
- change the temporary directory at this uri:
- admin/config/media/file-system
- change to: /Applications/MAMP/htdocs/aad8-drupal-tmp
- the css/html is screwed up on this page:
- admin/reports/dblog
- `drush cr` fixes this
Production Server
Production Server
=================
- after i confirmed that the update didn't clobber my website,
i followed the same steps on the Production server
- investigate the differences between these files:
- .htaccess
- robots.txt
Those notes are cryptic, but if you need an example of the steps needed to update a Drupal 8 website from one minor version to another (in just a few minutes on the Production server), I hope they are helpful.