1

I bought a WordPress website through Flippa and I need to set up a development area that will let me test changes and updates before I put them on the live site. I am brand new to this so I want to make sure I don't break the existing site. I have set up a raspberry pi 4 with a LAMP setup. The Linux is Buster with Apache2, MariaDB, and PHP 7.3.

I finally figured out how to attach the database to a new WordPress install using PHPMyAdmin to import the existing database into a blank one. I merged the existing source code with the WordPress install in the /var/www/html folder using the following command. (5469-6696 is the name of the flash drive)

sudo cp -RT /media/pi/5469-6696 /var/www/html

I deleted the wp-config.php file and started the WP installation. I attached the database to the setup of WordPress and it tells me "You appear to have already installed WordPress. To reinstall please clear your old database tables first."

If I delete the database tables I don't have anything to test with but if I click the login button it takes me to the live site and reentering the IP address of the Pi does the same thing. I want to use the Pi as a local testing server. How do I stop the install from connecting to the live site?

1
  • 1
    The live site URL is in the database, in the first two rows of the wp_options table. You need to change it so your sandbox knows its own URL instead. Either edit this in the database snapshot the sandbox is using or e.g. override the URL in the database in the sandbox's wp-config so you can use unedited database snapshots from live.
    – Rup
    Mar 11, 2020 at 10:11

1 Answer 1

1

You need to change the url of the copied website to not have a redirection

Assuming your live url is https://oldurl.com and your sandbox url is http://mysandboxurl.com (replace the values with your actual urls)

You can do so with either a define in your wp-config.php

define( 'WP_HOME', 'http://mysandboxurl.com' );
define( 'WP_SITEURL', 'http://mysandboxurl.com' );

Or changing the option_value of siteurl and home to http://mysandboxurl.com in your wp_options table

Or using wp cli

wp search-replace https://oldurl.com http://mysandboxurl.com --all-tables

To replace all links in your content as well to avoid being redirected via your menu to the live website

4
  • Thank you so much for this direction. I installed wp and used the given command in the terminal. Now it is going to the IP of the PI but it says that the connection is refused. Is this because I changed too many things in the database? I did a restart of apache but didn't do anything in PHPMyAdmin.
    – Tessa
    Mar 11, 2020 at 19:23
  • Do you have an eye on the error logs of apache and php? That will point you in the right direction Else you may have typed the wrong ip when replacing
    – Toffee
    Mar 11, 2020 at 22:30
  • I have two error logs for apache. Based on google searches the error.log is showing basic operations of restarts that are normal. I had a message in 'error.log.1` giving the error AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message.
    – Tessa
    Mar 12, 2020 at 16:14
  • In the terminal, I did sudo nano /etc/apache2/apache2.conf and added ServerName localhost as the last line in the file, saved, then did sudo systemctl restart apache2. The site still didn't run so I did sudo service apache2 restart (just in case they're not quite the same) but that didn't get it to work either. No new lines have been added to the error log after these changes.
    – Tessa
    Mar 12, 2020 at 16:15

Your Answer

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

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