Convert Kinsta-based Trellis and Bedrock to vanilla WordPress
1. Backup Kinsta's live enviroment
You can do so by going to the website in Kinsta -> Backups -> Manual.
Make sure you a add a descriptive backup note such as "before converting trellis to vanilla wordpress" so you know which backup to restore if things went sideways.
2. ssh into Kinsta
3. cd to /public/
4. Check the current version of WordPress
Now that you're in public, type cat current/composer.json
and look for
"roots/wordpress".
5. Download the same version of WordPress
If you found "roots/wordpress": 5.5.1
in the previous step, you'd do the
below:
wp core download --version=5.5.1
6. Configure WordPress
create a wp-config.php
file with database credentials from Kinsta's dashboard and
the prefix from the current database.
wp config create --dbname="mosaad" --dbuser="mosaad" --dbpass="mosaad123" --dbprefix="wp_"
7. Copy /app/ into /wp-content/
rsync -vrz current/web/app/ wp-content
8. Copy /shared/uploads/ into /wp-content/uploads/
rsync -vrz shared/uploads/ wp-content/uploads
9. cd to /wp-content/mu-plugins/
10. Delete Bedrock's mu-plugins from our vanilla WordPress copy
rm bedrock-autoloader.php disallow-indexing.php register-theme-directory.php
11. cd back to /public/
12. Ask Kinsta's support to reset the root directory
Go to Kinsta's chat in the bottom-right corner and ask them to reset the root
directory to be public
instead of public/current
for the website you're
converting.
Example "Hey there, please reset the root directory for mosaad2 to be public
"
13. Search and replace urls
The below assumes the production url contains www.
. It makes sure to replace
any old urls with http
only or without www.
as well.
wp search-replace "/app/" "/wp-content/" && wp search-replace "http://mosaad.com" "https://www.mosaad.com" && wp search-replace "https://mosaad.com" "https://www.mosaad.com" && wp search-replace "http://www.mosaad.com" "https://www.mosaad.com" && wp search-replace "https://www.mosaad.com/wp" "https://www.mosaad.com" && wp option update home "https://www.mosaad.com" && wp option update siteurl "https://www.mosaad.com"
Note: the order of these search-replace matters. if you replaced the domain
before you replace /app/
with /wp-content/
you might end up with urls in the
database like https://www.mosaad.com-content/uploads/06/img.png
which will
break media links.
14. Review Kinsta's redirect rules
Check Redirects in your Kinsta's dashboard and make sure no rule is
redirecting /wp-content/
to /app/
or any url to the old */wp/
format.
15. Clear Kinsta's cache
You can do so from your WordPress admin or from tools in your Kinsta's dashboard.
16. Clear Plugins cache
If you have image optimization plugins such as Nitro or OptiMole, make sure you clear their cache as well.
17. Visit your site's url to confirm it's working
18. If something went wrong, restore the backup
19. If all looks good, delete Trellis directories
rm -rf releases current shared
20. Setup a Continuous Integration for you Sage theme
I personally use Bitbucket Pipelines but you can use any CI service you wish.
21. Fix any hardcoded URLs in your theme
Make sure you check your theme for any url that contains /app/
and replace it
with /wp-content/
or be a better developer and do it dynamically the proper
way.
22. Search your theme for WP_ENV constant
If you used something like if(WP_ENV === 'production')
it will fail because
that was generated by Trellis. You can either define it for live website
manually by editing the wp-config.php
file or remove these if statements from
your theme.
Need help?
If the above didn't work for you or you wish for me to expand on the why behind any of it, tweet at me. I'm very friendly.