Installing Vagrant and VVV (and moving from an old instance to new)
Step 1
Install VirtualBox.
Step 2
Install VVV via git clone into your chosen dir (Here I’m using my-project-dir
as a generic name).
git clone https://github.com/Varying-Vagrant-Vagrants/VVV.git my-project-dir
Step 3
Install vagrant-hostsupdater
plugin:
vagrant plugin install vagrant-hostsupdater
Step 4
Install vagrant-triggers
plugin:
vagrant plugin install vagrant-triggers
Importing existing databases
(Hopefully you had vagrant-triggers
installed in your last VVV instance, which backed up your sql
databases to the /database/backups/
directory.) If not, the following won’t apply.
Step 1
In the /database
directory of your new instance:
Make a copy of init-custom.sql.sample
and rename it to init-custom.sql
. In init-custom.sql
add the following commands (change DATABASE_NAME
to your database name):
CREATE DATABASE IF NOT EXISTS `DATABASE_NAME`;
GRANT ALL PRIVILEGES ON `DATABASE_NAME`.* TO 'wp'@'localhost' IDENTIFIED BY 'wp';
Step 2
In the /database
directory of your new instance, create a /backups
directory:
cd /database
mkdir backups
Step 3
Meanwhile, in the database/backups/
directory of your old VVV instance, copy SITENAME.sql
of whichever databases you want to import into the database/backups/
directory of your new instance.
Search and replace in SQL database
To replace values in db, e.g. siteurl, pull db down from phpMyAdmin (via export), or make a copy from database/backups/SITENAME.sql
, make changes, then import via phpMyAdmin.
Configuring hosts
#1) vvv-hosts
Step 1
In the www
directory of your new VVV instance, create SITENAME/
directory:
cd www
mkdir SITENAME
Step 2
Next, cd
into the SITENAME
directory and create a vvv-hosts
file:
touch vvv-hosts
Step 3
Open the vvv-hosts
file and add SITENAME.dev
. Save and close.
#2) nginx-config/sites
Follow the instructions here under Nginx Configuration to create SITENAME.conf
in the config/nginx-config/sites/
directory.
Start the engine
vagrant provision
Otherwise, if your VM is already running, use reload:
vagrant reload --provision
This will import the sql
database from the database/backups
directory and load it into the VM, among other things. A full VM provision usually takes a few minutes. Go make a cup of coffee.
Next steps
For wordpress development, we will still need to ensure that our www/SITENAME/
directory includes an htdocs
directory with a standard wordpress install and all our themes and plugins in their associated directories within the wp-content
directory.