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

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!

Related

Local (dev) hosts domains ignored, but 'blocking' domains works...?

I am running Virtual Machine with Laravel project.
Typing 192.168.10.10 in browser re-directs correctly onto Laravel home page.
Typing testing.test is googling 'testing.test'. Tried across IE/Edge, Opera, Chrome.
My Homestead.yaml config is:
sites:
- map: testing.test
to: /home/vagrant/Code/Laravel/public
My hosts file is:
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
192.168.10.10 testing.test
Interestingly - if I add
127.0.0.1 www.stackoverflow.com
Stackoverflow will get 'blocked'.
Also pinging testing.test from commander gives positive response from 192.168.10.10.
Tried flashing DNS, turning off IPv6. Please help :)
Adding http:// in front of testing.test in hosts file helped. Also cleared dns from chrome and opera.
So the hosts file looks now:
192.168.10.10 http://testing.test www.testing.test testing.test

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.

Homestead project runs only when used 127.0.0.1 in the hosts file

I am new to the Homestead and virtualbox/vagrant world. I went through some video tutorials on how to strat working with Homestead.
Everything went smoothly until the last step. It says we need to add the IP address mention in the Homestead.yaml file into the hosts file.
I did that, but it always gave me the following error:
This site can’t be reached
dev.test refused to connect.
Search Google for dev test 8000
ERR_CONNECTION_REFUSED
My hosts file looks something like this:
192.168.10.10 dev.test
But when I use 127.0.0.1 dev.test it works perfectly fine.
I don't know what's happening.
Even the official documentation says we should 192.168.10.10 dev.test in the /etc/hosts file.
Where am I going wrong??
Here's my Homestead.yaml file
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
authorize: ~/.ssh/laravel.pub
keys:
- ~/.ssh/laravel
folders:
- map: /var/www/Laravel
to: /home/vagrant/Laravel
sites:
- map: dev.test
to: /home/vagrant/Laravel/test/public
databases:
- homestead
Looks like I found my mistake.
I was trying to access my web app using port 8000 even after using 192.168.10.10 dev.test in the hosts file. I should have simply used dev.test in the browser to access the web app.
Silly Mistake.
I makes perfect sense to use dev.test:8000 in the browser if the hosts file reads 127.0.0.1 dev.test

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

homestead machine is running but urls not found

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

Resources