WordPress Multisite site migration

Moving the site on WordPress Multisite from the local server to the hosting and vice versa considered a very difficult topic, although nothing complicated is here. Now you will see this. I hope that this article will be useful for amateur developers on WordPress.

What do we need to do?
All the same, as if you were moving a regular site on WordPress. So, what is await us:

I have a WordPress Multisite site with subdomains on the local “Open Server” server, accessible via url addresses http://localhost/seattle and http://en.localhost/seattle, which I am going to move to the hosting with the domain https://seattle.by/wordress and the subdomain https://en.seattle/wordpress.

Now let’s pause so that I explain to you how to configure subdomains so that site on WordPress Multisite start working.
On the local server: add the alias *.localhost => localhost in the Open Server settings in the aliases tab in order the site has access to the same files from the URL with the domain and the URL with the subdomain.
On hosting to achieve this you need to create a subdomain seattleby.com in cPanel and specify /public_html as the document root.

1. Transfer of site files to hosting

Copying files can be done either through ftp, or through cPanel (download the archive, and then unpack it), or through the console via ssh.

scp –rp seattle/ username@seattle.by:public_html/wordpress/

The console is open in localhost.
seattle/ – the directory where WordPress is installed.
username – the name for the seattle.by domain (it’s the same as the login name for cPanel).
public_html/wordpress/ – the path from the root of the site to the folder into which the files are copied.
flag r – recursive copying.
flag p – saves the modification time of files.
Then you will need to enter the password (as in cPanel). When you enter it will not be visible.

2. Moving the database

2.1. Exporting the database

Export of the database can be done either by a plugin, or through phpMyAdmin, or via the console.

mysqldump –u username -p database > dbbackup.sql

username – the name to log into phpMyAdmin.
database – the name of the database.
dbbackup.sql – the path to where the database will be exported.
Then you will need to enter the password (the same as for phpMyAdmin). When you enter it will not be visible.

2.2. Changes in the database

Let’s replace all old domains with new ones.

http://localhost/seattle we’ll change to https://seattle.by,
http://en.localhost/seattle to https://seattleby.com.

I’ll make changes with the console.

sed 's/http:\/\/en.localhost\/seattle/https:\/\/seattleby.com\/wordpress/g' backup.sql > dbbackup-2.sql
sed 's/http:\/\/localhost\/seattle/https:\/\/seattle.by\/wordpress/g' dbbackup-2.sql > dbbackup-3.sql

dbbackup-3.sql – the database backup we need.

2.3. Importing a database

Import the database to seattle.by we can make using the console or via phpMyAdmin.
The import of dbbackup-3.sql we’ll done with phpMyAdmin, because in Section 2.4 we will use phpMyAdmin again.

2.4. Changes in the database tables

I will indicate the tables in which we would like to make changes, what you need to change will be highlighted in red.

table “wp_options”

table “wp_site”

table “wp_sitemeta”

table “wp_blogs”

table “wp#options”
where # – number of the blog (site), for example, ‘_2’.

We finished with the database.

3. Edit the .htaccess file

In the .htaccess file (in cPanel or via ftp client, for example, FileZilla) we change RewriteBase. Instead of RewriteBase /seattle/ we write RewriteBase /wordpress/, because earlier WordPress was installed in the “seattle” folder, and now it will be in the “wordpress” folder.

4. Edit wp-config.php file

In wp-config.php changes are needed in the following lines

define('DB_NAME', database);
define('DB_USER', 'root');
define('DB_PASSWORD', '');
define('DB_HOST', 'localhost');

define('DOMAIN_CURRENT_SITE', 'localhost');
define('PATH_CURRENT_SITE', '/seattle/');

I gave the source file and I think that it will be not difficult to guess what you need to change here.
If authorization of the administration panel does not work, in wp-config.php you need to append define(‘COOKIE_DOMAIN’, $_SERVER[‘HTTP_HOST’] );.

I hope that this article will be useful, but for those who have questions, suggestions or advice, I ask you not to regret the time and write a comment. Thank you!

Leave a Reply

Your email address will not be published.