Solved

Running a wordpress development site that mirrors live site?

Posted on 2010-11-27
12
661 Views
Last Modified: 2012-05-10
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!
0
Comment
Question by:uzzidesign
  • 7
  • 4
12 Comments
 
LVL 70

Accepted Solution

by:
Jason C. Levine earned 500 total points
ID: 34223040
Hi uzzidesign,

The issue is that WordPress asks for the URL of the site when you do the initial install and when you backup/restore from a live server, all of the references to the URL or paths are in the db rows you have just imported.

So what you need to do is go through the options table and look for full URLs and convert them to the localhost version.  That should allow the local version to work as intended.

>>  Do the databases (live and local) need to be named the same? Currently they're not.

The overall database name is set in wp-config and as long as it is correct, they don't have to be the same name.  The tables, OTOH, do need to be named the same if WP is randomizing the tables...
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 34223046
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.
0
 
LVL 6

Author Comment

by:uzzidesign
ID: 34223095
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?
0
 
LVL 6

Author Comment

by:uzzidesign
ID: 34223109
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.
0
 
LVL 6

Author Comment

by:uzzidesign
ID: 34223121
What I mean is, is there a find/replace in phpMyAdmin somewhere?
0
 
LVL 6

Author Comment

by:uzzidesign
ID: 34223159
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).
0
Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 34223237
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.
0
 
LVL 8

Expert Comment

by:Sam Cohen
ID: 34223493
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
0
 
LVL 6

Author Comment

by:uzzidesign
ID: 34223643
> 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
0
 
LVL 6

Author Closing Comment

by:uzzidesign
ID: 34223646
Thanks, Jason. It was helpful to be reassured that I wasn't blowing stuff up :)
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 34223660
>> 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!
0
 
LVL 6

Author Comment

by:uzzidesign
ID: 34223735
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 :)
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
The purpose of this video is to demonstrate how to properly insert a Vimeo Video into a WordPress site or Blog. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp…
The purpose of this video is to demonstrate how to insert an Iframe into WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Open Page or Post…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now