This bash script makes it easy to spin up a new WordPress site using Varying Vagrant Vagrants.
Place vvv in any folder included in your PATH environment variable. To add a folder to PATH:
-
Open
~/.bashrc(or~/.bash_profile) -
If
PATHis not defined anywhere in the file, add this line:export PATH=/path/to/folder:$PATHWhere
/path/to/folderis the path to the folder containing the script. -
Changes take effect in a new Terminal session.
-
To run the script from anywhere, open the file and uncomment the line at the top defining
path. Set that to the root folder of VVV on your machine.
Type vvv in the command line to use. When running the site setup or teardown wizards, you can include the desired name of your site's directory as a parameter. Example: vvv new testsite
This lists all the sites currently in VVV's www folder.
Creating a site does the following:
- Halts Vagrant (if running)
- Creates a web root for the site in the
wwwfolder containing two files:vvv-init.shandvvv-hostsvvv-init.shtells Vagrant to create a database if one does not exist and download or update WordPress from trunk the next time Vagrant is provisionedvvv-hostscontains the hosts entry to give your site a nice custom domain (the domain is set in the wizard)
- Creates a file in the
nginx-configfolder to handle server settings for your site - Restarts Vagrant with
vagrant up --provision
Provisioning Vagrant takes a couple of minutes, but this is a crucial step as it checks out WordPress trunk into your site's htdocs directory.
Adding the filesonly parameter to this command will do everything in the list above except restart Vagrant. This is useful for testing the script quickly (as provisioning Vagrant takes a while).
Deleting a site does the following:
- Halts Vagrant (if running)
- Deletes the site's web root (which deletes the
vvv-init.shandvvv-hostsfiles as well) - Deletes the file in the
nginx-configfolder pertaining to the site
Ping me on Twitter at @alisothegeek.