Create a WordPress Site with Terminus and WP-CLI
Learn how to install and use Terminus and WP-CLI to control a WordPress site on Pantheon.
This section provides information on how to create and configure a site, and initialize your environments with Terminus, which allows you to call WP-CLI remotely without using a local installation.
Before You Begin
Be sure that you:
- Are familiar with your operating system's command line.
- Are using a Unix-based system (Linux or Mac OS X). Windows commands may vary slightly.
- Have already created a Pantheon account. Pantheon accounts are always free for development.
Install and Authenticate Terminus
Terminus provides advanced interaction with the platform and allows you to run WP-CLI commands remotely. Terminus allows you to automate parts of your workflow by combining multiple operations. Refer to the Terminus Guide for more information.
-
Install Terminus within the
$HOME/terminusdirectory: -
Go to your Personal Settings, select Machine Tokens, then Generate a Machine Token.
-
Use the Machine token to authenticate Terminus:
-
Verify your session after the installation is complete:
The installation and authentication were successful if you can see your Pantheon sites.
Create Your Site and Initialize Environments
The next sections use the example variables tessa-site-wp and "Terminus Demo Site" as the site name and label. Make sure you replace each instance, as well as other variables like the site URL and user/password combinations, with your own values.
-
Create a new WordPress site on Pantheon:
-
Add the
--orgoption to the command above and pass the Workspace name, label, or ID if you want to associate this site with an Workspace. -
Use the
site:org:addcommand to associate an existing site with an Workspace.
-
-
Open your new Site Dashboard in a browser:
Keep this window open to see the changes you are making in Terminus appear almost immediately in your Site Dashboard.
-
Retrieve the platform domain for the Dev environment:
You'll need this information to fill out the
--urloption in the next step. -
Use the WP-CLI
core installcommand to install WordPress on the Dev environment:As a reminder, WP-CLI is the command line utility for WordPress itself. Terminus is simply passing through the WP-CLI commands to the site on Pantheon. Run the command below to get a full list of WP-CLI commands:
The
--signifies the end of the Terminus options, anything after--is passed straight to WP-CLI. -
Create the Test environment:
-
Create the Live environment:
Export the Site Name as a Variable
-
Export your site name as a variable to avoid the need to copy/paste the remainder of your commands:
This sets an environment variable named $TERMINUS_SITE with the value tessa-site-wp. Anytime you use the variable name it's replaced in the executed command with the variable value.
-
Echo your variable to test that it works correctly:
You can now copy and paste the remainder of these commands without replacing the site name now that the commands use the
$TERMINUS_SITEvariable. -
Run the command below to get the connection information for the Dev environment:
Using Terminus and WP-CLI
Terminus provides the power to manage most aspects of your Pantheon sites. Tools such as WP-CLI (and Drush for Drupal) give you the power to manage the inner workings of your WordPress-powered site. Now you're ready to take the Sandbox site you've setup and explore on your own to see what else is possible.