Relocating a WordPress Installation
Well I’m working on something that I’m developnig locally, checking in to a subversion repository, and then deploying to another server (and other people will be doing the same when they collaborate with me). WordPress isn’t really designed for that, or for the situation where you have a copy of the database, and the code and need to restore it to a different place for any reason. The admin login form is accessible – but then submits to the old location before you can get in to change the settings.
Anyway it turns out to be really straight forward. The URL is in the database and a one-line query mends the problem. I’m putting it here for the next time I need it :)
update wp_options set option_value = 'http://new.path.to/blog" where option_name = 'siteurl';
I found some complicated instructions for moving a blog too – but this will also work for that scenario. This was wordpress 2.7 (their new and shiny version!), I’m not certain which other versions this would apply to but add a comment if you can expand on this please!
Useful to know!
I’ve used export/import XML before, when moving between hosting providers.
There’s some information on this sort of thing on the WordPress Codex at:
http://codex.wordpress.org/Changing_The_Site_URL
WordPress is generally very crap about moving a blog from one location to another, whether it be from a development site to a production site or from URL to another. The instruction for moving your site from one hostname to another are unbelievably complicated and come with scary warnings:
http://codex.wordpress.org/Changing_The_Site_URL#Domain_Name_Change
You can also define(‘WP_SITEURL’, ‘http://…’) in wp-config.php to set the site url dynamically. (This also marks it uneditable in the admin interface.
All I can say LornaJane, is that you are *ing brilliant!
I’ve moved older versions of WordPress, and it is remarkably easy. But I can’t quite remember how I did it. And I didn’t think to post the solution on my blog…
I’m working on a project at the moment with the same problem.
I think the easiest solution is just to omit the wp_config table when exporting your SQL locally.
Or just copy the SQL into an update file in your repository. Then you can just run the file and execute the query.
Simon: good tip!
Michael: Ah, you can set it in the config … that could be a much easier way of doing it, thanks :)
cereal_girl: I actually use this blog *instead* of a brain, things go here that I know will leak out through my ears and be lost forever if I don’t record them!
Gavin: The separate SQL could work – although now I know I can put this setting in a config, I might change it to use server-specific config in future. So many possibilities …
I’d used the Quick Fix method at http://codex.wordpress.org/Changing_The_Site_URL but the config option looks much more sensible. Especially for dev->staging->live setups where you may need to do this a lot.
Strange they don’t cover that in the docs.
*resists urge to say something rude about WordPress*