- A WordPress multisite database loaded on your Vagrant box, accessible at
vagrant.dev
with the IP address 192.168.33.10 (See yourVagrantfile
and/etc/hosts
) - WordPress already installed and configured on your Vagrant box
- WP-CLI installed on your Vagrant box
- The main site of your network is
network.org
and the project site isproject.org
- If you do not possess admin credentials for the network, we will create a new admin, whose username is
admin
and whose password ispassword
. - If you want to be able to undo this, run
vagrant plugin install vagrant-vbox-snapshot
from the Vagrant host. To take a snapshot, runvagrant snapshot take default [optional-name-for-snapshot]
. Take one before starting, and then at the start of every major section here.
Grab Version 2.x of https://interconnectit.com/products/search-and-replace-for-wordpress-databases/ and unzip it into the root of your Vagrant site. That's either into /vagrant
or into the folder containing the wordpress install. Either way, it should be in the same folder as wp-config.php
.
Visit http://vagrant.dev/searchreplacedb2.php in your browser.
- Check "Pre-populate the DB values"
- Click "Submit"
- Check that the values look right. If you're using our Vagrantfile from deploy-tools, it will be localhost, largoproject, root, root, utf8.
- There is a multi-select of database tables. Most will be prefixed with
wp_#_
, as opposed towp_
. Ctrl-click or shift-click to choose the non-number-prefixed tables. - Check 'Leave GUID column unchaged'
- Search for
network.org
and replace withvagrant.dev
- Submit search string.
Open wp-config.php
and add the follwing lines:
define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', true);
define('DOMAIN_CURRENT_SITE', 'vagrant.dev');
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);
This is only necessary if you do not possess the credentials for a network super-admin.
vagrant ssh
cd /vagrant
wp user create admin [email protected] --role=administrator --user_pass=password
wp super-admin add admin
You should now be able to log into http://vagrant.dev/wp-login.php as admin
with password
.
You only need to do this if your admin user does not have access to project.org
.
Log into your multisite install at http://vagrant.dev/wp-login.php.
- In the header, choose My Sites > Network Admin > Sites (http://vagrant.dev/wp-admin/network/sites.php)
- Find the
project.org
site. Click on its "Edit" button. - Find the site's URL near the top of the page: "Edit Site: project.org" or "Edit Site: project.vagrant.dev"
- Edit your host computer's
/etc/hosts
file by adding the line192.168.33.10 project.vagrant.dev
to the end of the file. - Check that http://project.vagrant.dev points to the correct site.
- Click the "Users" tab.
- Under "Add Existing User", enter
admin
as the username and choose the "Administrator" role.
- Go to http://vagrant.dev/wp-admin/network/sites.php
- Find the
project.org
site. Click on its "Edit" button. - Find the site's URL near the top of the page: "Edit Site: project.org" or "Edit Site: project.vagrant.dev"
- Find the ID number in the browser's current URL: http://vagrant.dev/wp-admin/network/site-info.php?id=53
- Copy down the blog ID number. We'll use it in the next step.
This process will be familiar, with one key difference.
Visit http://vagrant.dev/searchreplacedb2.php in your browser.
- Check "Pre-populate the DB values"
- Click "Submit"
- Check that the values look right. If you're using our Vagrantfile from deploy-tools, it will be localhost, largoproject, root, root, utf8.
- There is a multi-select of database tables. Ctrl-click or shift-click to choose the tables prefixed with wp_53_, where 53 is the site id.
- Check 'Leave GUID column unchaged'
- Search for
project.org
and replace withproject.vagrant.dev
- Submit search string.
- Wait. The page will load for a loooong time.
- If you get to a page with a success message, congratulations!
"In the process of replacing "project.org" with "project.vagrant.dev" we scanned 33 tables with a total of 610470 rows, 71588 cells were changed and 71560 db update performed and it all took 958.267747 seconds." - If the next page is mostly or entirely blank after the header, then you will need to use a different tool to perform the replace.
You should now be able to log in as admin
with password
at http://project.vagrant.dev/wp-login.php