How to determine Laravel Projects running in Homestead - laravel

So I have two laravel projects running in homestead. Everything's running well in my PC where the projects are located. But in the other computer in a network, it won't work.
Here's 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: C:\Users\Lekz\development\projects\laravel
to: /home/vagrant/Code
sites:
- map: laravel.dev
to: /home/vagrant/Code/acctg_pending2/public
- map: homestead.app
to: /home/vagrant/Code/test/public
databases:
- addessa_acctg_pending
- testdb
# blackfire:
# - id: foo
# token: bar
# client-id: foo
# client-token: bar
# ports:
# - send: 50000
# to: 5000
# - send: 7777
# to: 777
# protocol: udp
And my hosts file:
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
# redirecting this is just a bad idea 127.0.0.1 localhost
# redirecting this is just a bad idea 127.0.0.1 localhost
# redirecting this is just a bad idea 127.0.0.1 localhost
# redirecting this is just a bad idea 127.0.0.1 localhost
# redirecting this is just a bad idea 127.0.0.1 localhost
#127.0.0.1 localhost
192.168.10.10 laravel.dev
192.168.10.10 homestead.app
I can run the two projects without a problem in my PC. But When I tend to run those projects in other computer in a network it won't work. I can only run the second project typing 192.168.1._:8000 (my PC's IP).
How can I determine the projects in other computer in a network when it has the same IP? Like in my hosts file:
192.168.10.10 laravel.dev
192.168.10.10 homestead.app

You are using a virtual machine with an assigned IP address 192.168.10.10
The machine running the Homestead VM will access it through that IP address.
Your hosts file is an alias to that IP address of the VM Homestead.
..
If someone then takes the vagrantFile of your instance they can spin up their Homestead (aka Vagrant) instance with the VM's details.
The new machine using the vagrantFile will need to have their host file edited to match the same IP address as listed out in their Homestead/Vagrant.yaml file.
If you wanted to serve the laravel instance through your local machines ip address using a port you can do so using the
php artisan serve
command from the projects root directory. However, note additional dependencies for sql and composer may be need.

Related

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).

Windows 10 Hosts file not working Laravel Homestead

I am trying to get windows to redirect homestead.localhost to the site i have setup in Laravel Homestead. But its not letting me access the page. i can access the site i setup by going to 192.168.10.10 but going to http://homestead.localhost in my browser brings up:
ERR_CONNECTION_REFUSED
My windows host file, the only line in it, has
192.168.10.10 homestead.localhost
And here is 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: C:/Users/jarro/Documents/Sites
to: /home/vagrant/Sites
sites:
- map: homestead.localhost
to: /home/vagrant/Sites/homestead
databases:
- homestead
# blackfire:
# - id: foo
# token: bar
# client-id: foo
# client-token: bar
# ports:
# - send: 50000
# to: 5000
# - send: 7777
# to: 777
# protocol: udp
So the question is, why is my windows 10 host not working.
I have did the following:
Cleared IP Config, Restarted computer, deleted and created a new vagrant, and reloaded the vagrant.
What am i missing?
sites:
- map: homestead.localhost
to: /home/vagrant/Sites/homestead
You have to map your site to the "public" folder of your Laravel Project! Something like:
to: /home/vagrant/Sites/myLaravelProject/public
Homestead doesn't have any index.php which could be referenced.
So after about a week of giving up, i decided to go back and try again. Found a post on Laracasts:
https://laracasts.com/discuss/channels/general-discussion/homestead-windows-10-need-to-specify-port-8000
All you have to do to fix what i am having done is add :8000 on the url and the site loads. Its not working on port 80 for some reason. I am gonna go fix this now so i can rest in peace.
:D
This is an old question but in the Hosts file I find it much easier to just use:
127.0.0.1 myapp.local
It works everytime. I have always had minor problems with using 192.168.10.10

Laravel Homestead - No input file specified?

I am trying to install a Homestead VM for Laravel development on Debian Linux 8 with Vagrant 1.8.4 and VirtualBox 5.0.24 r108355.
Following the official documentation, I have installed Homestead and configured it in Homestead.yaml in the following way:
---
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: ~/Code/dev.todoparrot.com
to: /home/vagrant/Code
sites:
- map: dev.todoparrot.com
to: /home/vagrant/Code/dev.todoparrot.com/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
To test it with a sample file, I have created an index.php in /home/user/Code/dev.todoparrot.com/public/ on my local machine that echos a string:
<?php echo "Hello from Homestead!"; ?>
I have also added dev.todoparrot.com to /etc/hosts:
127.0.0.1 localhost
127.0.1.1 debian
192.168.10.10 dev.todoparrot.com
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
Within the Homestead folder of my local machine, the VM starts both via vagrant up and vagrant up --provision, but when I visit the domain http://dev.todoparrot.com/ in the browser, I get the following error:
No input file specified.
Any idea what could be wrong?
No input file specified
It says that you don't have any file in
/home/vagrant/Code/dev.todoparrot.com/public
For now, your Vagrant path is
/home/vagrant/Code/dev.todoparrot.com/
And you looking for dev.todoparrot.com/public in dev.todoparrot.com
That's your issue
You need change
folders:
- map: ~/Code/dev.todoparrot.com
to: /home/vagrant/Code
to:
folders:
- map: ~/Code
to: /home/vagrant/Code
It will emulate all folders in Code to /home/vagrant/Code/
Run vagrant up --provision after every update of Homestead.yaml
And in the future, you need to change/add only
sites:
- map: project-name.app
to: /home/vagrant/Code/ProjectName/public
Use vagrant ssh to check your current folders structure inside Code
If you already tried
vagrant up --provision
and still you getting 'No input file specified' error, try to run
vagrant reload --provision
reload vagrant box works for me.

How configure Homestead and xip.io?

I want to access from other devices (iphone, android device, etc) to my sites on homestead in my machine. My machine and all device are on same network.
I want to use http://xip.io but I could not confgure it.
My ip machine is 192.168.0.12
The ip for sites on Homestead is 192.168.10.10
This is the file hosts:
127.0.0.1 localhost
127.0.1.1 host
#Virtual Hosts on Homestead
192.168.10.10 siteOne.com
192.168.10.10 siteTwo.app
192.168.10.10 otherSite.app
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
and this is Homestead.yaml
---
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: ~/Homestead-Projects
to: /home/vagrant/Homestead-Projects
sites:
- map: siteOne.com
to: /home/vagrant/Homestead-Projects/SiteOne/public
- map: siteTwo.app
to: /home/vagrant/Homestead-Projects/SiteTwo/public
- map: otherSite.app
to: /home/vagrant/Homestead-Projects/OtherSite/public
databases:
- homestead
- db_siteOne
- db_siteTwo
- db_otherSite
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
how can I do it?
Thanks!
You can access your site by browsing to http://<your_local_ip>.xip.io:8000.
To understand how it works you need to know two facts:
Domain example.your_ip.xip.io resolves to your_ip.
By default local port 8000 is mapped to port 80 of your homestead virtual machine.
Please note, xip.io acts as a "DNS" and you don't need to edit your hosts file to access your homestead site from other devices on local network.
This solution works perfectly if you have only one site mapped in homestead. If there are multiple sites, only last mapped site gets served. A workaround is to use site identifier in your url. http://<your_site>.<your_local_ip>.xip.io:8000 still resolves to same endpoint but now you can update your homestead nginx to pickup the site identifier and serve the right site.
I believe Homestead already ships with it by default,
in my case i just added an entry on the hosts files, /etc/hosts (i'm on a mac machine), like this:
127.0.0.1 http://app.ip.address.xip.io:8000
(usually the default port is 8000), and then add an entry on the homestead yml config file (you can reach by typing homestead edit on your console.
and that should do it.

Vagrant Laravel new project set up

I am now ready to start a new project with Laravel using Vagrant. My initial project worked fine but I can't seem to get the new project to show in the browser with its unique name loginauth.app.
My very first app was called PaulsApp and if I typed paulsapp.app in the browser the laravel started page showed fine.
I followed the instructions to create a new project using composer create project in my VM in the same directory as my first app. I can see this in both the local and on the VM.
Next I updated the homestead.yaml file to include the new sitemap and run vagrant provision to let the VM know of the updates.
I believe I must be overlooking something as my .yaml file has the map as homestead.app but that does not work only paulsapp.app which is in my etc/hosts file.
Please could somebody explain how the .yaml file and the hosts file are interacting. If I completely remove the mapping to PaulsApp in the yaml file, paulsapp.app in the browser still shows up the correct page.. as such I am a tad confused. I thought one simply added a mapping to the yaml and then could access that mapping through the browser. I want to type loginauth.app in the browser and have it point to the index file in the public directory of /home/vagrant/code/loginauth/ thanks.
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/PaulsApp/public
- map: loginauth.app
to: /home/vagrant/code/loginauth/public
databases:
- homestead
variables:
- key: APP_ENV
value: local
etc/hosts
##
# 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
::1 localhost
192.168.10.10 Paulsapp.app
#127.0.0.1 PaulsApp.dev
OK so thanks to some help from the guys over at #laravel irc channel..
I needed to add the correct line to the hosts file. I tried 192.168.10.10 loginauth.app but got no joy so I used 127.0.0.1 loginauth.app.
Then the key was to vagrant halt the VM, Vagrant UP it again then vagrant provision it so the VM could see the changes.
Now loginauth.app:8000/ brings up the page I was hoping for...

Resources