I’ve been building a website using WordPress for the couple of weeks on my localhost. My plan was to export it when I’m done and then import it onto the live server.
Today I found out a couple of things:
-
WordPress’ Export tool only exports what’s in the database, nothing else. It doesn’t export images, etc. This could be easily remedied by simply copy pasting the files, but I was hoping for a complete solution where a tool will export EVERYTHING into a single zip file and then import than zip file onto live server to basically create an identical clone.
-
The paths that is created within the XML file generated by the Export tool uses absolute paths, and this is especially troublesome. Example:
http://localhost/wordpress/wp-content/uploads/2011/07/GSI-70-Automated-OAE-Screener.jpg
I haven’t tested it, but I imagine that when I import this XML onto my live server WordPress will look for a file at http://localhost/… and that’s just not gonna work of course. It would work if the paths are relative paths.
What do you guys think? Any suggestions? Ideas? Solutions?
Thanks a lot!
I’ve seen a bunch of ways of doing this, but here are a couple:
Use a plugin, like BackupBuddy (paid): http://pluginbuddy.com/purchase/backupbuddy/
Export your whole DB using phpMyAdmin and run a search-and-replace tool that properly deals with the serialized data, e.g. https://interconnectit.com/products/search-and-replace-for-wordpress-databases/ (I use this, and it works just fine). Then on the live server, create an empty DB and import this modified sql dump.
There was also a GSOC project this year for moving sites, called WordPress Move. Could work, not sure though: http://wordpress.org/extend/plugins/wordpress-move/
Another way to seamlessly switch from localhost to live (for MS Windows):
from your site control panel download a database copy and a site back-up of your files, and copy them to your localhost (for eg
C:/wamp/www/
) and import the db in your phpmyadmin; it’s better to do this the other way around to make sure your live site doesn’t run into any compatibility issues with the database if you later import the db.edit system32/drivers/etc/hosts file and point your site’s domain to localhost:
Now you can access your localhost WP version from your real site domain whenever that line in the Windows hosts file is present. WP will also think that this is the live site and you don’t need to change paths, re-configure plugins etc.
The only thing you’ll need to do is to import / export the database, which is pretty easy to do, and comment / uncomment that line from the hosts file, depending on which version of the site you want to access.
If you have multiple sites on your localhost in your “www” directory (like
C:/wamp/www/mysite/
, then you’ll also need to create virtual hosts for each o them:configure Apache from conf/extra/httpd-vhosts.conf:
change
NameVirtualHost *:80
toNameVirtualHost *
add:
(change paths accordingly)
in conf/httpd.conf you may need to add / or uncomment:
WP-Cli, definitively, as explained here.
In you localhost:
Upload the SQL file and the
wp-content/uploads
to your live server:I wrote a blog outlining a bunch of different ways to set up a testing environment for WP – it may be useful to you: http://wpmu.org/10-ways-to-set-up-a-testing-environment-for-wordpress/ Most of these take only a few minutes to set up.