Link to home
Start Free TrialLog in
Avatar of uzzidesign
uzzidesignFlag for United States of America

asked on

Running a wordpress development site that mirrors live site?

Hi,
I am trying something for the first time, without any experience working with databases at all, so please forgive my questions if I don't quite understand some of these concepts.

I have several live, hosted, Wordpress sites that I have been developing on the live servers (no development environment). I know this is pretty unrefined.

I would like to set up a development instance of each of these sites (retroactively) so that I can mirror the sites locally, and start developing "correctly", so to speak.

I have installed MAMP and am running several instances of Wordpress from a local apache htdocs directory on my Mac. I'm using the Mac's default instance of apache running with Web Sharing on my default port of 80 for something else, so MAMP is running on it's default port of 8888, if that's relevant.

Where I've run into problems is the following. My assumption was that if I wanted to catch up my local instances of the live sites so that I had a semi-useful development version going forward, that all I would have to do is do a database backup from the live site, and import it to my local MySQL database for the local instance of Wordpress. PhpMyAdmin gave me a successful import confirmation message but when I refreshed the local instance of Wordpress at

http://localhost:8888/sitename/wordpress/

it changes my URL to

http://localhost/sitename/wordpress/

giving me a 404. If I try to manually navigate to

http://localhost:8888/sitename/wordpress/wp-login.php

It correctly gives me the login screen, BUT my login no longer works and it redirects me to the LIVE URL of www.sitename.com/wordpress/wp-login.php. Do the databases (live and local) need to be named the same? Currently they're not.

I'm sure this has to do with my ignorance when it comes to MySQL. Probably something more complicated involved with resolving paths and whatnot. But I'm totally lost at this point. Help!
ASKER CERTIFIED SOLUTION
Avatar of Jason C. Levine
Jason C. Levine
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Also note that any content added to the live site may have the full live site URL attached to images or links.  You may have to do the same search and replace in the posts table too.
Avatar of uzzidesign

ASKER

Jason, thanks! I just found this tutorial just before seeing your response, the last step of which is exactly what you instructed as well. But alas, it's still not working.

I have started over completely, the live htdocs directory is mirrored locally, and the database is named the same locally as it is live. I've restored it and renamed the siteurl and home tables to

http://localhost:8888/sitename/wordpress/

Now, when I go to the local url I'm at least getting a blank page (implying a database error, I presume) which is different than a 404. Am I close? Have any idea where I could be going wrong?
Woohoo! I had my index.php in my root directory, as I usually do

require('.wordpress/wp-blog-header.php');

Open in new window


but just found my typo, which should be

require('./wordpress/wp-blog-header.php');

Open in new window


It's working!

But you are correct about my image and style paths. Can you explain how I go about

> You may have to do the same search and replace in the posts table too.
What I mean is, is there a find/replace in phpMyAdmin somewhere?
Okay, sorry if I'm running ahead of you, but I found this helpful info on the googles

UPDATE [your_table_name] SET [your_table_field] = REPLACE([your_table_field], '[string_to_find]' , '[string_to_be_replaced]');

Open in new window


and used this format to replace my urls in phpMyAdmin. It was a bit scary for me, having never run a sql before, but now it appears that all of my URLs have been updated. But still no love from my styles (and it appears some of my pages have still dropped off the map, or at least the hrefs to them in the anchors).
Peter, you're doing great.

The styles and what not are handled by themes, so you may need to search through the rest of the tables for other instances of paths or search through the theme files themselves to see if anything is hardcoded that shouldn't ben.  Worst case scenario, just upload the theme again and reactivate.

While you can do this with MySQL (as you discovered), I am assuming you did a data dump and ended up with a .sql file which you then imported.  I would do all Finds and Replaces on that file, since it is plain text and a lot easier to deal with.
Ok.
Here is what is going on i believe.
You can simply move a wordpress db from one wordpress to another.
The best way to do this, is to go into the phpmyadmin and click export, which will pop on all the sql data....
copy the sql data to textedit do a find and replace of the following:

http://www.myoldsiteurl.com/.........
to
http://localhost:8888/mysitefoldername/.....

then upload it to you MAMP's phpmyadmin

Simple...

This is the most effective , and quick way to transfer sql data from wordpress to wordpress
> I would do all Finds and Replaces on that file, since it is plain text and a lot easier to deal with.

heh, yes I guess that would be easier, thanks :)

k, fixed the styles, turned out to be another typo, heh
Thanks, Jason. It was helpful to be reassured that I wasn't blowing stuff up :)
>> Thanks, Jason. It was helpful to be reassured that I wasn't blowing stuff up :)

Yeah, I know the feeling.  The good news is that it's pretty hard to bork a WordPress beyond redemption.  Good luck with the projects!
Here's another nugget for anyone grazing on this thread down the road: you may have to reset/update your permalinks once you've restored your local db, even if your urls all seem correct :)