0

I set up a basic Wordpress installation (on a Raspberry Pi running Raspbian Stretch - Debian 9) using NGINX.

Recently I changed the hostname of my system (as part of a plan to ensure consistent naming across my systems) and everything seemed to be working successfully.

I wanted to move my Wordpress installation to a new system but found it was no longer working.

The basic home page came up, but the links to logos etc did not work. It soon became obvious, as the links were attempting to access oldhostname.local and this is somewhere encoded in the Wordpress database.

I restored the oldhostname and Wordpress is now working again.

Looking in Settings/General Settings the oldhostname is in Wordpress Address (URL) and Site Address (URL)

I could change this to my new hostname, but ideally would like to make this independent of hostname. (One aspect of the Raspberry Pi is that it is simple to clone SD Cards and I copy my installation to others with just a hostname change).

My question is can I make the Wordpress installation independent of hostname, and if so how?

0

As far as I remember it is not possible to decouple the domain name from the WP instance, but you can change it.

In the database you can find where the domain is stored by exporting the database with a mysql_dump and then search within the text file.

Another method which entails running MySQL commands is explained on this blog post..

Modifying the SQL database would be the preferred method. As editing the text you might be editing the wrong fields.

The commands from the blog:

UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldurl', 'http://www.newurl') WHERE option_name = 'home' OR option_name = 'siteurl';

UPDATE wp_posts SET guid = replace(guid, 'http://www.oldurl','http://www.newurl');

UPDATE wp_posts SET post_content = replace(post_content, 'http://www.oldurl', 'http://www.newurl');

UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.oldurl','http://www.newurl');

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.