Pantheon Guide for WordPress
This is an in-process placeholder for setting up WordPress with KalaPress on Pantheon.
Setting up a new site
Log in to Pantheon and make sure you are in the Kalamuna space and not your personal one.
Click “Create New Site“:
Under “What Kind of Site” choose “WordPress”:
Name the site (note what the URL will look like), set the Region appropriate to the client location, and make sure you’re setting it up in the Kalamuna Workspace:
Click the “Agree” button to have it listed in the Kalamuna billing space and click “Confirm”. It will take a while to deploy the CMS.
Once the Pantheon environment is complete, click “Visit your environment dashboard”.
Change Development Mode to GIT:
Either create a new GitHub repo for the project, or edit an existing one, and go to
Settings -> Secrets and Variables -> Actions
, then click the tab forVariables
:If you don’t have the ability to add or edit Variables in the GitHub repository, contact the Kalamuna Tech team lead for DevOps to either make the change or grant you access to do so.
You should see a variable for
DEPLOY_REPO
. If not, create one. To get the Value, go to the Pantheon Dashboard and click "Connection Info". In the SSH Clone URL field, copy everything after "git clone", starting withssh://
Paste the
ssh://
code into theDEPLOY_REPO
variable and save.The GitHub repo will now deploy to Pantheon whenever a push is made to the
master
branch.
See https://kalamuna.atlassian.net/wiki/spaces/KALA/pages/2870050818 for more information about GitHub actions.
Setting up a Multidev
Pantheon’s multidev service lets you spin up a new version of the main site but based on a specific branch. Note that the branch name must be lowercase.
Create and commit a branch, we’ll use
sandbox
as an example.Go to the main Pantheon dashboard for the site and click on the “Multidev” tab. You should see an option for “Git Branches”, and it will show every branch that’s been committed:
Click the “Create Environment” button.
In the popup, choose whichever current environment you want to clone as the base of the new site:
Once the files and database are copied, you’ll be able to choose it from the Multidev list:
Local configuation for working with Pantheon once everything has been established during initial project setup
Most of this setup should already be part of the repo, and is here for the benefit of someone doing the initial setup of the entire setup for the whole team. Devs working on the site after setup should be able to simply:
Use your preferred local setup software (LocalWP, Lando, ddev, etc.) to set up a default WordPress install
Git pull the repo to your local install in the app root
Update
wp-config-local.php
with your local database credentialsIn the theme folder, run
npm install
In the theme folder, run
composer install
(note that when using LocalWP you have to open the site shell using the button in the app, not just a regular Terminal window:You should now be able to change to the KalaPress theme in the WP admin.
Initial Setup for working with Pantheon
Pantheon requires all WordPress core files, plus the following:
wp-config.php
wp-config-pantheon.php
wp-config-local.php
wp-config.php
.gitignore-deploy
(should have the same contents as.gitignore
).
Ideally these files should be part of the starter repo, but if not their contents are included below.
KalaPress requires Composer to be installed on both your local and on the server. The easy way to accomplish this is to comment out the /vendor
folders in .gitignore
and .gitignore-deploy
, then run composer install
on your local, then merge and push. That will set up Composer in the Pantheon environment.
You will also need to run npm install
in the theme folder, and then npm run build
once during this initial setup process.
wp-config-pantheon.php
<?php
/**
* Pantheon platform settings.
*
* IMPORTANT NOTE:
* Do not modify this file. This file is maintained by Pantheon.
*
* Site-specific modifications belong in wp-config.php, not this file. This
* file may change in future releases and modifications would cause conflicts
* when attempting to apply upstream updates.
*/
// ** MySQL settings - included in the Pantheon Environment ** //
/** The name of the database for WordPress */
define('DB_NAME', $_ENV['DB_NAME']);
/** MySQL database username */
define('DB_USER', $_ENV['DB_USER']);
/** MySQL database password */
define('DB_PASSWORD', $_ENV['DB_PASSWORD']);
/** MySQL hostname; on Pantheon this includes a specific port number. */
define('DB_HOST', $_ENV['DB_HOST'] . ':' . $_ENV['DB_PORT']);
/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8mb4');
/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');
/**#@+
* Authentication Unique Keys and Salts.
*
* Changing these will force all users to have to log in again.
* Pantheon sets these values for you. If you want to shuffle them you could
* use terminus env:rotate-random-seed command:
* https://docs.pantheon.io/terminus/commands/env-rotate-random-seed
*
* @since 2.6.0
*/
define('AUTH_KEY', $_ENV['AUTH_KEY']);
define('SECURE_AUTH_KEY', $_ENV['SECURE_AUTH_KEY']);
define('LOGGED_IN_KEY', $_ENV['LOGGED_IN_KEY']);
define('NONCE_KEY', $_ENV['NONCE_KEY']);
define('AUTH_SALT', $_ENV['AUTH_SALT']);
define('SECURE_AUTH_SALT', $_ENV['SECURE_AUTH_SALT']);
define('LOGGED_IN_SALT', $_ENV['LOGGED_IN_SALT']);
define('NONCE_SALT', $_ENV['NONCE_SALT']);
/**#@-*/
/** A couple extra tweaks to help things run well on Pantheon. **/
if (isset($_SERVER['HTTP_HOST'])) {
// HTTP is still the default scheme for now.
$scheme = 'http';
// If we have detected that the end use is HTTPS, make sure we pass that
// through here, so <img> tags and the like don't generate mixed-mode
// content warnings.
if (isset($_SERVER['HTTP_USER_AGENT_HTTPS']) && $_SERVER['HTTP_USER_AGENT_HTTPS'] == 'ON') {
$scheme = 'https';
$_SERVER['HTTPS'] = 'on';
}
define('WP_HOME', $scheme . '://' . $_SERVER['HTTP_HOST']);
define('WP_SITEURL', $scheme . '://' . $_SERVER['HTTP_HOST']);
}
// Don't show deprecations; useful under PHP 5.5
error_reporting(E_ALL ^ E_DEPRECATED);
/** Define appropriate location for default tmp directory on Pantheon */
define('WP_TEMP_DIR', sys_get_temp_dir());
// FS writes aren't permitted in test or live, so we should let WordPress know to disable relevant UI
if (in_array($_ENV['PANTHEON_ENVIRONMENT'], array( 'test', 'live' )) && ! defined('DISALLOW_FILE_MODS')) {
define('DISALLOW_FILE_MODS', true);
}
/**
* Set WP_ENVIRONMENT_TYPE according to the Pantheon Environment
*/
if (getenv('WP_ENVIRONMENT_TYPE') === false) {
switch ($_ENV['PANTHEON_ENVIRONMENT']) {
case 'live':
putenv('WP_ENVIRONMENT_TYPE=production');
break;
case 'test':
putenv('WP_ENVIRONMENT_TYPE=staging');
break;
default:
putenv('WP_ENVIRONMENT_TYPE=development');
break;
}
}
/**
* Defaults you may override
*
* To override, define your constant in your wp-config.php before wp-config-pantheon.php is required.
*/
/** Disable wp-cron.php from running on every page load and rely on Pantheon to run cron via wp-cli */
$network = isset($_ENV["FRAMEWORK"]) && $_ENV["FRAMEWORK"] === "wordpress_network";
if ( ! defined( 'DISABLE_WP_CRON' ) && $network === false) {
define( 'DISABLE_WP_CRON', true );
}
wp-config.php
<?php
/**
* This config file is yours to hack on. It will work out of the box on Pantheon
* but you may find there are a lot of neat tricks to be used here.
*
* See our documentation for more details:
*
* https://pantheon.io/docs
*/
/**
* Pantheon platform settings. Everything you need should already be set.
*/
if (file_exists(dirname(__FILE__) . '/wp-config-pantheon.php') && isset($_ENV['PANTHEON_ENVIRONMENT'])) {
require_once(dirname(__FILE__) . '/wp-config-pantheon.php');
/**
* Local configuration information.
*
* If you are working in a local/desktop development environment and want to
* keep your config separate, we recommend using a 'wp-config-local.php' file,
* which you should also make sure you .gitignore.
*/
} elseif (file_exists(dirname(__FILE__) . '/wp-config-local.php') && !isset($_ENV['PANTHEON_ENVIRONMENT'])){
# IMPORTANT: ensure your local config does not include wp-settings.php
require_once(dirname(__FILE__) . '/wp-config-local.php');
/**
* This block will be executed if you are NOT running on Pantheon and have NO
* wp-config-local.php. Insert alternate config here if necessary.
*
* If you are only running on Pantheon, you can ignore this block.
*/
} else {
define( 'DB_NAME', 'local' );
define( 'DB_USER', 'root' );
define( 'DB_PASSWORD', 'root' );
define( 'DB_HOST', 'localhost' );
define('DB_CHARSET', 'utf8');
define('DB_COLLATE', '');
define('AUTH_KEY', 'put your unique phrase here');
define('SECURE_AUTH_KEY', 'put your unique phrase here');
define('LOGGED_IN_KEY', 'put your unique phrase here');
define('NONCE_KEY', 'put your unique phrase here');
define('AUTH_SALT', 'put your unique phrase here');
define('SECURE_AUTH_SALT', 'put your unique phrase here');
define('LOGGED_IN_SALT', 'put your unique phrase here');
define('NONCE_SALT', 'put your unique phrase here');
}
/** Standard wp-config.php stuff from here on down. **/
/**
* WordPress Database Table prefix.
*
* You can have multiple installations in one database if you give each a unique
* prefix. Only numbers, letters, and underscores please!
*/
$table_prefix = 'wp_';
/**
* For developers: WordPress debugging mode.
*
* Change this to true to enable the display of notices during development.
* It is strongly recommended that plugin and theme developers use WP_DEBUG
* in their development environments.
*
* You may want to examine $_ENV['PANTHEON_ENVIRONMENT'] to set this to be
* "true" in dev, but false in test and live.
*/
define('WP_DEBUG', false);
// Enable Debug logging to the /wp-content/debug.log file
define('WP_DEBUG_LOG', false);
// Disable display of errors and warnings
define('WP_DEBUG_DISPLAY', false);
@ini_set('display_errors',0);
if (isset($_ENV['PANTHEON_ENVIRONMENT'])) {
define('FS_METHOD', 'direct');
}
/* That's all, stop editing! Happy Pressing. */
/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');
/** Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php');
wp-config-local.php
Replace DB_NAME
, DB_USER
, DB_PASSWORD
, and DB_HOST
with the correct ones for your local setup. Note that this file is .gitignored
and is what you should be using to change settings like for WP_DEBUG
and such.
<?php
/**
* This is a sample config for local development. wp-config.php will
* load this file if you're not in a Pantheon environment. Simply edit/copy
* as needed and rename to wp-config-local.php.
*
* Be sure to replace YOUR LOCAL DOMAIN below too.
*/
define( 'DB_NAME', 'local' );
define( 'DB_USER', 'root' );
define( 'DB_PASSWORD', 'root' );
define( 'DB_HOST', 'localhost' );
define( 'DB_CHARSET', 'utf8' );
define( 'DB_COLLATE', '' );
define( 'AUTH_KEY', 'put your unique phrase here' );
define( 'SECURE_AUTH_KEY', 'put your unique phrase here' );
define( 'LOGGED_IN_KEY', 'put your unique phrase here' );
define( 'NONCE_KEY', 'put your unique phrase here' );
define( 'AUTH_SALT', 'put your unique phrase here' );
define( 'SECURE_AUTH_SALT', 'put your unique phrase here' );
define( 'LOGGED_IN_SALT', 'put your unique phrase here' );
define( 'NONCE_SALT', 'put your unique phrase here' );
define('WP_DEBUG', false);
// Enable Debug logging to the /wp-content/debug.log file
define('WP_DEBUG_LOG', false);
// Disable display of errors and warnings
define('WP_DEBUG_DISPLAY', false);
@ini_set('display_errors',0);
define( 'WP_HOME', 'http://cnerj.local' );
define( 'WP_SITEURL', 'http://cnerj.local' );
define( 'WP_AUTO_UPDATE_CORE', false );