- Working with wp-config.php on vCanopy
- A quick intro to user-configs.php
- Editing user-configs.php
- Migrating to vCanopy and the wp-config.php file
- Cloning, Failover, and wp-config.php
If you have a website that requires you to add custom code snippets to the
wp-config.php file, on vCanopythese changes won’t persist when you migrate your website to a new server or clone it to a new domain name. Due to the way cloning works, a new
wp-config.php will instead be generated in its place.
To remedy this, we have the
user-configs.php which you can use to add your custom edits. We’ll dig into all the details in this article.
Working with wp-config.php on vCanopy
In a nutshell, please don’t edit the
wp-config.php file for your websites unless absolutely necessary (for example, changing the database table prefix, updating a database user, or editing the DB_CHARSET),
Don’t manually edit the custom edits that we take care of from our side -these all have a comment beginning with vCanopy, for example:
/* vCanopy Cron */.
If you need to add additional information to the wp-config.php we have a special include that you can use called
user-configs.php that you can use instead.
MIGRATING TO vCanopy AND WP-CONFIG.PHP
If you migrate to vCanopy and the migration process copies the
wp-config.php file into your websites /htdocs folder, this may cause issues, and you will need to delete the none-vCanopy
wp-config.php file to ensure your site works as expected.
We’ll take a look at both of these below.
A Quick Intro to user-configs.php
user-configs.php is a custom vCanopy solution for adding content to wp-config.php without actually adding it directly to the
Code placed in this file is treated in the same way by WordPress as if it was added to the
wp-config.php file. This is accomplished using the PHP include statement.
With this, you can make sure that your changes do persist over migrations/clones, by instead adding your code to the
user-configs.php file. Any code added here will not be written over at any point by any vCanopy function.
NOTE: This wouldn’t transfer over if moving a WordPress site away from vCanopy, but it will make it so moving and cloning sites within GP is smooth sailing.
user-configs.php file is located in:
You can edit it either directly on your server, or over SFTP.
EDIT VIA SFTP
To connect to your server over SFTP, please check out the following articles: –
Once connected you can download the file over SFTP, make your edits, and then re-upload it to your server.
EDIT VIA SSH
To connect to your server via SSH, see the following articles to get started:
Step 1. Generate your SSH Key
Inside your server type the following command to edit your
user-configs.php, replacing “site.url” with your domain name:
Make your edits, and then save the file with CTRL+O. You can then exit the file with CTRL+X, and then exit your server with:
Once your edits are made you’re all set! If you migrate your website to a new server, or clone it to a new domain name, your custom edits will now persist.
Migrating to vCanopy and the wp-config.php file
To ensure your migrations are successful, please double check that you don’t have two wp-config.php files inside your site as you move your sites to vCanopy
vCanopy securely stores the wp-config.php file 1 level up outside of /htdocs here:
Depending on how you’ve migrated over, you find that you also have additional file here:
If you have two wp-config.php files these can interfere with each other and cause problems. Please simply delete the wp-config.php file inside /htdocs if it exists, and leave ours in it’s place.
You can do this by connecting to your server over SFTP or you can delete them directly on your server – please see the guides linked in the previous section to get started.
If deleting over SSH, you can navigate to your websites htdocs folder with the following command (switching out “site.url” for your websites domain name):
Then display the contents of the file with:
And if you see a wp-config.php file, you can delete it with:
Once that’s done you’re all set!
Cloning, Failover, and wp-config.php
Cloning and Failover largely follow the same functions.
When moving a site from one server to another, your user-configs.php will be cloned over, copying any customizations that you’ve made.
The table prefix inside the wp-config.php will also be matched on the new site.
Important: When using Snapshot Failover, if you later edit the table prefix on the primary server for any reason, this will not be copied a second time, so please be sure to edit this on both the primary site and the failover site.