[wp-hackers] Keep local DB in sync with remote DB

Stephen Rider wp-hackers at striderweb.com
Mon Dec 1 03:45:44 GMT 2008


On Nov 30, 2008, at 4:35 PM, Mike Schinkel wrote:

Stephen Rider wrote:
>> Not necessarily -- if the config points to "localhost" for the DB
>> then it is at the same computer on which you're running
>> WordPress (whether test or live server).

> Also not necessarily.  Not all web hosts using "localhost" for their  
> MySQL
> services, MediaTemple for example.

I know.  That's what I meant by the "if".  My live host server does  
use localhost, and it works on my local machine too, so I'm good. :)   
Sorry I wasn't more clear.

>> I keep the wp-config.php one directory up from the WordPress  
>> files.  The local and "live" wp-config files aren't synced, but  
>> everything else is. Works perfectly for me.  No extra code needed.
>> On another note: I keep my wp-content in a separate place too, so  
>> when upgrading I can completely wipe the wp/ directory and upload  
>> the new files.
>
> How does WP know where to find them?  What do you have to change?

As of WP 2.6, the wp-config.php file can be one directory up from the  
WordPress files.  No need to change anything - it works  
automatically.  If WP doesn't find a wp-config.php file, it looks one  
directory up.
* WordPress is at example.com/wp/
* wp-config.php is at example.com/

For moving wp-content, I set the WP_CONTENT_DIR and WP_CONTENT_URL  
constants.

ALSO:  I did not notice in your instructions -- you also need to add  
the .loc (or in my case, .local) domain to your "hosts" file.   
(Obviously you've done this, but I didn't see it in your directions.)

What you do is very similar to what I do.  I modify the Apache config  
to add the different domains, I also add those domains to my hosts  
file.  Then I can go to example.com for the live site or example.local  
for the local test site.  I run Apache via MAMP on my Mac laptop.

The wp-config.php files are basically identical, except that the local  
one defines WP_SITEURL and WP_HOME.  That way when I import the data  
from my live site to the local site, it works with the local copy  
despite the .com being set in the database.  The CONSTANT overwrites  
that setting from the DB.

Stephen


-- 
Stephen Rider
<http://striderweb.com/>





More information about the wp-hackers mailing list