Mapping Folders and Sites in Laravel/Homestead - php

I have slowly been working on getting Laravel/Homestead up on ubuntu 15.1 and am struggling to get my folders and sites mapped in my Homestead.yaml file. The virtual machine is up and running, when I go to Homestead.app in the browser it tells me that no input file specified. I know that I don't have it mapped correctly.
---
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: ~/Homestead/Projects/Laravel
to: /home/vagrant/Projects
sites:
- map: homestead.app
to: /home/goldenos/Homestead/Projects/public
databases:
- homestead
# blackfire:
# - id: foo
# token: bar
# client-id: foo
# client-token: bar
# ports:
# - send: 50000
# to: 5000
# - send: 7777
# to: 777
# protocol: udp
I have my index.php file in ~/Homestead/Projects in a folder named Laravel if I need to provide any additional information please let me know and I will provide it asap. Thanks in advance for any information!
-Luke

Try THIS instead:
folders:
- map: ~/Homestead/Projects // your local whole projects folder on the host machine (so you can setup multiple websites on the same virtual box)
to: /home/vagrant/Projects // synced folder in virtual box
sites:
- map: homestead.app
to: /home/vagrant/Projects/Laravel/public // path of project in the virtual box
- map: site2.app
to: /home/vagrant/Projects/Site2/public
Don't forget to run vagrant up/reload flagging --provision after you edited your .yaml file like:
vagrant up --provision
OR
vagrant reload --provision

Related

Homestead link doesnt work

Trying to setup Homestead for laravel development. Did every step in laravel docs about homestead, but i cant get my project link running.
I added this line to hosts file
192.168.10.10 shop.dev
this is how my Homestead.yml file looks like:
---
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
authorize: c:/users/lukas/.ssh/id_rsa.pub
keys:
- c:/users/lukas/.ssh/id_rsa
folders:
- map: e:/Projektai/Homestead
to: /home/vagrant/Code
sites:
- map: shop.dev
to: /home/vagrant/Code/Parduotuve/public
databases:
- homestead
# blackfire:
# - id: foo
# token: bar
# client-id: foo
# client-token: bar
# ports:
# - send: 50000
# to: 5000
# - send: 7777
# to: 777
# protocol: udp
At first i had some problems running VM but I managed to get it working. However now this is not working at all.

Laravel Homestead 403 Error

I am getting an error on Laravel Homstead which stated the 403 forbidden error, I cannot seem to see what is wrong in the .yaml file. I am using OSX if that helps. Below is my .yaml file for assistance.
---
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: /Users/jordanbarber/vagrant/laravel/projects/mysite/html/vAMSYS
to: /home/vagrant/Code
sites:
- map: homestead.app
to: /home/vagrant/base/public
databases:
- homestead
variables:
- key: APP_ENV
value: local
# blackfire:
# - id: foo
# token: bar
# client-id: foo
# client-token: bar
# ports:
# - send: 93000
# to: 9300
# - send: 7777
# to: 777
# protocol: udp
Continue from " so, what would that directory be? " If you're using windows, go to you root folder and type "cmd" in the path at the top, after that run
vagrant reload
Your folder might be wrong.
Open a terminal window in your project directory and enter
pwd
This prints the working directory, change the working directory in your yaml file.
Hope it helps.
You need to also edit your /etc/hosts file to include:
192.168.10.10 homestead.app
Then run
vagrant reload --provision

Laravel homestead links to same directory

I'm setting up homestead. But when I want to add another website to homestead it points to the same directory?
This is my Homestead.yaml file:
---
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: ~/documents/vagrant/sites
to: /home/vagrant/Code
sites:
- map: test.app
to: /home/vagrant/Code/test
- map: testt.app
to: /home/vagrant/Code/secondtest
databases:
- homestead
# blackfire:
# - id: foo
# token: bar
# client-id: foo
# client-token: bar
# ports:
# - send: 50000
# to: 5000
# - send: 7777
# to: 777
# protocol: udp
When I go to testt.app it points to the same directory as test.app. This is how my etc/hosts file looks like:
My homestead directory:
Every time I make changes in my homestead.yaml file I do: "vagrant provision". When I ssh into my homestead server I can go to the directory secondtest so it exists.
In your etc/hosts you should point both domains to 192.168.10.10 IP and not 127.0.0.1
Have you actually run the provision command?
homestead provision

Laravel homestead accessing site in browser

I am having trouble accessing a site hosted on a laravel homestead virtual machine, using the hostname homestead.app:8000.
http://homestead.app:8000 returns a "This webpage is not available" message in chrome.
127.0.0.1:8000 returns the 'Laravel 5' landing page, which I was expecting from the above.
I have added the following to the /etc/hosts file on my local machine (and tried a few variations of this).
127.0.0.1 homestead.app:8000
Any obvious reasons why this wouldn't work? Steps that may have been missed?
This is the content of the Homestead.yaml file
---
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
authorize: ~/.ssh/homestead.pub
keys:
- ~/.ssh/homestead
folders:
- map: ~/Apps/test
to: /home/vagrant/Code
sites:
- map: homestead.app
to: /home/vagrant/Code/Laravel/public
databases:
- test
variables:
- key: APP_ENV
value: locals
# blackfire:
# - id: foo
# token: bar
# client-id: foo
# client-token: bar
# ports:
# - send: 93000
# to: 9300
# - send: 7777
# to: 777
# protocol: udp
Change /etc/hosts on your local machine to this
192.168.10.10 homestead.app
Save and in the browser of your choice on your local machine navigate to
http://homestead.app

Laravel Homestead using both Windows and Mac

Following Laravel's 5.1 documentation about using Homestead on a per-project basis, I ran the commands to create a Homestead Vagrantfile inside of my Git repository for my project, I did this on my Macbook. Here is the Homestead.yaml for that:
---
ip: "192.168.10.10"
memory: 2048
cpus: 1
hostname: projectname
name: projectname
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: "/Users/user/Sites/personal/projectname"
to: "/home/vagrant/projectname"
sites:
- map: homestead.app
to: "/home/vagrant/projectname/public"
databases:
- projectname
variables:
- key: APP_ENV
value: local
# blackfire:
# - id: foo
# token: bar
# client-id: foo
# client-token: bar
# ports:
# - send: 93000
# to: 9300
# - send: 7777
# to: 777
# protocol: udp
Problem is, after pushing this to Git and pulling down on my PC, the path in the Homestead.yaml file is now completely wrong so that it won't work...
How can I abstract the path from Homestead.yaml to an environment variable so that I can share a vagrant VM across operating systems?
Managed to solve it!
If I set the folder to "." it will use the current directory which works for both Mac and Windows!
...
folders:
- map: "."
to: "/home/vagrant/projectname"
...
Meaning now I have a Homestead vagrant machine in Git that I can use on both Mac and Windows :D

Categories