WordPress Cone/migration and Backup (from Server A to Server B)
Today, I am trying to back up my WordPress on Server A to Server B. To assist my future operations, I would like to open a post to record the procedures briefly.
Firstly, you need to backup all the wordpress folder as well as the SQL. If you can, just use the export function of phpMyAdmin on Server A.
However, there is some tricky point is that you have to click two boxes: 1) 壓縮: zip and 2) 匯出資料庫為各別檔案 in order to zip the .sql by using phpMyAdmin function.
Copy the whole folder from Server A
MUST export xxx.sql.zip (one of the phpMyAdmin Export Function)
Then, just copy and paste the whole folder to Server B
And import the xxx.sql.zip to Server B by using phpMyAdmin
If you have problem during import – please pay attention on the limitation on upload setting in php.ini
Reference: http://tech.smallya.net/2017/11/21/phpmyadmin%E7%84%A1%E6%B3%95%E6%AD%A3%E5%B8%B8%E5%8C%AF%E5%85%A5%E4%B8%8A%E5%82%B3%E5%A4%A7%E5%AE%B9%E9%87%8Fsql%E6%AA%94%E6%A1%88%E5%95%8F%E9%A1%8C%E8%A7%A3%E6%B1%BA/
upload_max_filesize = 100M;
post_max_size = 100M;
Then follow instruction of the link : https://www.wpbeginner.com/wp-tutorials/how-to-fix-the-error-establishing-a-database-connection-in-wordpress/ to edit the WP-Config.php
Of course, you can test the connection by using another php
testconnection.php
<?php
$link = mysqli_connect('localhost', 'username', 'password');
if (!$link) {
die('Could not connect: ' . mysqli_error());
}
echo 'Connected successfully';
mysqli_close($link);
?>
UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldurl', 'http://www.newurl') WHERE option_name = 'home' OR option_name = 'siteurl'; UPDATE wp_posts SET guid = replace(guid, 'http://www.oldurl','http://www.newurl'); UPDATE wp_posts SET post_content = replace(post_content, 'http://www.oldurl', 'http://www.newurl'); UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.oldurl','http://www.newurl');
Edit wp-config.php
It is possible to set the site URL manually in the wp-config.php file.
Add these two lines to your wp-config.php, where “example.com” is the correct location of your site.
define( 'WP_HOME', 'http://www.newurl' ); define( 'WP_SITEURL', 'http://www.newurl' );
Also, please change the “define(‘WP_DEBUG’, false);” to “define(‘WP_DEBUG’, true);”
“define(‘WP_DEBUG’, false);” ⇒ “define(‘WP_DEBUG’, true);”
- After log onto admin page of your wordpress >> Setting >> Permalinks: there are various options, please make sure you have choose the correct setting, if you are not sure, try-and-errors method could help.. just click every one to try it.
- You may need to set up the Virtual Host if you have various WordPress in your Server B
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/"
ServerName localhost
<Directory "/">
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/host1"
ServerName host1.localhost
<Directory "C:/xampp/htdocs/host1">
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/host2"
ServerName host2.localhost
<Directory "C:/xampp/htdocs/host2">
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/host3"
ServerName host3.localhost
<Directory "C:/xampp/htdocs/host3">
</Directory>
</VirtualHost>