0
votes

For whatever reason I cannot get multiple sites to work with Homestead. Every new site added, returns the same site when I visit it in the browser

I have tried every "solution" I have come across here on stack as well as on larvel.io. None of them solve the problem. Any help would be greatly appreciated.

Below are the contents of both my .yaml file and my hosts file.

Local Directory Structure:

 Root directory = WWW
 project1       = WWW/project1
 project2       = WWW/project2

Homestead.yaml:

 ---
 ip: "192.168.10.10"
 memory: 2048
 cpus: 1
 provider: virtualbox

 authorize: ~/.ssh/id_rsa.pub

 keys:
     - ~/.ssh/id_rsa

 folders:
     - map: ~/WWW
       to: /home/vagrant/Code

 sites:
     - map: /project1.app
       to: /home/vagrant/Code/project1/public
     - map: /project2.dev
       to: /home/vagrant/Code/project2/public

 databases:
     - project1_db
     - project2_db

 variables:
     - key: 'APP_ENV'
       value: 'local'
     - key: 'APP_DEBUG'
       value: 'true'

 # blackfire:
 #     - id: foo
 #       token: bar
 #       client-id: foo
 #       client-token: bar

 # ports:
 #     - send: 93000
 #       to: 9300
 #     - send: 7777
 #       to: 777
 #       protocol: ump

/etc/hosts 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 

 192.168.10.10 project1.app
 192.168.10.10 project2.dev

I have tried the following:

  1. vagrant provision
  2. vagrant reload --provision
  3. Destroyed box and vagrant up
  4. vagrant global-status, followed by vagrant provision vm#
  5. have also tried to map folders and sites

ex:

 folders:
     - map: ~/WWW/project1
       to: /home/vagrant/Code/project1

     - map: ~/WWW/project2
       to: /home/vagrant/Code/project2

 sites:
      - map: /project1.app
        to: /home/vagrant/Code/project1/public
      - map: /project2.dev
        to: /home/vagrant/Code/project2/public
2

2 Answers

1
votes

First, one tip: use nfs because windows folder share is very very slow. To add support for this feature on Windows you should install vagrant-winnfsd

vagrant plugin install vagrant-winnfsd

folders:
    - map: ~/WWW
      to: /home/vagrant/Code
      type: nfs

Just in case remove the slash before the site hostname. I don't have sure if this is the reason but was the only thing wrong I found in your configuration.

sites:
    - map: project1.app
      to: /home/vagrant/Code/project1/public
    - map: project2.dev
      to: /home/vagrant/Code/project2/public

Another tip: install the vagrant-hostsupdater plugin to add the hostnames to your hosts file automatically.

vagrant plugin install vagrant-hostsupdater

in you Homestead.yaml file:

aliases: ["project1.app", "project2.dev"]

in scripts/homestead.rb file:

config.hostsupdater.aliases = settings["aliases"]

My files: homestead.rb and Homestead.yaml

0
votes

Got it.

The slashes before the domain where causing the issue.

Changed this:

sites:
    - map: /project1.app
      to: /home/vagrant/Code/project1/public
    - map: /project2.dev
      to: /home/vagrant/Code/project2/public

To this:

sites:
    - map: project1.app
      to: /home/vagrant/Code/project1/public
    - map: project2.dev
      to: /home/vagrant/Code/project2/public