Automatic mapping domains to folders in Homestead - vagrant

Homestead configuration file, Homestead.yaml, offers way to map domains to folders, like this:
sites:
- map: project.dev
to: /home/vagrant/www/project.dev/public
- map: some-other.dev
to: /home/vagrant/www/some-other.dev/public
# etc.
Is there any way to automate this process and map all .dev domains to the folders, like this?
/home/vagrant/www/{domain}/public

Old thread but you can do this
sites:
- map: '~^(?<project>.+)\.dev$'
to: /home/vagrant/Development/\$project/public

Related

Laravel 5 Homestead Multiple Sites on Local Network

I have two Laravel projects on a Homestead machine.
Homestead.yaml
sites:
- map: homestead.app
to: /home/vagrant/Code/Laravel/public
- map: blog.app
to: /home/vagrant/Code/Blog/public
and /etc/hosts:
192.168.10.10 homestead.app
192.168.10.10 blog.app
And everything works as expected. But when I want to access sites from a phone on a local network and go to
192.168.1.100:8000
It takes me to a Blog project. Is there a way for all projects to be accessible at all times?
I read this How to connect to Homestead which has multiple sites through mobile device?, but you have to pick one project to be accessible. And you have to edit Homestead.yaml and reload vagrant every time you want to swap projects.
I have just figured this out myself, and I have posted answers here (Homestead cant access second site remotely) and here (Laravel homestead multiple sites choose which one is locally accesable).
In short:
sites:
- map: homestead.app
to: /home/vagrant/Code/Laravel/public
port: 81
- map: blog.app
to: /home/vagrant/Code/Blog/public
ports:
- send: 8100
to: 81
Then access your homestead.app project via http://192.168.1.100:8100.

Homestead Installation: Shared folder map changes not working

I'm trying to install Homestead on a Mac using VirtualBox and when I edit the homstead.yaml file to change the location of my local shared folder the change never registers, as I always get the error
The host path of the shared folder is missing: ~/Code
when I vagrant up.
When I performed bash init.sh I was asked to overwrite homestead.yaml, after.sh, and aliases. I've been having this problem for a while now and have tried many different things but nothing seems to work. I new with Laravel and would appreciate some help. Thanks!
In your Homested.yaml file but make sure you have folder in your C:\Code
folders:
- map: C:/Code
to: /home/vagrant/Code
sites:
- map: homestead.app
to: /home/vagrant/Code/Laravel/public

PhpMyAdmin on Laravel 5 Homestead, Windows

I downloaded phpmyadmin to my /Code folder, and then updated my Homestead.yaml file:
folders:
- map: C:\Users\{ myname }\Code
to: /home/vagrant/Code
- map: C:\Users\{ myname }\Code\phpmyadmin
to: /home/vagrant/Code/phpmyadmin
sites:
- map: homestead.app
to: /home/vagrant/Code/Laravel/public
- map: phpmyadmin.app
to: /home/vagrant/Code/phpmyadmin
I updated my hosts file also...
{ ip from homestead.yaml} phpmyadmin.app
When I browse to phpmyadmin.app it displays the same site as homestead.app.
I'm using Windows.
Is there some way to restart homestead? How do I get this to work?
You'll need to reprovision your homestead vm with
vagrant provision
See Adding Additional Sites

The host path of the shared folder is missing: path/to/file Mac OS X Yosemite

I keep getting this error while runing : vagrant up :
Homestead.yaml
folders:
- map: ~/Applications/MAMP/htdocs
to: /home/vagrant/code
sites:
- map: homestead.app
to: /home/vagrant/code/aveniros/Laravel/public
Can someone please point out what I did wrong here ?
I fix this disaster by by deleting the (~)
Homestead.yaml
folders:
- map: /Applications/MAMP/htdocs/code
to: /home/vagrant/code
sites:
- map: homestead.app
to: /home/vagrant/code/aveniros/Laravel/public
It should work now.
Then, if you open up your Virtual Box Application, you should see something like this :
Hope this answer help ! :D

Multiple folders for homestead not syncing

My first homestead project worked without a hitch here's the core part of the homstead.yaml
folders:
- map: C:\dev\bitbucket
to: /home/vagrant/bb
sites:
- map: project.dev
to: /home/vagrant/bb/example/project/public
now I wanted to add a different folder into the mix so I extended the yaml to
folders:
- map: C:\dev\bitbucket
to: /home/vagrant/bb
- map: C:\dev\github
to: /home/vagrant/gh
sites:
- map: project.dev
to: /home/vagrant/bb/example/project/public
- map: another.dev
to: /home/vagrant/gh/example/another/public
I run homestead provision and now I can access another.dev but I got the error No input file specified. So I ran the command homestead ssh and cd /home/vagrant followed by ls and all I see is the bb folder and not the gh
I found multiple places that mention multiple sites syntax, but couldn't find something mentioning multiple folders (although as the name suggests folders is plural, so I thought this should be possible)
What am I missing?
sometimes homestead doesn't provision correctly and needs a full reboot. while this isn't ideal, one workaround is to use homestead halt followed by homestead up to recreate the provisioning process for the VM.
a bit of my homestead file
u are not allowed to change this directory /home/vagrant/Projects to something else
folders:
- map: ~/Projects
to: /home/vagrant/Projects
sites:
- map: aone.dev
to: /home/vagrant/Projects/aone/public
- map: booking.dev
to: /home/vagrant/Projects/booking/public
- map: nish.dev
to: /home/vagrant/Projects/nish/public
- map: shazdekocholo.dev
to: /home/vagrant/Projects/shazdekocholo/public
- map: hejab.dev
to: /home/vagrant/Projects/hejab/public

Resources