24
www.limecanvas.com

WordPress Migrations - Moving WordPress to Another Server

Embed Size (px)

DESCRIPTION

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

Citation preview

Page 1: WordPress Migrations - Moving WordPress to Another Server

www.limecanvas.com

Page 2: WordPress Migrations - Moving WordPress to Another Server

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

Page 3: WordPress Migrations - Moving WordPress to Another Server

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

Page 4: WordPress Migrations - Moving WordPress to Another Server

BUT that would take ages..

Page 5: WordPress Migrations - Moving WordPress to Another Server

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

Page 6: WordPress Migrations - Moving WordPress to Another Server

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)

Page 7: WordPress Migrations - Moving WordPress to Another Server

File Manager on cPanel: Compress/Uncompress

Page 8: WordPress Migrations - Moving WordPress to Another Server

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?

Page 9: WordPress Migrations - Moving WordPress to Another Server

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

Page 10: WordPress Migrations - Moving WordPress to Another Server

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

Page 11: WordPress Migrations - Moving WordPress to Another Server

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.

Page 12: WordPress Migrations - Moving WordPress to Another Server

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

Page 13: WordPress Migrations - Moving WordPress to Another Server

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.

Page 15: WordPress Migrations - Moving WordPress to Another Server
Page 16: WordPress Migrations - Moving WordPress to Another Server

Upload the sql.gz

file that was

generated by WP

Migrate DB

Page 17: WordPress Migrations - Moving WordPress to Another Server

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.

Page 18: WordPress Migrations - Moving WordPress to Another Server

1. Use WP Migrate DB

Rename old domain to new

domain

2. Generate .sql.gz file

3. Load into blank DB using

PHPMyAdmin

Page 19: WordPress Migrations - Moving WordPress to Another Server

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');

Page 20: WordPress Migrations - Moving WordPress to Another Server

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

SSH

– scp ./* [email protected]:~/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

Page 21: WordPress Migrations - Moving WordPress to Another Server

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)

Page 22: WordPress Migrations - Moving WordPress to Another Server

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.

Page 23: WordPress Migrations - Moving WordPress to Another 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

Page 24: WordPress Migrations - Moving WordPress to Another Server