Move WordPress to new location or server, easiest way

Moving wordpress (image from www.digicrab.com)

When creating a site on WordPress there comes a point when you need to move it to production environment, to client's webhosting etc. Here is the simplest way of moving WordPress. 

 

1. Copy all files to new server via FTP

 

2. Export database via phpmyadmin from a) old server and b) import to new server.

 

3. Log in to new server phpmyadmin and Change Home and Siteurl in database table wp_options to your new address (alternative methods to change siteurl).

 

4. Change image URLs. Perform a Find and replace on tables wp_posts and wp_postmeta . Search for your old base URL and replace that with your new base URL.

WP_POSTS

Click on wp_posts -> Search -> Find and Replace -> enter your old URL with http and new URL with http, do not include a trailing slash and select column post_content and then replace.

WP_POSTMETA

Click on wp_postmeta -> Search -> Find and Replace -> enter your old URL with http and new URL with http, do not include a trailing slash and select column meta_value and then replace.

WordPress stores your image urls as absolute not relative because the images can appear in more places than one page and they haven't figured out yet how to serve them via a relative URL.

 

5. Assuming you have the new database set up add connection parametres to wp-config.php on your new server.

/** The name of the database for WordPress */
define('DB_NAME', 'userna5_wp1');

/** MySQL database username */
define('DB_USER', 'userna5_wp1');

/** MySQL database password */
define('DB_PASSWORD', 'passwordgoeshere');

/** MySQL hostname */
define('DB_HOST', 'localhost');

 

6. Log in to admin http://yoursite.com/wp-admin and go to Settings -> Permalinks, and click Save - I've found this has to be done in order for the URL rewrites to work correctly if they were enabled in your testing site.

 

7. Go to Settings -> Media and change the media location to wp-content/uploads. Should work, if not, see for your full path from your hosting provider or FTP client and include that in here. 

 

Done!

Ps, If you hard-coded absolute URLs in your template or CSS files you need to edit them manually. This is how I move my WordPress sites without installing plugins to move WordPress. Simple and works.

 

 

About me

Iinstructor of robotics (LEGO Mindstorms), computer teacher, IT support, web dev, currently studying cyber-physical systems engineering.

If you found a solution here, would you consider donating $25,000 for my next project?

Just kidding, 1$ would do fine.

Hope you found what you needed. Thanks for stepping by.