views:

296

answers:

6

Hi,

I'm trying to make local development copies for my wordpress blog. I tried first to install wordpress locally (on XAMPP for Windows), install the plugins then import the live data (from a DB backup). The problem is whenever I import the live data I start getting all sorts of errors, even after I change the blog's URL through the database.

Also, the redirection rules I have on my server don't seem to work locally (whether set by wordpress or some of its plugins).

So is there a safe way to just grab the whole thing and make it work locally exactly like the server?

Your help is much appreciated :)

+1  A: 

Maybe somebody will come up with a tool, tutorial or a full HOWTO on this, but in the meantime a few general things on migration:

  1. The redirection rules probably don't work because Windows has trouble with the .htaccess file name due to the starting .. What I usually do is, add (or change) the AccessFileName directive in my Apache config to htaccess.txt that makes the file better usable on Windows. If that doesn't help, put the contents of .htaccess up here.

  2. From my (albeit limited) Experience with Wordpress, it is better to make a raw copy of the Wordpress file and data structure, rather than installing a fresh version and adding all the plugins. There is so much change in the Wordpress code base (automatic update of plugins etc.) that problems are legion. You would then have to change the paths locally in the configuration files, or set up a local path structure that exactly imitates that on the server.

Can you post some of the errors you get when using the live data?

Pekka
Great tip on #1. Can you elaborate on #2 though? how do I get a raw copy of the data (I currently use WP-DB-Backup)?As for the errors, when I try to move the whole installation into localhost I start getting a "not found" error for custom URLs (home page works fine though). When I install a fresh wordpress installation THEN migrate the data (phpmyadmin import/export), I get a 404 error even at the home page.Not really sure what's going on.
KeyStroke
#2: For example install phpMyAdmin on your remote server, export a full dump of the database, re-import it in phpMyAdmin locally. You can also use `mysqldump` and `mysql` if you have command line access to the server and/or locally. As for the errors, make sure your htaccess redirections work properly first. The errors may all vanish then.
Pekka
To make a raw copy of the WordPress file structure, just copy the whole thing down to your local hard drive through FTP or similar.
Svish
And make sure to update the mysql connection string, so you connect to the right database. No idea where that is done in WordPress, but should be somewhere :p I.e. change *mysql.mysite.com* to *localhost*, or whatever.
Svish
Be sure to edit your wp_options table to update your paths of your blog install.Also you will need to remember that the guid's generated for the posts will be full permalink style urls, so they will be an http. If you want to update them all I guess you could replace it with a mysql query, but generally you can work around it.
DavidYell
A: 

Here is my 2cents tip:

If you are using plugins, and one of them has an api-key (for an example, Google's analytical toolkit, requires a key), the key may be bound to the IP address where your wordpress blog is located and may fail under the localhost (127.0.0.1). So double check to see if you can obtain a global key which can work on any IP address. This is dependent on the service and plugin. Google Maps is one, Recaptcha is another that comes to mind.

Hope this helps, Best regards, Tom.

tommieb75
+5  A: 
  1. get a full backup of all the files in your online wordpress installation
  2. get a complete backup of the database in use
  3. with any text editing software, process the SQL file of the database backup and change every occurrence of http://old.site with http://localhost
  4. extract the files to your document root
  5. edit wp-config.php to tweak database host/user/pass
  6. import the modified SQL backup
  7. login into admin panel, go to Options->Permalink and save to update permalinks

No need to install anything, just grab what you have online. On windows you might have to rename .htaccess

kemp
The search + replace saved my life! Thanks mate :) +1
alex
+1  A: 

Perhaps a much simpler way would just be to add a host reference from the address of blog to local host e.g. http://en.wikipedia.org/wiki/Hosts_file. This would allow you to test your blog as if it were actually running on the domain without any of the potential pitfalls.

ternaryOperator
A: 

kemp's answer is just about perfect. I only wanted to add that you could download something like VirtualBox or VMware and install Linux to it and get a webserver up and running on the virtual machine. This would let you get past any WAMP-LAMP inconsistencies.

gabrielk
A: 

Kemp's answer is good - but you don't need to edit your SQL dump, or change the database.

Instead, add 2 lines to your wp-config.php file (I normally add them just above the comment line in the file:

define('WP_HOME','http://localhost');
define('WP_SITEURL','http://localhost');


/* That's all, stop editing! Happy blogging. */ <-- this line already present in the file.
anu