Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 693
  • Last Modified:

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!
0
uzzidesign
Asked:
uzzidesign
  • 7
  • 4
1 Solution
 
Jason C. LevineNo oneCommented:
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
 
Jason C. LevineNo oneCommented:
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
 
uzzidesignAuthor Commented:
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
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
uzzidesignAuthor Commented:
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
 
uzzidesignAuthor Commented:
What I mean is, is there a find/replace in phpMyAdmin somewhere?
0
 
uzzidesignAuthor Commented:
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
 
Jason C. LevineNo oneCommented:
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
 
Sam CohenConsultant to Digital/DeveloperCommented:
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
 
uzzidesignAuthor Commented:
> 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
 
uzzidesignAuthor Commented:
Thanks, Jason. It was helpful to be reassured that I wasn't blowing stuff up :)
0
 
Jason C. LevineNo oneCommented:
>> 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
 
uzzidesignAuthor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 7
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now