I'm having trouble configuring wp-config.php correctly in a staged server environment. I'm being told that I should be working in my stage environment for Wordpress with an example address of http://www-stage.website.com. It will then mirror to the production server at http://website.com as they use the same database.

Any uploads, plugins and themes should also be done on the stage site, but configuring the config file has been a challenge.

Am I on the right track in using something like


or should I only be configuring the site through the WP general settings? Or am I just totally going about this the wrong way?

The latter seems to be the case.

  • 2
    possible duplicate of Developing, Testing and Releasing Oct 12, 2012 at 20:20
  • Well, does it achieve what you want? Please elaborate what you need to configure (there are a lot of things to tweak) and what of it you can't achieve currently.
    – Rarst
    Oct 13, 2012 at 21:34

2 Answers 2


I would be very hesitant in having the same database for staging and live as any changes to the database would affect both sites (especially when using software like Wordpress where there is configuration in the database). The only time that I would think of pointing to the live database would be if I was doing theme development and was not going to change the content in any way.

Your best bet is to set up a different site (and database) for staging and copy the database from live to it on a semi regular basis. This means you will need to update a number of URL's in the wp_options table (specifically 'site_url' and 'home' - there may be others depending on your setup). If it is not possible to create another database (for example you or your client couldn't afford to pay your provider for another one), you can change the $table_prefix variable in the wp-config file on staging.

When deploying to either staging or live (I assume you have a dev site set up elsewhere), take care not to overwrite wp-config.php file in the Wordpress root directory as this holds all the database connection details.


Who is your webhost?

We use rackspace and when you setup Wordpress initially they give you a temporary url to use, similar to the one you have above with the odd subdomain to it -- Rackspace generates a harder to guess url for you. You can use that to create and view your website before you make any changes to your DNS.

When Wordpress installs i think you are going to want to use the staging url only.

Once you are done building your website, you update your DNS settings on your domain name and then you update the general settings. I think you want to have everything matching.

  • The webhost is company that provides service for my client, a state agency. I set both 'home' and 'siteurl' for the staging site and noticed that all changes regarding the database are updated on the production site since they use the same database. It may be all good to go. You are right in saying I should only use the staging url. I also need to setup multisite, but after many failed attempts in getting that right, I may use an alternative method like using the same WP install for multiple sites.
    – diventato
    Oct 12, 2012 at 20:29
  • Let us know how it goes...I actually have not used the configuration like you are doing. It sounds pretty cool though. Glad its working.
    – Robbiegod
    Oct 12, 2012 at 21:17
  • Actually I wound up using a mixture in my wp-config to make it all come together: define('WP_HOME','http://www.website.com'); define('WP_SITEURL','http://www-stage.website.com');
    – diventato
    Oct 12, 2012 at 22:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.