?
Solved

Running a wordpress development site that mirrors live site?

Posted on 2010-11-27
12
Medium Priority
?
677 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 4
12 Comments
 
LVL 70

Accepted Solution

by:
Jason C. Levine earned 2000 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
What Is Blockchain Technology?

Blockchain is a technology that underpins the success of Bitcoin and other digital currencies, but it has uses far beyond finance. Learn how blockchain works and why it is proving disruptive to other areas of IT.

 
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
 
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

Limited time offer using promo code EXPERTS30

Designed with a wealth of functionality and convenience, ATEN's new Thunderbolt™ 2 Sharing Switch takes your Thunderbolt setup to the next level. Now through September 15, 2017, Experts Exchange members get 30% off the US7220 on the ATEN USA eShop using promo code EXPERTS30.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
This video teaches viewers how to create their own website using cPanel and Wordpress. Tutorial walks users through how to set up their own domain name from tools like Domain Registrar, Hosting Account, and Wordpress. More specifically, the order in…
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.
Suggested Courses

770 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