{"id":5993,"date":"2018-03-23T13:00:23","date_gmt":"2018-03-23T04:00:23","guid":{"rendered":"https:\/\/tadtadya.com\/en\/?p=5993"},"modified":"2021-01-25T15:07:47","modified_gmt":"2021-01-25T06:07:47","slug":"wordpress-how-to-move","status":"publish","type":"post","link":"https:\/\/tadtadya.com\/en\/wordpress-how-to-move\/","title":{"rendered":"WordPress, How to move the environment"},"content":{"rendered":"\n<p>There are four major copies of the WordPress moving process.<\/p>\n\n\n\n<div class=\"wp-block-origin-block-em-box em-group em-group-default\">\n<ul><li><span class=\"marker-pink\">Database<\/span><\/li><li><span class=\"marker-yellow\">Plugins<\/span><\/li><li><span class=\"marker-green\">Theme<\/span><\/li><li><span class=\"marker-blue\">Uploaded files such as media files<\/span><\/li><\/ul>\n<\/div>\n\n\n\n<p>The method I'm about to show you can also be done with WordPress multisite.<\/p>\n\n\n\n<!--more-->\n\n\n\n<div class=\"wp-block-origin-block-msg-box\"><div class=\"msgbox msgbox-notice v1\"><i class=\"fas fa-exclamation-triangle icon\"><\/i><div class=\"msg\">\n<p>This is written by a Japanese who can't speak English with the help of translation application. Sorry if it's not good.<\/p>\n<\/div><\/div><\/div>\n\n\n\n<p>Every system has its own moving process, but so does WordPress.<\/p>\n\n\n\n<div class=\"wp-block-origin-block-em-box em-group em-group-default\">\n<p>Making the development environment out of the production environment.<\/p>\n\n\n\n<p>Making the production environment out of the development environment.<\/p>\n\n\n\n<p>Launching multiple copies of the same system.<\/p>\n\n\n\n<p>System error recovery work.<\/p>\n<\/div>\n\n\n\n<p>This is a commentary for smoothing out these situations when encountered. I'll keep it simple.<\/p>\n\n\n<div id=\"toc\" class=\"idx-lst\">\n\t<input type=\"checkbox\" class=\"chk\" id=\"idx-lst-chk\" name=\"btn\" \/>\n\t<label class=\"idx-lst-hd\" for=\"idx-lst-chk\"><i class=\"fa-solid fa-check-double\"><\/i>Contents<\/label>\n\t<div class=\"idx-lst-bd\">\n\t\t<ul class=\"idx-lst-ul\">\n\t\t\t\t\t\t\t<li class=\"idx-lst-li idt0\">\n\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa-regular fa-hand-point-right ico\"><\/i>\n\t\t\t\t\t\t\t\t\t\t<a href=\"#index-list-1\" title=\"Building a WordPress environment at the new location\">Building a WordPress environment at the new location<\/a>\n\t\t\t\t<\/li>\n\t\t\t\t\t\t\t\t<li class=\"idx-lst-li idt0\">\n\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa-regular fa-hand-point-right ico\"><\/i>\n\t\t\t\t\t\t\t\t\t\t<a href=\"#index-list-2\" title=\"Moving the Database\">Moving the Database<\/a>\n\t\t\t\t<\/li>\n\t\t\t\t\t\t\t\t<li class=\"idx-lst-li idt0\">\n\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa-regular fa-hand-point-right ico\"><\/i>\n\t\t\t\t\t\t\t\t\t\t<a href=\"#index-list-3\" title=\"Change database settings\">Change database settings<\/a>\n\t\t\t\t<\/li>\n\t\t\t\t\t\t\t\t<li class=\"idx-lst-li idt0\">\n\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa-regular fa-hand-point-right ico\"><\/i>\n\t\t\t\t\t\t\t\t\t\t<a href=\"#index-list-4\" title=\"Importing database information\">Importing database information<\/a>\n\t\t\t\t<\/li>\n\t\t\t\t\t\t\t\t<li class=\"idx-lst-li idt0\">\n\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa-regular fa-hand-point-right ico\"><\/i>\n\t\t\t\t\t\t\t\t\t\t<a href=\"#index-list-5\" title=\"Change Domain\">Change Domain<\/a>\n\t\t\t\t<\/li>\n\t\t\t\t\t\t\t\t<li class=\"idx-lst-li idt0\">\n\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa-regular fa-hand-point-right ico\"><\/i>\n\t\t\t\t\t\t\t\t\t\t<a href=\"#index-list-6\" title=\"Moving the WordPress environment\">Moving the WordPress environment<\/a>\n\t\t\t\t<\/li>\n\t\t\t\t\t\t\t\t<li class=\"idx-lst-li idt0\">\n\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa-regular fa-hand-point-right ico\"><\/i>\n\t\t\t\t\t\t\t\t\t\t<a href=\"#index-list-7\" title=\"Moving plugins\">Moving plugins<\/a>\n\t\t\t\t<\/li>\n\t\t\t\t\t\t\t\t<li class=\"idx-lst-li idt0\">\n\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa-regular fa-hand-point-right ico\"><\/i>\n\t\t\t\t\t\t\t\t\t\t<a href=\"#index-list-8\" title=\"Moving the theme\">Moving the theme<\/a>\n\t\t\t\t<\/li>\n\t\t\t\t\t\t\t\t<li class=\"idx-lst-li idt0\">\n\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa-regular fa-hand-point-right ico\"><\/i>\n\t\t\t\t\t\t\t\t\t\t<a href=\"#index-list-9\" title=\"Moving media files and other uploaded files\">Moving media files and other uploaded files<\/a>\n\t\t\t\t<\/li>\n\t\t\t\t\t\t\t\t<li class=\"idx-lst-li idt0\">\n\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa-regular fa-hand-point-right ico\"><\/i>\n\t\t\t\t\t\t\t\t\t\t<a href=\"#index-list-10\" title=\"Responding to &#039;Permission denied&#039;\">Responding to &#039;Permission denied&#039;<\/a>\n\t\t\t\t<\/li>\n\t\t\t\t\t\t<\/ul>\n\t<\/div>\n<\/div>\n\n\n\n\n<h2 class=\"is-style-h2df\" id=\"index-list-1\">Building a WordPress environment at the new location<\/h2>\n\n\n\n<p>First, prepare the WordPress environment of the destination.<\/p>\n\n\n\n<div class=\"wp-block-origin-block-em-box em-group em-group-default\">\n<ul><li>Web Server<\/li><li>Database Server (also database creation)<\/li><li>PHP (when not. often installed if Linux)<\/li><li>Installation of WordPress<\/li><\/ul>\n<\/div>\n\n\n\n<p>Since this section describes the migration process, the respective installation methods are omitted.<\/p>\n\n\n\n<h2 class=\"is-style-h2df\" id=\"index-list-2\">Moving the Database<\/h2>\n\n\n\n<p>Create a backup file (.sql) using the WordPress backup plugin or a database backup command such as 'mysqladmin'.<\/p>\n\n\n\n<div class=\"wp-block-origin-block-a-link-ext alk-ex center\"><a href=\"https:\/\/wordpress.org\/plugins\/backwpup\/\" target=\"_blank\" rel=\"noopener noreferrer\" title=\"WordPress Plugins - BackWPup\"><strong>WordPress Plugins - BackWPup<\/strong> <i class=\"fas fa-angle-double-right\"><\/i><\/a><\/div>\n\n\n\n<div class=\"wp-block-origin-block-a-link-ext alk-ex center\"><a href=\"https:\/\/tadtadya.com\/en\/mysql-mariadb-how-to-backup-2\/\" title=\"MySQL\/MariaDB, How to backup\"><strong>MySQL\/MariaDB, How to backup<\/strong> <i class=\"fas fa-angle-double-right\"><\/i><\/a><\/div>\n\n\n\n<h2 class=\"is-style-h2df\" id=\"index-list-3\">Change database settings<\/h2>\n\n\n\n<p>When the database settings change in a new environment, change the configuration information in <strong><span class=\"marker-yellow\">wp-config.php<\/span><\/strong>.<\/p>\n\n\n\n<div class=\"pre-code-title\">definition in wp-config.php<\/div><pre class=\"line-numbers\"><code class=\"language-vim\">define('DB_NAME', 'db-name');\ndefine('DB_USER', 'db-user');\ndefine('DB_PASSWORD', 'db-password');\n\n\/** Here's when you need to change it. Very little to change. *\/\ndefine('DB_HOST', 'localhost');\ndefine('DB_CHARSET', 'utf8');\ndefine('DB_COLLATE', '');<\/code><\/pre>\n\n\n\n<h2 class=\"is-style-h2df\" id=\"index-list-4\">Importing database information<\/h2>\n\n\n\n<div class=\"pre-code-title\"><\/div><pre class=\" command-line\" data-user=\"\" data-output=\"\"><code class=\"language-bash\">mysql -uuser -ppassword db_name &lt; backup.sql<\/code><\/pre>\n\n\n\n<p>Restore the database. The above is how to do it with MySQL (MarriaDB).<\/p>\n\n\n\n<div class=\"wp-block-origin-block-a-link-ext alk-ex center\"><a href=\"https:\/\/tadtadya.com\/en\/mysql-mariadb-how-to-restore-2\/\" title=\"MySQL\/MariaDB, How to Restore\"><strong>MySQL\/MariaDB, How to Restore<\/strong> <i class=\"fas fa-angle-double-right\"><\/i><\/a><\/div>\n\n\n\n<h2 class=\"is-style-h2df\" id=\"index-list-5\">Change Domain<\/h2>\n\n\n\n<div class=\"wp-block-origin-block-msg-box\"><div class=\"msgbox msgbox-info v1\"><i class=\"fas fa-info-circle icon\"><\/i><div class=\"msg\">\n<p>If the domain you are moving to does not change, skip this section.<\/p>\n\n\n\n<div class=\"wp-block-origin-block-a-link-ext alk-ex center\"><a href=\"#index-list-6\" title=\"Skip\"><strong>Skip<\/strong> <i class=\"fas fa-angle-double-right\"><\/i><\/a><\/div>\n<\/div><\/div><\/div>\n\n\n\n<p>Use the WordPress command tool to batch replace all the domains registered in the database.<\/p>\n\n\n\n<p>We will not use SQL bulk replace here.<\/p>\n\n\n\n<div class=\"pre-code-title\">Bulk domain replacement for DB in wp-cli command<\/div><pre class=\" command-line\" data-user=\"\" data-output=\"\"><code class=\"language-bash\">wp search-replace 'old-domain.com' 'new-domain.com'<\/code><\/pre>\n\n\n\n<p>When using multisite, the tables in the child sites will not be replaced, so we will add an option.<\/p>\n\n\n\n<div class=\"pre-code-title\">Bulk domain replacement for multiple sites<\/div><pre class=\" command-line\" data-user=\"\" data-output=\"\"><code class=\"language-bash\"> wp search-replace 'old-domain.com' 'new-domain.com' --network<\/code><\/pre>\n\n\n\n<p>The '<strong><span class=\"marker-blue\">--network<\/span><\/strong>' option will also replace the tables in the child sites of the multisite.<\/p>\n\n\n\n<p>For multisite, add the setting to wp-config.php.<\/p>\n\n\n\n<div class=\"pre-code-title\">Setting wp-config.php<\/div><pre class=\"\"><code class=\"language-vim\">define('DOMAIN_CURRENT_SITE', 'new-domain.com');<\/code><\/pre>\n\n\n\n<div class=\"wp-block-origin-block-em-box em-group em-group-point\">\n<ul><li>Don't use SQL bulk replace.<\/li><li>For batch replacement, use the WordPress command \"wp search-replace\".<\/li><\/ul>\n<\/div>\n\n\n\n<h3 class=\"is-style-h3df\">If you are having trouble with an error<\/h3>\n\n\n\n<div class=\"wp-block-origin-block-msg-box\"><div class=\"msgbox msgbox-notice v1\"><i class=\"fas fa-exclamation-triangle icon\"><\/i><div class=\"msg\">\n<p>The following error may occur with bulk domain substitution<\/p>\n\n\n\n<p>\"Error: Site 'sample.test\/' not found. Verify DOMAIN_CURRENT_SITE matches an existing site or use --url=&lt;url&gt; to override.\"<\/p>\n<\/div><\/div><\/div>\n\n\n\n<p>This error is a data inconsistency that occurs if you specify 'DOMAIN_CURRENT_SITE' in wp-config.php before importing new data into the database.<\/p>\n\n\n\n<p>This happens when importing data from the latest database into a test environment that has already been created.<\/p>\n\n\n\n<figure class=\"wp-block-table aligncenter\"><table><tbody><tr><td>wp-config.php<\/td><td>New Domain<\/td><\/tr><tr><td>Imported data<\/td><td>Old domain<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>Modify the command for bulk domain substitution to allow for this to occur.<\/p>\n\n\n\n<div class=\"pre-code-title\">Fix for bulk domain replacement<\/div><pre class=\"line-numbers\" data-user=\"root\" data-output=\"\"><code class=\"language-bash\">wp search-replace 'old-domain.com' 'new-domain.com' --url=\"old-domain.com\" --network --path=\/home\/myuser\/html\/DocumentRoot<\/code><\/pre>\n\n\n\n<p>To fix the domain inconsistency, use '--url=\"old domain\"' to force a change in the value of 'DOMAIN_CURRENT_SITE' when importing.<\/p>\n\n\n\n<p>(Keep the value in wp-config.php)<\/p>\n\n\n\n<p>I also added the '--path' option so that the 'wp' command can be executed outside of the WordPress installation directory.<\/p>\n\n\n\n<p>This command can be used for other than multisite, so batch domain changes can be performed with it.<\/p>\n\n\n\n<div class=\"wp-block-origin-block-em-box em-group em-group-link em-group-related\">\n<ul><li><strong><a href=\"https:\/\/tadtadya.com\/en\/wordpress-when-the-wp-command-is-not-available\/\" title=\"WordPress, When the wp command is not available\">WordPress, When the wp command is not available<\/a><\/strong><\/li><li><strong><a href=\"https:\/\/developer.wordpress.org\/cli\/commands\/search-replace\/\" target=\"_blank\" rel=\"noreferrer noopener\" title=\"wp-cli command official - search-replace\">wp-cli command official - search-replace<\/a><\/strong><\/li><\/ul>\n<\/div>\n\n\n\n<h2 class=\"is-style-h2df\" id=\"index-list-6\">Moving the WordPress environment<\/h2>\n\n\n\n<p>Copy backups of plugins, theme source files, uploaded media files, etc. to the new WordPress environment.<\/p>\n\n\n\n<p>Backups are provided by WordPress plugins, so it is recommended to do backups on a regular basis.<\/p>\n\n\n\n<p>Some backup plugins include database backups.<\/p>\n\n\n\n<p>I recommend <a href=\"https:\/\/wordpress.org\/plugins\/backwpup\/\" target=\"_blank\" rel=\"noreferrer noopener\" title=\"BackWPup\"><strong>BackWPup<\/strong><\/a>. It can backup plugins, themes, uploaded files including media, and databases.<\/p>\n\n\n\n<p>You can also backup your entire WordPress environment.<\/p>\n\n\n\n<h2 class=\"is-style-h2df\" id=\"index-list-7\">Moving plugins<\/h2>\n\n\n\n<p>Copy the plugin files in '<strong><span class=\"marker-yellow\">DocumentRoot\/wp-content\/plugins<\/span><\/strong>' to the new environment. You can overwrite any plugins that already exist, but to be safe, delete any duplicate plugins in the new environment before copying them.<\/p>\n\n\n\n<p>Next, confirm that the plugins you copied are displayed in the \"<span class=\"marker-yellow\">Installed Plugins<\/span>\" section of the admin panel. After confirming that they are displayed, activate each plugin.<\/p>\n\n\n\n<p>If the database has been moved, the plugin configuration information has also been copied, so that's all there is to it.<\/p>\n\n\n\n<h2 class=\"is-style-h2df\" id=\"index-list-8\">Moving the theme<\/h2>\n\n\n\n<p>Copy the theme files in '<strong><span class=\"marker-yellow\">DocumentRoot\/wp-content\/themes<\/span><\/strong>' to the new environment.<\/p>\n\n\n\n<p>Maybe you have directly written the url domain in your theme file customization. In that case, please change the domain name to match your new environment.<\/p>\n\n\n\n<div class=\"wp-block-origin-block-em-box em-group em-group-note\">\n<p>It is not a good idea to write the domain directly; use the functions provided by WordPress.<\/p>\n<\/div>\n\n\n\n<h2 class=\"is-style-h2df\" id=\"index-list-9\">Moving media files and other uploaded files<\/h2>\n\n\n\n<p>Copy the files in '<strong><span class=\"marker-yellow\">DocumentRoot\/wp-content\/uploads<\/span><\/strong>' to the new environment.<\/p>\n\n\n\n<p>That's it for the moving process.<\/p>\n\n\n\n<h2 class=\"is-style-h2df\" id=\"index-list-10\">Responding to 'Permission denied'<\/h2>\n\n\n\n<p>When the moving process is completed successfully and you check the operation, \"<strong><span class=\"marker-pink\">Permission denied<\/span><\/strong>\" may occur.<\/p>\n\n\n\n<p>This is caused by a file or directory permission error, such as when a compressed file such as tar.gz is decompressed and then transferred to a new environment.<\/p>\n\n\n\n<p>Backup files are usually compressed using tar.gz or similar, so make sure to extract them on the server in the new environment.<\/p>\n\n\n\n<p>If it still happens, change the permissions of each directory and file to the same permissions as before the move using the <strong><a href=\"https:\/\/tadtadya.com\/en\/linux-chmod-changing-file-and-directory-permissions-2\/\" title=\"Linux chmod, change file and directory permissions\">'chmod' command<\/a><\/strong>.<\/p>\n\n<!-- WP QUADS Content Ad Plugin v. 2.0.65.1 -->\n<div class=\"quads-location quads-ad2\" id=\"quads-ad2\" style=\"float:none;margin:0px;\">\n<ul class=\"quads-location-ul\">\r\n<li class=\"quads-location-li li-1\">\r\n<script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script>\r\n<ins class=\"adsbygoogle\"\r\n     style=\"display:block\"\r\n     data-ad-client=\"ca-pub-4926008942376207\"\r\n     data-ad-slot=\"6550760310\"\r\n     data-ad-format=\"auto\"\r\n     data-full-width-responsive=\"true\"><\/ins>\r\n<script>\r\n     (adsbygoogle = window.adsbygoogle || []).push({});\r\n<\/script>\r\n<\/li>\r\n<li class=\"quads-location-li li-2\">\r\n<script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script>\r\n<ins class=\"adsbygoogle\"\r\n     style=\"display:block\"\r\n     data-ad-client=\"ca-pub-4926008942376207\"\r\n     data-ad-slot=\"6550760310\"\r\n     data-ad-format=\"auto\"\r\n     data-full-width-responsive=\"true\"><\/ins>\r\n<script>\r\n     (adsbygoogle = window.adsbygoogle || []).push({});\r\n<\/script>\r\n<\/li>\r\n<\/ul>\n<\/div>\n\n","protected":false},"excerpt":{"rendered":"<p>There are four major copies of the WordPress moving process. Database, Plugins, Theme, Uploaded files such as media files. The method I'm about to show you can also be done with WordPress multisite.<\/p>\n","protected":false},"author":1,"featured_media":12486,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"jetpack_publicize_message":"WordPress: How to move the environment\r\n\r\n#WordPress\r\n#How_to_move_WordPress","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_options":[]},"categories":[9,42,43],"tags":[38,546,552,553,554],"jetpack_publicize_connections":[],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/tadtadya.com\/en\/wp-content\/uploads\/sites\/2\/2018\/10\/wordpress-1.png?fit=1280%2C671&ssl=1","jetpack_sharing_enabled":false,"jetpack_shortlink":"https:\/\/wp.me\/p8Qw77-1yF","jetpack_likes_enabled":false,"_links":{"self":[{"href":"https:\/\/tadtadya.com\/en\/wp-json\/wp\/v2\/posts\/5993"}],"collection":[{"href":"https:\/\/tadtadya.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tadtadya.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tadtadya.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tadtadya.com\/en\/wp-json\/wp\/v2\/comments?post=5993"}],"version-history":[{"count":0,"href":"https:\/\/tadtadya.com\/en\/wp-json\/wp\/v2\/posts\/5993\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/tadtadya.com\/en\/wp-json\/wp\/v2\/media\/12486"}],"wp:attachment":[{"href":"https:\/\/tadtadya.com\/en\/wp-json\/wp\/v2\/media?parent=5993"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tadtadya.com\/en\/wp-json\/wp\/v2\/categories?post=5993"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tadtadya.com\/en\/wp-json\/wp\/v2\/tags?post=5993"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}