Bedrock and Trellis are created with a sole purpose in mind – to make it easier for developers to develop, maintain, as well as deploy WordPress websites. In today’s post, we will talk about the main features of both Bedrock and Trellis. We will also explain how to integrate these tools as well as share our thoughts on why you should use them instead of a traditional WordPress setup.

What are Bedrock and Trellis?
With its improved security and folder structure, as well as modern development tools, Bedrock provides an alternative way of managing your WordPress installation.
On the other hand, Trellis works alongside Bedrock to create development environments with Vagrant along with one-command deploys.
Developers use Bedrock in order to gain proper dependency and package management for their WordPress projects. While package managers are common tools in every developer’s toolkit, using one with WordPress is not so widely spread due to its already developed concept for plugins. Bedrock uses Composer for plugin management and for managing themes or even WordPress core as dependencies.
Trellis is used for creating development and production servers for WordPress hosting. It is also created to function seamlessly with Bedrock-based websites. Today, our web development agency Chicago explores the case of using Trellis for your development server and Kinsta for a production server. We choose Kinsta over Trellis provisioned VPS because we are aware that it is way too time-consuming to manage the server yourself, especially for companies that have a large number of clients.
Many WordPress hosts allow neither SSH access nor Composer or WP-CLI integration. Since these are all required if you wish to use Bedrock and Trellis, we can’t quite call a wast number of WordPress hosts developer-friendly. On the other hand, Kinsta offers SSH access and the option to modify the root path to achieve proper functionality.
Bedrock vs traditional WordPress install
When choosing between Bedrock and regular WordPress install, keep in mind that Raspberry Pi, Snopes, JetBlue, and many others power their WordPress websites using Bedrock. Bedrock is created with a modern development process in mind using the twelve-factor app methodology for building software-as-a-service apps:
- Environment-specific configuration files are stored outside of the public webroot
- Environment variables to separate config from code in a single .env file
- Improved security by limiting access to non-web files and bcrypt hashed passwords
- Custom wp-content directory named app
- Allows integration with Composer for managing plugins, themes, as well as other PHP dependencies
- .gitignore gives you the option to exclude WordPress core, plugins, or uploads
Here is a comparison of the two folder structures:
How to configure Trellis for Kinsta
First of all, you need to add your public SSH keys to the MyKinsta dashboard. In order to make one-command deploys in Trellis work with Kinsta, you need to do some configuring. Once this is done, you will be able to easily deploy your WordPress website by running the deploy playbook in Trellis:
ansible-playbook deploy.yml -e env=staging -e site=example.com
Open your MyKinsta dashboard and select the WordPress website that you wish to set up with Bedrock and Trellis, along with your code editor opened to the trellis directory in your project. Here you need to edit trellis/ansible.cfg by adding the following code to the [defaults] at the top:
forks = 3
host_key_checking = False
Staging Configuration
Kinsta provides everything you need from the server standpoint. This means that provisioning your staging and production environments does not apply automatically. You need to ensure that trellis/group_vars/staging/wordpress_sites.yml is configured with the proper canonical for your staging website:
wordpress_sites:
example.com:
site_hosts:
– canonical: staging-example.kinsta.com
After that, you should open up trellis/group_vars/ staging/main.yml and add the following piece of code to the end:
project_root: /www/example_123/public
www_root: /www/example_123/public
web_user: example
web_group: www-data
The project_root and www_root paths should be replaced with those provided in the MyKinsta dashboard for your staging environment.
Now, open trellis/group_vars/staging/vault.yml for editing by running ansible-vault edit group_vars/staging/vault.yml. You need to add db_user, db_name, and db_password to env along with values which you can find on the main info screen for your website in the MyKinsta dashboard:
Here is how it should look:
vault_wordpress_sites:
example.com:
env:
db_user: “example”
db_name: “example”
db_password: “xxxxxxxxxxxxxxx”
# Generate your keys here: https://roots.io/salts.html
auth_key: “”
secure_auth_key: “”
logged_in_key: “”
nonce_key: “”
auth_salt: “”
secure_auth_salt: “”
logged_in_salt: “”
nonce_salt: “”
The last step includes opening trellis/hosts/staging and replacing the contents with the following:
kinsta-staging ansible_host=104.154.94.123 ansible_ssh_port=12345 ansible_ssh_extra_args=’ -o StrictHostKeyChecking=no’
[web]
kinsta_staging
[staging]
kinsta_staging
For the host and SSH port values, refer to the MyKinsta dashboard.
Production configuration
To configure your production environment, you’ll need to toggle your “live” environment in the MyKinsta dashboard and repeat the same process.
You should open up trellis/group_vars/ staging/main.yml and add the following piece of code to the end:
project_root: /www/example_123/public
www_root: /www/example_123/public
web_user: example
web_group: www-data
The project_root and www_root paths should be replaced with those provided in the MyKinsta dashboard for your staging environment.
Open trellis/group_vars/staging/vault.yml for editing by running ansible-vault edit group_vars/staging/vault.yml:
vault_wordpress_sites:
example.com:
env:
db_user: “example”
db_name: “example”
db_password: “xxxxxxxxxxxxxxx”
# Generate your keys here: https://roots.io/salts.html
auth_key: “”
secure_auth_key: “”
logged_in_key: “”
nonce_key: “”
auth_salt: “”
secure_auth_salt: “”
logged_in_salt: “”
nonce_salt: “”
The last step includes opening trellis/hosts/production and replacing the contents with the following:
kinsta-production ansible_host=104.154.94.123 ansible_ssh_port=12345 ansible_ssh_extra_args=’ -o StrictHostKeyChecking=no’
[web]
kinsta_production
[staging]
kinsta_production
How to modify the deploy tasks
The first thing we need to do is to prevent Trellis deploys (which try to reload php-fpm) from running on Kinsta’s servers. Also, we need to activate Kinsta’s cache clearing on a deploy. Here is how to do that.
We need to open trellis/roles/deploy/hooks/finalize-after.yml and navigate all the way to the bottom. Replace the last task for Reload php-fpm with the following:
- name: Clear Kinsta cache
uri:
url: “{{ site_env.wp_home }}/ask-support-rep/”
method: GET
Replace ask-support-rep above after asking a Kinsta support rep for the URL to clearing the cache on your website.
How to install Composer dependencies (optional step)
If you are presented with a screen that asks you to run Composer install, you need to add the following piece of code before the Clear Kinsta cache code:
- name: Install Composer dependencies
composer:
command: install
working_dir: >/www/example123/public/final-path
How to add kinsta-mu-plugins to Bedrock
Kinsta websites come with preinstalled mu-plugins. In order to add them to Bedrock, you will need to bring in the kinsta-mu-plugins package. You do this by opening site/composer.json and adding the following piece of code within the repositories array:
{
“type”: “package”,
“package”: {
“name”: “kinsta/kinsta-mu-plugins”,
“type”: “wordpress-muplugin”,
“version”: “2.3.3”,
“dist”: {
“url”: “https://kinsta.com/kinsta-tools/kinsta-mu-plugins.zip”,
“type”: “zip”
}
}
}
After this, you need to run the following from your Bedrock/site directory:
composer require kinsta/kinsta-mu-plugins:2.3.3
How to configure the Kinsta CDN
You have an option to use the Kinsta CDN along with your Bedrock website and the Kinsta MU plugin. However, you must manually define the directory in your /config/application.php file. Here is how to do that using the /app directory on your website.
define( ‘KINSTA_CDN_USERDIRS’, ‘app’ );
If more than one directory needs to be added, just put commas between them like so:
define( ‘KINSTA_CDN_USERDIRS’, ‘app,app2,app3 );
Contacting Kinsta support and completing the setup
There is one more step for you to do before completing a setup. You need to contact Kinsta’s support team on MyKinsta for your document root to be updated to public/current/web.
You can also ask the support team for your clear cache URL in case you didn’t get it earlier. Ensure that trellis/roles/deploy/hooks/finalize-after.yml is updated with the correct URL so that Kinsta’s cache would be cleared on successful deployment. After that, you will be able to deploy to both your staging as well as production environments with a single line:
# Deploy staging
ansible-playbook deploy.yml -e env=staging -e site=example.com –limit=kinsta_staging
# Deploy production
ansible-playbook deploy.yml -e env=production -e site=example.com –limit=kinsta_production
You can also choose to set up a continuous integration service, like CircleCI, so it would run the deploy command once you commit to either staging or master.
Final thoughts
This concludes our guide on how to use Bedrock and Trellis. We hope that you have found today’s article helpful. If you are a fellow WordPress enthusiast, check out our article on the Sage WordPress theme and find out why it is our premium choice for SEO.