最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How do I create a WP sandbox for development on localhost (raspberry pi 4) without being redirected to the live site?

programmeradmin1浏览0评论

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?

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?

Share Improve this question asked Mar 11, 2020 at 3:30 TessaTessa 132 bronze badges 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 Commented Mar 11, 2020 at 10:11
Add a comment  | 

1 Answer 1

Reset to default 1

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

Assuming your live url is https://oldurl and your sandbox url is http://mysandboxurl (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' );
define( 'WP_SITEURL', 'http://mysandboxurl' );

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

Or using wp cli

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

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

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论