Skip to content

Instantly share code, notes, and snippets.

@joshlevinson
Last active December 30, 2016 13:54
Show Gist options
  • Save joshlevinson/d90ffab3ea61393e91c2 to your computer and use it in GitHub Desktop.
Save joshlevinson/d90ffab3ea61393e91c2 to your computer and use it in GitHub Desktop.
Create new VVV sites with WP CLI + wildcard hosts
# create at /etc/dnsmasq.d/dev in the vagrant guest
address=/dev/127.0.0.1
# create in your vagrant directory @ config/nginx/sites/wildcard.conf
# this dir is copied during provision, if you don't want to re-provision, run this in a vagrant shell:
# sudo rsync -rvzh --delete /srv/config/nginx-config/sites/ /etc/nginx/custom-sites/
server {
listen 80;
listen 443 ssl;
server_name ~^(?<name>.*)\.dev;
root /srv/www/$name/htdocs;
include /etc/nginx/nginx-wp-common.conf;
}
vagrant ssh
cd /srv/www/
mkdir site-name && cd site-name && mkdir htdocs && cd htdocs
wp core download
wp core config --dbname=site-name --dbuser=root --dbpass=root
wp db create
wp core install --url=site-name.dev --title=Site --admin_user=admin --admin_pass=password --admin_email=admin@example.dev
@joshlevinson
Copy link
Author

joshlevinson commented Nov 2, 2015

Wildcard DNS on your local machine (host) is a nice thing to add to this.
You can follow this guide.
Step 2 is different though: we want Dnsmasq to forward traffic to VVV, not the host.
Accomplish this by switching out address=/dev/127.0.0.1 with the address of the VVV machine (usually 192.168.50.4, so address=/dev/192.168.50.4) in the /usr/local/etc/dnsmasq.conf file.

@allenmoore
Copy link

@joshlevinson This is great! I made a couple of changes, which can be seen here -- https://gist.github.com/allenmoore/a7a231a385537285c180899b44d5e16e.

The most important would be replacing --admin_pass=password with --admin_password=password on line 7 of wp-cli-commands.sh.

You'll also notice some additional commands on line 3 of the same file that creates both vvv-hosts and wp-cli.yml files, with the correct content added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment