vagrant share
also accepts --name
as a parameter. Here is what you can do:
- Backup site’s database. For example this way:
vagrant up
vagrant ssh
cd /srv/www/{sitename}/current
wp db export db.sql
- Edit trellis/group_vars/development/wordpress_sites.yml, change
site_hosts:
value from{hostname}.dev
to{hostname}.vagrantshare.com
- Execute
vagrant reload --provision
to set up nginx - Execute
vagrant share --http 80 --name {hostname}
where default {sitename}
is example.com
and default {hostname}
is {example}
Keep in mind, that you cannot reach vagrant cloud by {hostname}.vagrantshare.com locally, you will always see your local instance, because of the record in hosts file. It shouldn’t be a problem in most cases.
If you lose your database during the process, like me, you can restore it by executing
vagrant ssh
cd /srv/www/{sitename}/current
wp db import db.sql
Finally you may wish to get rid of remains of old site: old database, /etc/nginx/sites-available/{hostame}.dev, /srv/www/{hostame}.dev. In that case it’s probably better to use vagrant destroy && vagrant up
instead of vagrant reload --provision
at the 3rd step (db backup is absolutely must in that case).