Configured site for Homestead not working - laravel

Here is Homestead.yaml config :
ip: 192.168.9.10
memory: 2048
cpus: 2
provider: vmware_desktop
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
-
map: 'C:\Users\Khalil\RestfulAPI'
to: /home/vagrant/restfulapi
sites:
-
map: restfulapi.dev
to: /home/vagrant/restfulapi/public
php: "8.0"
databases:
- homestead
features:
-
mariadb: false
-
ohmyzsh: false
-
webdriver: false
name: restfulapi
hostname: restfulapi
I also added it to the hosts file : 192.168.9.10 restfulapi.dev
It works when i use http://restfulapi.local without mapping it directly as a site since i guess *.local is the default?
Running restfulapi.dev takes forever to load then gives a "connection time out", pinging the IP from my host responds with TTL expired in transit 4 times and ends with a
Ping statistics for 192.168.9.10:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
I can normally run vagrant ssh and ping 192.168.9.10 and get response, and it's also configured as eth1 on the machine when i run ip address show.
Tried provisioning, destroying the VM, setting up everything from scratch.

I attach my Homestead.yaml file for a test project that I am developing using Laravel Framework and PHPStorm.
[Homestead.yaml]
[1]: https://i.stack.imgur.com/VqkHh.png
After making changes to your Homestead.yaml file, execute
vagrant reload --provision
Once the virtual machine has finished booting, ssh into the VM through this command: vagrant ssh

Delete the version of php from your Homestead.yaml and run vagrant up and vagrant provision.

Related

Homestead mapping folders and sites on ubuntu machine

I'm used to working in a windows environment and have homestead up and running on my windows machine.
I'm now trying to set up homestead on a machine running ubuntu, partly as a development opportunity for me and to overcome some perceived issues in windows that I've experienced with setting up development workflow. anyway....
I've successfully installed homestead and after vagrant upand changing my hosts file I can get the vagrant machine up and running. I can ping the url for my development site. However when I try and view the site in the browser - i get a timeout.
I can SSH into the vagrant machine but navigating to home/vagrantthere is no code folder - so it doesn't appear to be creating that folder on set up.
I added that folder from within the machine as sudo and gave write permissions - On examining the start up script I can see this message:
homestead: /home/vagrant/code => /media/ray/Develop/vagrant/projects
==> homestead: Detected mount owner ID within mount options. (uid: 1000 guestpath: /home/vagrant/code)
==> homestead: Detected mount group ID within mount options. (gid: 1000 guestpath: /home/vagrant/code)
Q1: Is there an error log within homestead I can view to try and work out what the issues are?
Q2: For now I'm assuming it may be a mapping issue in my homestead.yaml file - although in the past on windows this has manifested itself as ǹo input file detected`error.
My code is on a separate partition to the ubuntu machine (on my dual boot laptop). I can navigate to the files which are located in the media folder with this path:
/media/ray/Develop/vagrant/projects
Here is my current homestead.yamlfile:
---
ip: "192.168.56.56"
memory: 2048
cpus: 2
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: /media/ray/Develop/vagrant/projects
to: /home/vagrant/code
sites:
- map: wedleague.loc
to: /home/vagrant/code/wedleague/public
php: "8.1"
databases:
- homestead
- wedleague
- sandpit
features:
- mysql: true
- mariadb: false
- postgresql: false
- ohmyzsh: false
- webdriver: true
services:
- enabled:
- "mysql"
# - disabled:
# - "postgresql#11-main"
ports:
- send: 33060 # MySQL/MariaDB
to: 3306
Have I mapped this correctly? - I'm still getting used to ubuntu file system (mounted/symlink etc) over windows so wonder if I've made an error here.
Thank you

Homestead ERR_SOCKET_NOT_CONNECTED After Mac OS Update

I recently updated to Big Sur on my Mac and haven't been able to access any of my VMs as web pages since. I've destroyed and rebuilt this VM using Homestead's expected installation process.
VirtualBox 6.1.28
Latest Homestead version from release branch
Vagrant 2.2.18
This is the error I'm seeing
After long hours spent researching this loads of people seem to resolve it by adding the site to their hosts file. To confirm I have added this to hosts:
Error when viewing the URL without site in hosts
Update: I'm able to view the VM if I go to http://localhost:8000/. Going to http://192.168.10.10 doesn't work.
From the vagrant box using curl 192.168.10.10 produces the expected HTML output of that page. So does curl localhost:8000 from my machine. If I try curl 192.168.10.10 from my machine I get curl: (55) getpeername() failed with errno 22: Invalid argument.
I've tried every other network configuration within Virtualbox and using NAT is the only one that allows the SSH connection. It seems requests aren't making it to the VirtualBox.. probably because there's an error stating the socket isn't connected.
Socket stats seems to show it's listening on port 80
As of now I have destroyed and rebuilt the box again, so it is as close to an expected installation that anyone should have.
p.s. "site.test" is a placeholder for the actual name.
Here is my Homestead.yaml: https://pastebin.com/qhPdWCNv
---
ip: "192.168.10.10"
memory: 2048
cpus: 2
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: ~/Sites
to: /home/vagrant/code/
sites:
- map: site.test
to: /home/vagrant/code/site/public
php: "7.4"
databases:
- homestead
features:
- mysql: true
- mariadb: false
- postgresql: false
- ohmyzsh: false
- webdriver: false
services:
- enabled:
- "mysql"
# - disabled:
# - "postgresql#11-main"
#ports:
# - send: 33060 # MySQL/MariaDB
# to: 3306
# - send: 4040
# to: 4040
# - send: 54320 # PostgreSQL
# to: 5432
# - send: 8025 # Mailhog
# to: 8025
# - send: 9600
# to: 9600
# - send: 27017
# to: 27017
Here is my hosts file: https://pastebin.com/Y6Re15iy
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
192.168.10.10 site.test
::1 localhost
Vagrant 6.1.28 seems to restrict the valid IP address of a guest.
Took me hours to figure this out, read then manual.
Solved by changing my Homestead.yaml ip to 192.168.56.0 and also altered the ip in /etc/hosts
From the manual:
On Linux, Mac OS X and Solaris Oracle VM VirtualBox will only allow IP addresses in 192.68.56.0/21 range to be assigned to host-only adapters.
For anyone that encounters this issue I fixed this by updating the VM to a new IP, changing the domain, and clearing the dns cache (dscacheutil –flushcache).

Homestead cant access second site remotely

I have one site setup fine, but the second can't be accessed remotely:
My YAML:
---
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: ~/Projects
to: /home/vagrant/Projects
sites:
- map: app.app
to: /home/vagrant/sites/app1/public
- map: app2.app
to: /home/vagrant/sites/app2/public
port: 8100
ports:
- host: 81
- guest: 8100
I can access the first site using my IP easily - http://192.168.0.5/ but the second one cannot share the same port, so I've added 81 -> 8100.
When I try to reprovision my homestead vagrant box it says:
There are errors in the configuration of this machine. Please fix
the following errors and try again:
vm:
* Forwarded port definitions require a "host" and "guest" value
* Ports to forward must be 1 to 65535
* Ports to forward must be 1 to 65535
Any ideas?
The service xip.io can make short work of this. Here's how:
As an example, I have the following Homesite app setup, 'rentmanager.test'. This is the first application I provisioned on Homestead, so it's the default route. To access this from my local network, all I have to do is go to:
http://rentmanager.test.192.168.5.124.xip.io:8000
Where 'rentmanager.test.' is the name of my Laravel application on Homestead, '192.166.5.124.' is my IP address on the local network, 'xip.io:8000' is the redirect service domain and the needed port to access the app (8000) outside of the default routing that Homestead sets up.
Now, this works fine out of the box with the first site you provision, but what happens if we have more than one site? That requires a little more legwork. Let's assume we've got a second app called 'sitescanner.test' that we want to access. If I try to access the same URL above with the new app URL, you'll see I'm still served the first application! Let's resolve that as well.
First, you're going to need to add an additional rule to your hosts file. So, assuming our new app is called 'sitescanner.test':
# Vagrant Sites External Access
192.168.10.10 sitescanner.test.192.168.5.124.xip.io
Once that's in place then we have to update the provisioning scripts in Homestead to create the correct virtual host entries so Homestead knows how to route the request. To do that, we'll edit your Homestead.yaml. Under the 'sites:' directive:
- map: sitescanner.test
to: /home/vagrant/Code/sitescanner/public
- map: sitescanner.test.192.168.5.124.xip.io
to: /home/vagrant/Code/sitescanner/public
Once this is complete, simply 'vagrant halt' (if it's already running), then 'vagrant up --provision' and you should be able to access your site from
http://sitescanner.test.192.168.5.124.xip.io:8000
Anywhere on your network! Hope this helps.
While I'm thinking about it, there is a final consideration for this configuration:
You may want to set a static IP address on your host machine if possible. If you're being assigned a dynamic IP address via DHCP it's possible (and likely) for this configuration to eventually break if you're ever assigned a new IP.
According to the documentation found at https://laravel.com/docs/5.4/homestead
you don't need to specify ports when adding multiple sites
sites:
- map: homestead.app
to: /home/vagrant/Code/Laravel/public
- map: another.app
to: /home/vagrant/Code/another/public
then add the following to your hosts file
192.168.10.10 homestead.app
192.168.10.10 another.app
make sure to run vagrant reload --provision
I do not know which version of Laravel or Homestead you are using, but this is possible. With the Homestead versions documented for Laravel 5.6 or 5.7, you were 95% of the way to having this complete.
Instead of using port: 8100 in your sites configuration, you should have used port: 81.
Instead of guest and host, use send and to.
I used the exact same setup as you except for those two differences, and it works for me.
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: ~/Projects
to: /home/vagrant/Projects
sites:
- map: app.app
to: /home/vagrant/sites/app1/public
- map: app2.app
to: /home/vagrant/sites/app2/public
port: 81
ports:
- send: 8100
to: 81
You would then be able to access your app via http://app2.app:8100 if your hosts file has an entry for app2.app or via http://192.168.0.5:8100 if you aren't using the hosts file.

Homestead Vagrant stuck on SSH connect

When I try to boot up Laravel Homestead on my MacBook Pro (OS X 10.12.3) it gets stuck on:
homestead-7: SSH address: 127.0.0.1:2222
homestead-7: SSH username: vagrant
homestead-7: SSH auth method: private key
And it will eventually time-out.
Timed out while waiting for the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within
the configured ("config.vm.boot_timeout" value) time period.
If you look above, you should be able to see the error(s) that
Vagrant had when attempting to connect to the machine. These errors
are usually good hints as to what may be wrong.
If you're using a custom box, make sure that networking is properly
working and you're able to connect to the machine. It is a common
problem that networking isn't setup properly in these boxes.
Verify that authentication configurations are also setup properly,
as well.
If the box appears to be booting properly, you may want to increase
the timeout ("config.vm.boot_timeout") value.
This is what my vagrant box displays:
My Homestead.yaml:
---
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: ~/Code
to: /home/vagrant/Code
sites:
- map: homestead.app
to: /home/vagrant/Code/Laravel/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'm running Vagrant 1.9.1 with VirtualBox 5.1.14.
Does anyone have an idea what the problem might be?
I solved it. Apparently I had to enable "Cable Connection" on my VM.
Laravel Homestead hangs at SSH auth method: private key on mac
https://github.com/mitchellh/vagrant/issues/7648#issuecomment-235282382

How to troubleshoot and enable folder synchronisation in Laravel Homestead?

I have followed instructions (https://laravel.com/docs/5.2/homestead) to set up laravel running in a Vagrant/Homestead box.
In the end, I should be able to the website from virtual machine by accessing homestead.app in browser on my host machine.
I´ve tried accessing in different ways, with and without specifying port 8000:
http://homestead.app - connection timeout
http://192.168.10.10 - connection timeout
http://localhost - connection timeout
http://127.0.0.1 - connection refused
After troubleshooting I have found that files are not synced to the virtual machine.
E:\homestead_local\Laravel\public\ contains index.php which I try to access. It is not synced to the VM.
I can´t find any error logs on server.
Also, on VM home/vagrant folder was empty after I did everything from instructions. I´m not sure if that was supposed to happen.
Instructions of what I did, keeping them short:
Installed Virtualbox 4.2 and Vagrant 1.8.1
Dowloaded vagrant box:
vagrant box add laravel/homestead
Installed Homestead 0.4.1
git clone https://github.com/laravel/homestead.git Homestead
Initialized homestead:
bash init.sh
Edited homestead.yaml file
Edited hosts file
Hosts file:
192.168.10.10 homestead.app
127.0.0.1 homestead.app
homestead.yaml file:
ip: "192.168.10.10"
memory: 768
cpus: 1
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: E:\HSprojects
to: /home/vagrant/Code
sites:
- map: homestead.app
to: /home/vagrant/Code/Laravel/public
databases:
- homestead
Questions
After running "vagrant up" my CMD shows this:
....
default: Mounting shared folders...
default: /vagrant => E:/Homestead
Why is it showing E:/Homestead and not E:/HSProjects?
Is sharing between folders bidirectional? I can't find a clear answer on this, but I assume they are.

Resources