WordPress Migrations - Moving WordPress to Another Server

Post on 15-Jun-2015

182 views 7 download

Tags:

description

How to successfully move your WordPress site from one server to another using a variety of methods and tools.

Transcript of WordPress Migrations - Moving WordPress to Another Server

www.limecanvas.com

You may have to do one or all of the following to move a WordPress site from one server/folder to another.

Physically relocate the files (PHP, images etc.)

Physically relocate the database (SQL)

Reconfigure WordPress to point to new database

Rename URLs in database from old domain/folder to new domain/folder

You could move them one-by-one using FTP.

BUT that would take ages..

Pack entire WordPress site into one archive

• Zip, Gzip, lhz, 7z …whatever

The method:

Download the archive to local machine then upload and unpack at new location

Command line for SSH:

tar –zcvrf archive.tar.gz ./

Note: tar by itself doesn’t compress -z = gzip -c = create -v = verbose -f = file -r = recursive

Unpacking:

tar –zxvf archive.tar.gz (-x = extract)

File Manager on cPanel: Compress/Uncompress

FTP = “File Transfer Protocol” – PRO: Has been around since dawn of Interwebs

– PRO: Vastly supported

– CON: Two channels. One for data, one for control. Bit of overhead

– CON: No encryption. None. Nadda. Tiddly Squat. Zero! N O T H I N G

Try to avoid using FTP where possible.

However, most shared hosting plans do not support secure FTP WTF is that all about?

Two completely different methods!

FTPS = “Secure FTP” Port 990

Uses two data streams. One for data + one for control

SSL encryption. Widely supported.

SFTP = “SSH File Transfer Protocol” Port 22

Uses one data stream for both control and data

Requires SSH keys management. More secure.

Pros/Cons: https://www.eldos.com/security/articles/4672.php?page=all

Command line :-P

WinSCP (free)

Has a global password to protect accounts

PuTTY (free)

SSH client

IDEs

PHPStorm and Dreamweaver have built in FTP clients

1. At old location, pack existing site into a compressed archive file

2. Download archive file to local machine

3. FTP archive file up to new location (securely if possible)

4. Unpack archive file at new location

Congrats - Your WordPress site files are now at the new location.

Two Considerations before attempting to move the database

1. “Am I moving the database to a new database server?” Will mostly be yes.

2. “Am I moving the site to a new domain or folder structure?” e.g. myolddomain.com mynewdomain.com mydomain.com/wordpress mydomain.com/blog If so, you will also need to rename the old domain URLs that are stored in the database, to your new domain

URLs in your content or links to images/resources on your posts and pages are stored in the database.

Some, URLs will be stored along with other related information (e.g post/media ID, attributes) – an array of information

Arrays are stored in the DB as serialized data.

e.g. {s:26:”http://www.limecanvas.com/”}

s:26 = number of characters in the string

By simply renaming URLs in the SQL file using a text editor, the number of characters in the string will be incorrect and that will cause data issues. You need to update both.

Upload the sql.gz

file that was

generated by WP

Migrate DB

PHPMyAdmin or PHP environment may have upload limitations.

Three tricks:

1. Use SSH mysql –u username –p database_name < file.sql or for a .sql.gz

zcat file.sql.gz | mysql -u username –p database_name

2. Use BigDump script http://www.ozerov.de/bigdump/

3. Split SQL file into manageable chunks Not recommended. Easy to break SQL statements.

1. Use WP Migrate DB

Rename old domain to new

domain

2. Generate .sql.gz file

3. Load into blank DB using

PHPMyAdmin

Last thing to do is to tell WordPress where the database is

Edit the wp-config.php file

define('DB_NAME', 'DBNAME');

define('DB_USER', 'DBUSERNAME');

define('DB_PASSWORD', 'DBPASSWORD');

define('DB_HOST', 'localhost');

Read Japh’s “Migrating a Site Quickly with SSH and WP-CLI”

SSH

– scp ./* wil@newdomain.com:~/limeca/wordpress

WP-CLI “a command line interface for WordPress”

– wp db export - l gzip > database.sql.gz

– wp core download

– gunzip < database.sql.gz | wp db import

– wp search-replace olddomain.com newdomain.com

– then edit the wp-config.php file

XCloner Plugin (free) http://www.xcloner.com/

OK – if you’re not changing domain or URL structure i.e. “cloning”

BackupBuddy (paid) http://ithemes.com/purchase/backupbuddy/

Using the “Move” feature. Deploy to a new domain.

Git (free) http://git-scm.com/

From “master” branch, pull on or push to server. Doesn’t do the DB though on its own (use hooks)

When moving your site watch out for…

.htaccess file (hidden file in your site root folder) – This file is used for caching and permalinks. It may contain references

to your old domain/URL structure. If in doubt, don’t move it to the new server and let WordPress create a new one by saving your Permalinks settings in the moved site.

Caching/Security Plugins – These may also use the .htaccess file to add rewrite rules which may

contain the old domain/URL structure. Disabled them before the move and then activate them again on the new server.

[1] newfillmore.com

[3] maran.com

[4] vonbandersnatch.files.wordpress.com

[7] limecanvas.com

[11] memegenerator.net

[15] limecanvas.com

[16] limecanvas.com

[18] memegenerator.net

[19] memegenerator.net