homestead machine is running but urls not found - laravel

I am using homestead and it is my first time. now i can run the homestead up and machine starts.
i edited the homestead.yaml file and i edited hosts file but when i try to go to my website in the browser it says that the webpage is not available.
for more information i am using windows and virtual box and here is my hosts file
127.0.0.1 localhost
192.168.10.10 exam.dev
i am wondering what can i do to fix this problem. what i am missing here?
Edit: i tried to ping the 192.168.10.10 but it says that destination host is unreachable

Related

Why am I getting the Apache2 welcome page instead of the laravel page?

I installed laravel via homestead, but when I go to localhost I get the apache2 welcome/success screen. I can't get the Laravel welcome page to load up.
I ran vagrant up on the homestead box but there were no laravel files. So I installed it using composer create-project --prefer-dist laravel/laravel app.
Now when I go to localhost I get the apache2 welcome screen. If I put an index.html in /vagrant I can get that to load up by going to localhost:8000. But going to the same address without the index file causes a 403.
I've tried all combinations of URLs, /app, /app/app, /app/public, and I've tried changing the URL in the .env.
Weirdly, I can't find this apache welcome file on the server. The page itself says "You should replace this file (located at /var/www/html/index.html)" If I SSH in and go to that folder, there is an nginx welcome html page there, but no apache one.
If I go to file:///var/www/html/ in the browser, I see the index.html of the apache welcome page. If I go to file:///var/ I see a few different folders there than I do by SSHing into the vagrant box. I don't understand why.
How can I get the Laravel welcome page to appear?
edits:
http://localhost:8000/public returns "No input file specified"
Sites part of homestead.yaml
sites:
-
map: homestead.test
to: /home/w/work/qs/app/public
/etc/hosts:
127.0.0.1 localhost
127.0.1.1 qs qs
192.168.10.10 homestead.test
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
#### HOMESTEAD-SITES-BEGIN
# 127.0.0.1 homestead.test
#### HOMESTEAD-SITES-END
You need to add hosts entries for each site and the mappings to your Homestead.yaml:
/etc/hosts:
192.168.10.10 homestead.test
~/Homestead/Homestead.yaml:
sites:
- map: homestead.test
to: /home/vagrant/code/my-project/public
Then still under ~/Homestead, run vagrant up --provision.
As per documentation,
you will still need to add an /etc/hosts file entry for homestead.test or the domain of your choice if you are not using automatic
Add domain entry in your /etc/hosts file like:
192.168.10.10 homestead.test
And try brows http://homestead.test from browser
Make sure the IP address listed is the one set in your Homestead.yaml
Edited:
It seems you may running some commands out of the root directory of the project.
Here is the very short video to verify your steps.
https://youtu.be/a9jtoXXp5ao
All the best!

How to resolve domains within a vagrant box?

I have a Debian Vagrant box running a Nginx server which hosts two websites/services that should share data via JSON endpoints.
Websites are accessible with https://app.test and https://cdn.app.test from the browser of the Host MacOS system.
To do this I have setup config.vm.network "private_network", ip: "33.33.33.10" in the Vagrantfile.
I have added to the /etc/hosts file on MacOS:
33.33.33.10 app.test
33.33.33.10 cdn.app.test
I can access both domains from the Mac, that works.
However I cannot use curl https://cdn.app.test/ within the Vagrant box shell because the Domains won't be resolved.
Neither curl_init or file_get_contents work.
I guess the problem is that the Vagrant cannot see the MacOS hosts entries.
What is the right way to configure this dev system? What is the easy fix?
The easy fix is to add
127.0.0.1 app.test
127.0.0.1 cdn.app.test
to /etc/hosts in the Debian Vagrant box.
For Vagrant. copy the default config from /etc/apache2/sites-available/000-default.conf to /etc/apache2/sites-available/"".conf
vagrant ssh // login
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/"<your-test-domain>".conf
Folder name in sites-available should be the exact same as the one that you will be changing in your hosts file later.
Then edit your ServerName and DocumentRoot, enable it -> sudo a2ensite "".conf
restart Apache, edit your hosts file in your host OS.
Inside your hosts file, point to your private IP as specified in Vagrantfile

App on a Vagrant box running Laravel Homestead only displays 'It Works' upon fresh install of Laravel App

I install a new Laravel app into my /sites folder called 'blog' using the laravel new blog terminal command.
The site builds fine, no errors on the terminal.
Then I used the subl /etc/hosts command to open up the hosts file in Sublime Text 3. Here is the contents of that file.
##
# 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
127.0.0.1 laraveltest.app
127.0.0.1 makoto.app
127.0.0.1 modelawiki.app
127.0.0.1 fresher.app
127.0.0.1 blog.app
Right now let's focus on blog.app.
I then use the subl Homestead.yaml command to open and edit the Homestead.yaml file and update the maps. Here's the contents of that file.
---
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: ~/www/sites
to: /home/vagrant/sites
sites:
- map: blog.app
to: /home/vagrant/sites/blog/public
- map: laraveltest.app
to: /home/vagrant/sites/laravelTest/public
- map: makoto.app
to: /home/vagrant/sites/Makoto
- map: modelawiki.app
to: /home/vagrant/sites/modelawiki
- map: fresher.app
to: /home/vagrant/sites/fresher/public
databases:
- homestead
I then run the homestead provision command which is an alias for vagrant provision to update everything and get the site up and running.
Now before running the vagrant provision command, every other site (laraveltest.app:8000, makoto.app:8000, etc.) worked just fine, and or displayed the Default Laravel Splash screen (laraveltest.app:8000).
When visiting any of the sites mapped in the homestead.yaml file, all I'm getting is the following page displayed...
http://imgur.com/a/6IIkD
Here's the HTML output.
<html><body><h1>It works!</h1></body></html>
I'm confused on what I did wrong. I'm a newer user going through the Laravel Tutorials on LaraCasts. I followed CodeCourses videos on YouTube to help me install the Vagrant Box onto my machine.
I've also tried to see what was out there on the net for this issue and all i could find is this article on laravel valet... but it seems as though this isn't the tutorial I need.
https://laracasts.com/discuss/channels/laravel/valet-v112-update-just-keep-getting-the-it-works
Edit: I'm currently in the process of uninstalling the vagrant box running laravel/homestead. I did the vagrant destroy <id> command and the vargrant box remove. I then edited the /etc/hosts file and removed all the edited custom app names. I then also deleted my Homestead folder containing my homestead.yaml file. I'm hopefully starting with a fresh install here soon.
(Posted answer on behalf of the OP).
I reinstalled everything including the Vagrant box, and Homestead. Everything runs as normal. Don't know what happened. However the only way I can connect to my sites are to actually type the port in the URL. i.e. blog.app:8000. If i visit blog.app by itself, then the "It Works!" header comes back up and the laravel site goes away.
I'm thinking this might be an issue with nginx, and port forwarding? Since this is the case and the original question has been answered by myself, I'll be asking a new question about port forwarding and Laravel homestead.
Have you configured your sites-available ? try this line inside the virtual machine (after command vagrant ssh):
serve blog.app ~/sites/blog/public
It seems that you have already solved the problem, as you made an edit to your original question and linked to a new question. However, one thing I noticed that may have been causing your problem is the IP in your /etc/hosts file is does not match the IP in your Homestead.yaml file. When I use Laravel Homestead, I make sure that my /etc/hosts and Homestead.yaml files have identical IPs. I always get the Laravel splash page when I do this. Hopefully this is useful for future Vagrant boxes.

Point Vagrant to a Local API

Hey guys I have two vagrant machines running, one is the app code base and the other is the api code base for the app. I want to be able to do a curl call from my app machine to the api machine.
On my computer I can call both because I have them in my etc/hosts file, but what do I need to do to successfully request from vagrant to vagrant.
I tried to go into my app vagrant machine's etc/hosts and add the domain with the 127.0.0.1 but no cigar.
So it turns out that Vagrant makes your guest machine's ip to 10.0.2.2. So what I did on my App code base vagrant machine. I edited the /etc/hosts to;
10.0.2.2 api.local.com
previously I tried 127.0.0.1, and that didn't work, so I just checked the apache access logs saw the ip and gave that a whirl. and that worked.
On my local machine I have;
127.0.0.1 api.local.com
I hope this helps.

Hosts file redirect to local computer directory

I have a local Apache server running on my desktop which allows me to run a local site which I want to access from my laptop.
I'm able to access the computer in my hosts file using '192.168.0.5 liam.pc' but I can't figure out how to enter a directory. I've tried '192.168.0.5/Hudex/public hudex.dev' but it doesn't seem to work.
How can I accomplish the effect I want?
HOSTS file:
127.0.0.1 localhost
127.0.0.1 zheil.dev
192.168.0.5 liam.pc

Resources