0

As I'm new to Linux and WPCLI, I moved a site from one VPS to another but URL stayed the same and PHPmyadmin doesn't work so as of the moment I can't change the site URL from PHPmyadmin.

When I try to navigate to the site from the browser (after setting up a database, changing wp-config.php accordingly, uploading site dir with right permissions etc) I get a 500 error.

I ten went did sudo tail /var/log/apache2/error.log and saw an error regarding that site, but with the old url (so somewhere the url wasn't changed and this seems to be the source of the problem). This is the error:

[Sun May 07 15:20:21.881125 2017] [:error] [pid 19110] [client IP_ADDRESS:56239] PHP Fatal error:

Unknown: Failed opening required '/var/www/html/contentperhour.com/wordfence-waf.php' (include_path='.:/usr/share/php') in Unknown on line 0

I thought it's Wordfence related so I tried to remove it:

sudo wp plugin deactivate wordfence
sudo wp plugin uninstall wordfence

Removing Wordfence and restarting the server didn't help.

How could I change the URL of the site from outside the site or outside PHPmyadmin?

2 Answers 2

0

The site and home URLs aren't serialized, if you access to the database export, you can change them directly in that file with a text editor.

You can also override the database values temporarily in wp-config.php with some defines:

define('WP_HOME','http://example.com');
define('WP_SITEURL','http://example.com');
5
  • Sorry if it wasn't clear: I can't access the DB file of my site from PHPmyadmin (and don't know a way to do so without PHPmyadmin) so I need to run some search and replace from within the Linux CLI.
    – user87795
    May 7, 2017 at 18:10
  • Then editing wp-config.php is probably the easiest. You can then update the values in the database with update_option, see Changing The Site URL for more info.
    – Milo
    May 7, 2017 at 19:10
  • Hi Milo, I thumbed up your answer. I tried to use the define method you presented but it seems not to be enough and I still need to change the domain somewhere else in the DB (can this be?)...
    – user87795
    May 7, 2017 at 19:49
  • what are the current symptoms? the error you have above isn't related to URL, it's the internal path to the file on the server.
    – Milo
    May 7, 2017 at 20:15
  • The site doesn't go up, it shows a 500 error on the browser, yet everything seems to be in place. The dir name in document root, the DB and DB user names, the wp-config file, everything.
    – user87795
    May 7, 2017 at 20:24
0

I would recommend the solution by Milo but if you want to do so from Bash, you could querying MySQL directly from it (note the comments):

mysql -u root -p # Start Bash querying mode and Proceed to DB of choice.
    use wordpress; # Delete "wordpress" and put your WP DB.
    show tables;
        update wp_options set option_value = 'http://correctDomain.name' where option_id = 1;
            select * from wp_options where option_value = 'http://www.correctDomain.name';
                \q # Quit querying mode.
  • The original article includes a Cname (www.) in the update and select queries but I removed it here.

  • Make sure to disable any "defines" you might have added to wp-config.php.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.