[wp-hackers] WP Development & Production Sites

Otto otto at ottodestruct.com
Fri Dec 17 12:37:38 UTC 2010

On Fri, Dec 17, 2010 at 1:39 AM, Ankur Oberoi <aoberoi at gmail.com> wrote:
>> Okay, let's say your production site is live.example.com and your
>> staging site is stage.example.com.
>> On your staging site, you set it up to think it's the live site, with
>> the live URL. This is to make it identical in content and database and
>> such with the live site.
>> Then, in some file that is not going to the live site (wp-config, any
>> plugin, etc), you'd do something sorta like this:
>> ob_start('my_callback');
>> function my_callback($out) {
>>   return str_replace('live.example.com', 'stage.example.com', $out);
>> }
>> Output buffering. It's easy.
>> http://php.net/manual/en/function.ob-start.php
> I just got around to trying this out. At first I thought this was perfect and I took ur advice on modifying the hosts file to point to my own machine for the live URL. Then I tried to access wp-admin and I have an issue, maybe you've dealt with this so you can help me out.
> I (will) have a staging server at 'stage.example.com' and the site lives at 'example.com', so I set my output buffering callback function like this:
> function my_callback($out) {
>        str_replace('example.com', 'stage.example.com', $out);
>        return str_replace('http://example.com', 'http://stage.example.com', $out);
> }
> I am trying to be extra cautious about the url, although i don't like the fact that if anywhere in my content i talk about example.com it will automatically be changed to stage.example.com, but in this case that won't happen so lets just ignore that.
> on my staging machine I added a line to /etc/hosts:
> stage.example.com
> the machine also has a vhost running whose ServerName (apache specfic i guess) is set to stage.example.com and points to the directory in which the site lives.
> I am pretty sure I did all the steps right, but what would it take for my client to be able to visit stage.example.com/wp-admin in order to see the admin section as usual?

If you want your client to see the staging site, then the staging site
has to be somewhere that they can see it. This means that if you're
running it on the local machine, then that ain't going to work.

I was kind of assuming that stage.example.com was a live site
somewhere on the internet. If you're developing locally, then no magic
in the world will put the local install on the live internet... short
of actually putting the machine on the live internet as a server with
a domain name pointing to it.


More information about the wp-hackers mailing list