Send by LINE
B! Bookmarks in Hate-bu
Bookmarks in Pocket
RSS feeds

WordPress: How to move the environment

Other language site
No available translations found
Google Translate
WordPress logo

In WordPress, copying from the production environment to create the development environment, copying from the development environment to create the production environment may be.

To do that work, there are roughly a copy of the DB, a copy of the plugin, a copy of the theme, a copy of the upload file such as a media file.

The way to explain from now on is possible with WordPress multi-site.

Prepare the destination WordPress environment

First, prepare the destination WordPress environment.

  • Install web server
  • Install DB server (also create database to use)
  • Install WordPress

Moving the database

Create backup (.sql) with WordPress backup plugin or database backup command such as mysqladmin.

Edit backup data

It is not necessary if the destination domain does not change. Please skip this place.

If the destination domain changes, change the domain of the backup file (.sql) to the new domain with the editor's collective replacement function.

Change database setting

If the database setting changes in the new environment, change the setting information in wp-config.php.

define('DB_NAME', 'db-name');
define('DB_USER', 'db-user');
define('DB_PASSWORD', 'db-password');

/** From here we need to change */
define('DB_HOST', 'localhost');
define('DB_CHARSET', 'utf8');
define('DB_COLLATE', '');

Moving WordPress environment

Copy backups of plug-ins, theme source files, uploaded media files etc. to the WordPress environment in the initial installation state of the new environment.

Since WordPress plug-in is provided for backup, we recommend that you regularly backup it using this plug-in.

Some backup plugins include database backups. Recommended is BackWPup. You can back up upload files including databases, plugins, themes, and media.

You can also back up the entire WordPress environment.

Moving plug-in

Copy the plug-in file of "DocumentRoot/wp-content/plugins" to the new environment. Although plugins that already exist may be overwritten, duplicate plugins may be overwritten, but just in case, duplicate plugins are deleted once and then copied.

Next, confirm that the plug-in copied with "installed plug-in" on the management screen is displayed. After confirming that it is displayed, activate each plug-in.

If the DB has finished moving, the plugin configuration information is also copied.

Moving a theme

Copy the theme file of "DocumentRoot/wp-content/themes" to the new environment.

Perhaps, you may be writing the url domain directly by customizing the theme file. In that case, change the domain name according to the new environment.

Originally it is not good to describe the domain directly. You should use the functions provided by WordPress.

Moving uploaded files such as media files

Copy the file "DocumentRoot/wp-content/uploads" to the new environment.

Moving work is over.

Correspondence when "Permission denied" comes out

If moving work finishes successfully and you check the operation, "Permission denied" may occur.

This is likely to happen, for example, when a file or directory permission error has occurred, and when copying, it decompresses the compressed file with tar.gz etc. before copying it to the new environment.

Since the backup file is compressed by tar.gz etc., let's expand it on the server of the new environment.

If it still occurs, use the "chmod" command to change the permissions of each directory and file to the same privilege as before moving.

Leave a Reply