amuck-landowner

[Request] Wordpress from localhost to vps migration.

juan

New Member
Good Day, can someone give a better secure tutorial of migrating wordpress site from localhost to vps with the complete better file/folder permissions. I have a bunch of wordpress site that are hosted locally on a desktop machine and will be migrated to a vps. Thanks in advance.
 
Last edited by a moderator:

George_Fusioned

Active Member
Verified Provider
Are you running some kind of control panel on the VPS?

Actually you should simply SFTP the files to your VPS in their respective folders for each domain, restore the MySQL databases, and (probably) use the WP_HOME & WP_SITEURL directives in each sites wp-config.php to set the real URL of each WordPress site (more about that here: http://codex.wordpress.org/Changing_The_Site_URL )
 

bizzard

Active Member
The best solution is to create a database dump and replace the localhost URL's with the new URL's in server, using a text editor. For eg., replace all http://localhost.com/wordpress/ to http://www.example.com/

Then upload it to the VPS. You might also need to replace few directory paths like "/var/www/wordpress" in your local system to match the path in your VPS. Usually, its used by plugins.

In the VPS, download the latest wordpress, extract it, replace the wp-content folder with your local files and configure the installation using wp-config.php file.

You will be good to go with that.
 

wlanboy

Content Contributer
I moved about 9 wordpress blogs and you have to care about the file paths and the domains.

  1. Copy database
  2. Copy files
  3. edit wp-config.php

    define('WP_HOME', 'http://www.newdomain.com');
    define('WP_SITEURL', 'http://www.newdomain.com');

  4. Run following SQL commands
    Code:
    update wp_postmeta set meta_value = replace(meta_value, '/old/directory', '/new/directory');
    update wp_options set option_value = replace(option_value, '/old/directory', '/new/directory');
    update wp_usermeta set meta_value = replace(meta_value, 'olddomain.com', 'newdomain.com');
    update wp_options set option_value = replace(option_value, 'olddomain.com', 'newdomain.com');
    update wp_comments set comment_author_url = replace(comment_author_url, 'olddomain.com', 'newdomain.com');
    update wp_posts set post_content = replace(post_content, 'olddomain.com', 'newdomain.com');
    update wp_posts set post_excerpt = replace(post_excerpt, 'olddomain.com', 'newdomain.com');
    update wp_posts set guid = replace(guid, 'olddomain.com', 'newdomain.com');
That's it.
 

juan

New Member
I have moved wp sites before and i always forget how and what files and folders should i change permissions. This is where i always messed up the migration. And nope i don't use cp, just the command line for all.
 

vanarp

Active Member
While the manual methods given above are the good ways to learn, I personally prefer to use Duplicator plugin for any WP site migration irrespective of server environment. It takes care of lot of that manual stuff.

As for file permissions you might want to go through this WP Hardening codex page.
 
Top
amuck-landowner