Manually upgrading a production Dev Portal environment from a stage environment

Overview

Dev Portal is built on top of Drupal, which consists of a core system along with Drupal modules and themes to extend out the base features of a Drupal installation. Both core Drupal, Drupal modules and Drupal themes release new versions, which you need to keep up to date for any feature updates or bug fixes. All of the Dev Portal functionality that Apigee releases is also a Drupal module, which also need to be upgraded to stay updated.

Our cloud environment gives you the ability to move code changes and product upgrades from a staging or test environment into your production environment with an easy to use user interface. If you are are running Dev Portal on premise however, you will need to do these steps manually. This document explains how you can migrate your custom changes or Drupal core or module upgrades from your staging environment to your production environment.

This process will only move over any Drupal core, Drupal modules, or custom module changes. This will not move any content or configuration that you have changed that is in the database, or any file or image uploads you have placed on your stage environment.

For system upgrading purposes, Dev Portal (Drupal) consists for the following pieces that are useful to understand:

  1. Drupal web root - Drupal code is served up by Apache web server. The Apache web server is configured via Apache virtual hosts to load the Drupal code from the Drupal web root. By default, the Dev Portal installer will use /var/www/html. All code, including custom modules and themes are in this directory.
  2. Drupal database - The database is stored in MySQL. The connection settings to this database is kept in the {webroot}/sites/default/settings.php file. You can look in this file to find out the database connection settings, or you can use drush with this commands: cd {webroot} drush status --show-passwords
  3. Drupal file system - There are three locations in the Drupal web root where files are stored. These locations are configurable, you can find out where these directories are located by using the drush status command again, or by logging in as an administrator and going to Configuration > Media > File System.
    1. Public file system path - This is a directory where public files such as uploaded images for content are stored.
    2. Private file system path - The private file system is used to store items that should not be accessible through the web server, such as a configuration setting.
    3. Temporary directory - The temporary directory is used to store any temporary files that a module or core Drupal needs to create.

Upgrade Assumptions

The instructions below that your web root is located at /var/www/html, and that your Drupal files system locations are:

  • Public file system path: sites/default/files
  • Private file system path: sites/default/files/private
  • Temporary directory: sites/default/files/tmp

If your system is different, you will need to change the commands below accordingly.

Upgrade Procedure

  1. Make a backup of your production webroot and database.
  2. Put your production site in maintenance mode by logging into the site as an admin and going to Configuration > Development > Maintenance mode, and check the "Put site into maintenance mode". This will make sure no more content changes are being made on the site during the upgrade process - only administrators will be able to login at {{site_url}}/user.
  3. Copy the staging environment's Drupal web root to a directory next to your current web root with the name of html-upgraded. You should now have the staging Drupal web root (html-upgraded) right next to your production web root (html) : [root@servername ~]# cd /var/www [root@servername ~]# ls cgi-bin error html html-upgraded icons
  4. Replace the html-upgraded/sites/default/settings.php with the production settings file: cd /var/www cp html/sites/default/settings.php html_upgraded/sites/default
  5. Replace the private and public Drupal file system locations from your production web root into the site you are upgrading: cd /var/www rm html_upgraded/sites/default/files cp -R html/sites/default/files html-upgraded/sites/default rm html_upgraded/sites/default/private

    cp -R html/sites/default/files html-upgraded/sites/private

  6. Copy over the .htaccess and robots.txt files from the production webroot directory to the html-upgraded directory if you have modified them.
  7. Make sure the permissions are set properly on the html-upgraded site. Apache needs to be able to read all files, and be able to write to the Drupal file system locations. Run the following commands, making sure to change the group "apache" with the name of the user that Apache runs as on your system and "root" with the user that should own the Dev Portal files. For more information on securing your site, see: https://www.drupal.org/node/244924 cd /var/www/html-upgraded chown -R root:apache . find . -type d -exec chmod u=rwx,g=rx,o= '{}' \; find . -type f -exec chmod u=rw,g=r,o= '{}' \; cd /var/www/html-upgraded/sites find . -type d -name files -exec chmod ug=rwx,o= '{}' \; for d in ./*/files do find $d -type d -exec chmod ug=rwx,o= '{}' \; find $d -type f -exec chmod ug=rw,o= '{}' \; done
  8. Switch the production webroot with the upgraded web root. The new code will now be running when anyone hits the site's URL: cd /var/www mv html html-old mv html-upgraded html
  9. Go to {{site_url}}/update.php, where {{site_url}} is your site URL and follow instructions on screen. You will need to be logged in as an administrator.
  10. Take your production site out of maintenance mode by logging into the site as an admin and going to Configuration > Development > Maintenance mode, and uncheck the "Put site into maintenance mode".

Notes

  • There are many ways to automate this process, including using source control as a way to pull in new changes.
Version history
Last update:
‎05-12-2015 04:57 PM
Updated by: