Laravel + Homestead + Vagrant not working - php

I am new to homestead and vagrant, i installed homestead as in laravel documentation but getting timeout error when visit address : 192,168.10.10.
Before this error i was getting error request time out on ip so i uncomment this line :
config.vm.network "private_network", ip: "192.168.10.10"
Then network start working ping.
Also i uncommented this line :
config.vm.network "forwarded_port", guest: 80, host: 8080
So it's started showing me port forward.
Then i made this line uncommented :
config.vm.network "public_network"
But still getting error, don't now what is the error. I checked nginx folder by log in to ssh : vagrant ssh then cd /etc/nginx/sites-enabled
I saw there is no configuration file maybe because vagrant not loading Homestead.yaml file.
Here is my yaml file
---
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: ~/Websites
to: /vagrant/Code
sites:
- map: laravel.dev
to: /home/vagrant/Code/admin/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

After add homestead box your first work is to clone repository :
git clone https://github.com/laravel/homestead.git Homestead
And clone this to in folder where from you want to run your code or websites example :
if ~/Websites then:
cd ~/Websites
Then clone command, after clone cd Homestead run bash init.sh in Terminal it will make a folder in your root directory called .homestead where your Homestead.yaml file will. Edit Homestead file like this:
---
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: ~/Websites
to: /home/vagrant/Websites
sites:
- map: laravel.dev
to: /home/vagrant/Websites/admin/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
After edit add your ssh key using this command in terminal :
ssh-keygen -t rsa -C "you#homestead"
Keygen should create files in .ssh folder in document root but if not then create folder .ssh then paste it from document root to ssh folder so you no need to edit Homestead.yaml file
When this done change directory to : cd ~/Websites/Homestead
Now run this :
vagrant up
If any edit in yaml file or Vagrantfile then run this :
vagrant reload --provisions
Maybe that should fix your issue otherwise something wrong with your PC :D
Don't forget to add this in /etc/hosts file :
192.168.10.10 laravel.dev
If none of this helps you many want to check the Laravel documentation:
Laravel Documents

Related

Mapping Folders and Sites in Laravel/Homestead

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

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