How to deploy your Bedrock + Trellis site to Kinsta

There is an existing tutorial on how to deploy your Bedrock + Trellis site here but when I tried to follow that guide, I encountered some issues like another github repo permission issue, encryption from trellis files and others.

So let’s dig in to that tutorial and add additional steps to make it perfect!

Adding a repository in Github

First you can login to then go here. Then create a repository.

Then we will push our local files to github using these commands. Make sure you are in your site directory where you created your Trellis site. (mine is

git remote add origin [email protected]:jmcausing/WPTrellis.git
git push -u origin master

When you are done initializing git and adding the remote repo, it is time for us to commit and push it to github.

git add.

git commit -m ‘my first commit’

git push origin master

Now the files are there in github.

Editing files in Trellis (Staging)

Alright! Now we got our github repo, time for us to edit some files. We are still following this guide but just adding some details. Here are the files that we need to edit:

forks = 3
host_key_checking = False


trellis/group_vars/staging/wordpress_sites.yml and

      - canonical:


Then open up trellis/group_vars/staging/main.yml and add the following to the end of the file:

project_root: /www/example_123/public
www_root: /www/example_123/public
web_user: example
web_group: www-data

Get those info from your My Kinsta dashboard like the path dir and username


Now this is the part where I was stuck following that Kinsta Trellis tutorial.

Next, open trellis/group_vars/staging/vault.yml for editing by running ansible-vault edit group_vars/staging/vault.yml

First step: SSH to your Trellis localsite (go to the trellis folder and run vagrant ssh and make sure you are from the powershell terminal)

Go to trellis folder from that SSH then run that command ansible-vault edit group_vars/staging/vault.yml

You see there’s an error. To fix that, we need to configure the vault password by following these 3 steps.

1. Set vault password

Create .vault_pass file inside the trellis folder with your string password

2. Inform Ansible of vault password

3. Encrypt files

Make sure you run this still inside the trellish ssh then enter your new vault password

ansible-vault encrypt group_vars/all/vault.yml group_vars/development/vault.yml group_vars/staging/vault.yml group_vars/production/vault.yml

Now let’s run this again: ansible-vault edit group_vars/staging/vault.yml and enter your vault password you created.

It will open a vi linux editor so tips on how to use it. press ‘i‘ to insert some text, when you are done editing the text, ‘esc‘ on your keyboard then type :w to save the file and :q to exit;

It will give you a link just copy and paste under “Yaml Format (for Trellis)” (send red box on the screenshot).


Get those info from your My Kinsta dashboard (staging) like the site IP and ssh port

Editing files in Trellis (Production)

Follow the same process above for editing the files but make sure you are editing it from the ‘production’ folder and same steps from this guide.

Modifying the Deploy Tasks

Contact Kinsta support and ask them for the clear cache url. Open trellis/roles/deploy/hooks/finalize-after.yml and scroll to the bottom. Remove the last task for Reload php-fpmand add the following:

- name: Clear Kinsta cache
    url: "{{ site_env.wp_home }}/ask-support-rep/"
    method: GET

Adding kinsta-mu-plugins to Bedrock

  "type": "package",
  "package": {
    "name": "kinsta/kinsta-mu-plugins",
    "type": "wordpress-muplugin",
    "version": "2.0.15",
    "dist": {
      "url": "",
      "type": "zip"

Then run the following from your Bedrock/site directory:

composer require kinsta/kinsta-mu-plugins:2.0.15

Configuring the Kinsta CDN

define( 'KINSTA_CDN_USERDIRS', 'app');

Ask Kinsta Support

Contact Kinsta support and ask them to change the root directory in nginx config to:


Then let’s push the Changes to github first. Make sure you are in the Power Shell inside your main site directory then switch to WSL

Configure SSH (Trellis SSH and My Kinsta SSH)

We also need to connect from Trellis to My Kinsta SSH. To do this, we need to generate the ssh keys from Trellis ssh and add the public key to My Kinsta uset settings.

!Important: Make sure you followed this from the origina Kinsta tutorial:

We are using SSH from Trellish so we need to follow this instead How to Generate SSH Key Pair on MAC/Linux

Screenshot below shows we generated an ssh key and reading the (we will paste this in github)

Then add the SSH key to your My Kinsta user account. A complete guide is located here.

Generate SSH keys from Kinsta (staging ssh) then add deploy keys to Github

Commands from the screenshot above

ssh-keygen -t rsa -b 4096 -C “[email protected]

cat ~/.ssh/

Paste the keys to your github repo deploy keys

Deploying your Local Trellis + Bedrock site to Kinsta Staging

Make sure you are still in the local Trellis SSH (power shell) using vagrant ssh command

Then cd to ‘trellis folder then run the deploy command (deploying local to staging Kinsta site). Make sure change the to your staging site domain.

# Deploy staging
ansible-playbook deploy.yml -e env=staging -e --limit=kinsta_staging

Let’s run that command now!

So far so good. No errors!

Deployment from local WordPress bedrock + trellis to Kinsta staging was successful! Let’s see our Kinsta staging site.

The WordPress directory structure is different and it is now using Bedrock + Trellis.

Want to deploy also to production? Do the same command but just change the domain url of your Kinsta live site. See commands below for deploying staging and live sites.

# Deploy staging
ansible-playbook deploy.yml -e env=staging -e --limit=kinsta_staging

# Deploy production
ansible-playbook deploy.yml -e env=production -e --limit=kinsta_production

I hope you enjoyed this tutorial and leave your comments below if you have questions.

Subscribe To Our Newsletter

Join our mailing list to receive the latest website layout designs, news and updates from our team.

You have Successfully Subscribed!

Share This