A while back, WordPress.com enabled SSH access for Business and eCommerce plans. I recently had a look at what those environments look like. First test: WP-CLI commands. It’s great to see that commands like wp db export
work just fine. You’re also allowed to create folders in the home directory, so we can easily export a file and save them outside of the public root, in a folder like ~/_sql/
.
Plugins, themes and WordPress Core
Most plugins and themes installed in the Dashboard are actually symlinks, linking to the root /wordpress/
folder. This is also where WordPress Core is stored. It seems like all of these files are shared files, that are used by all WordPress.com websites. That means that, for example, the Yoast SEO plugin is stored in /wordpress/plugins/wordpress-seo/latest/
which in turn links to /wordpress/plugins/wordpress-seo/19.6.1/
in which the actual files are stored.
What does that mean?
This means that creating a backup or local environment is not as straight forward as it usually is. I normally just run a command like rsync -r public_html/wp-content/ app/www/content
followed by a wp db import
and a wp search-replace
. In this case we also have to do that for files stored in /wordpress/plugins/
, /wordpress/themes/
and /wordpress/mu-plugins
.
Creating a local environment for a WordPress.com website
Allright, let’s have a look at all steps involved for duplicating a WordPress.com site locally
- Connect via SSH (make sure to enable SSH access for the site and connect to it via Settings -> Hosting Configuration)
- Create a
~/_sql/
directory or something similar - Run
wp db export && mv *.sql ~/_sql/
in~/htdocs
- Prepare a local environment for your site locally (using MAMP, docker-compose or something different)
- Download the sql file with something like:
scp {name}@sftp.wp.com:~/_sql .
- Run
wp db import {sql_file_name}.sql
in your local site - Run
wp search-replace {live-domain-name} {local-domain-name} in your local site
- Create a new admin user with something like:
wp user create admin admin@local.test --role=administrator --user_pass=password
- Download the wp-content files with:
rsync -r {name}@sftp.wp.com:~/htdocs/wp-content/ {path_to_your}/wp-content/
- Download the shared plugin and theme files with:
rsync -r {name}@sftp.wp.com:/wordpress/plugins {path_to_your}/wp-content/plugins
rsync -r {name}@sftp.wp.com:/wordpress/themes {path_to_your}/wp-content/themes
- Visit your new local environment!
Key Take-aways
- WP-CLI works!
- Core, plugins and themes are stored in a root folder:
/wordpress/
- The current version of WordPress is stored in
~/htdocs/__wp__
which is a symlink to/wordpress/core/{version-number}
- The directory structure is a bit.. unusual, a symlink called wordpress-seo in
wp-content/plugins/
points to/wordpress/plugins/wordpress-seo/latest
which points to/wordpress/plugins/wordpress-seo/19.6.1
- The
/wordpress
folder seems to be a a shared folder readable by all WP sites, but only after enabling or purchasing the plugin for the site
Leave a Reply