Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Homestead: Folder mapping to the wrong document root

I'm using Laravel Homestead to VM into my dev environment. I recently created a new mapping (the /Website/Site/ directory) in my Homestead.yaml whenever I go to site.app page , I'm redirected to the /tasks page which was set in another project (/Laravel). (This results in an error, since the page isn't there). Here is my Homestead.yaml file:

folders:
   - map: /Users/me/Homestead/Code/Laravel
     to: /home/vagrant/Code/Laravel
   - map: /Users/me/Homestead/Code/Larabook
     to: /home/vagrant/Code/Larabook
   - map: /Users/me/Homestead/Code/Website/Site
     to: /home/vagrant/Code/Website

sites:
    - map: homestead.app
      to: /home/vagrant/Code/Laravel/public
    - map: larabook.app
      to: /home/vagrant/Code/Larabook/public
    - map: site.app
      to: /home/vagrant/Code/Website/public

variables:
   - key: APP_ENV
     value: local

The Laravel contains the route where the index page is redirected and the Website directory is the new project that is just a fresh install of Laravel and nothing else. Here is some of the Server/Request Data error output:

SCRIPT_FILENAME /home/vagrant/Code/Laravel/public/index.php
SCRIPT_NAME     /index.php
REQUEST_URI     /tasks
DOCUMENT_URI    /index.php
DOCUMENT_ROOT   /home/vagrant/Code/Laravel/public

Here is the route.php for the project in Laravel/ (i.e. the old project)

 Route::get('/', function(){
    return Redirect::to('tasks');
 });

Why is a fresh install of Laravel being redirected by a project in a different directory?

SOLUTION

  1. vagrant reload --provision

or, more drastically

  1. from ~/Homestead run vagrant destroy then vagrant up
like image 907
jkjmr6 Avatar asked Sep 11 '14 00:09

jkjmr6


4 Answers

I ran into this issue too.

Presumedly, the changes in Homestead.yaml file are being ignored. So, I resolved to refresh it.

! REVISED SOLUTION THAT DOES NOT DESTROY YOUR MACHINE

My solution below is inadequate because it destroys your existing machine. See this solution first!

Once your Homestead environment is provisioned and running, you may want to add additional Nginx sites for your Laravel applications. You can run as many Laravel installations as you wish on a single Homestead environment. There are two ways to do this: First, you may simply add the sites to your Homestead.yaml file and then run vagrant provision.

Alternatively, you may use the serve script that is available on your Homestead environment. To use the serve script, SSH into your Homestead environment and run the following command...

http://laravel.com/docs/homestead#daily-usage

Per the Laravel.io forum the better solution is to run vagrant reload --provision.

See also

*Vagrant Docs

OLD SOLUTIONS: USE AS LAST RESORT

Try these solutions:

  1. from ~/Homestead run vagrant reload then vagrant up

or, more drastically

  1. from ~/Homestead run vagrant destroy then vagrant up

OPTION 2 DESTROYS YOUR SERVER AND ITS DATABASES

Note: I resorted to step 2.

like image 76
mike Avatar answered Sep 26 '22 03:09

mike


You can run homestead up --provision to force the reload of the Homestead.yaml file.

like image 30
bcdennis72 Avatar answered Sep 26 '22 03:09

bcdennis72


If you have a running homestead instance, simply issue the command homestead provision from your local machine.

like image 23
Sir Cringe Avatar answered Sep 26 '22 03:09

Sir Cringe


I could fix that issue using the serve command provided with the homestead box. When you're connected to the VM run:

serve personal.local /home/vagrant/projects/personal/personal-site/public

without the need to reboot the VM. I've tried vagrant reload --provision and it reloads the yaml file but seems not the ngnix configuration.

like image 27
user2131283 Avatar answered Sep 26 '22 03:09

user2131283