2016-01-13 43 views
0

無論出於何種原因,我無法獲得多個網站與Homestead合作。每增加一個新網站,當我在瀏覽器中訪問它時,都會返回相同的網站Laravel 5.2 - Homestead每個域的同一網站加載

我嘗試了每次在堆棧以及larvel.io中遇到的「解決方案」。他們都沒有解決問題。任何幫助將不勝感激。

下面是我的.yaml文件和我的主機文件的內容。

本地目錄結構:

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文件:

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

我曾嘗試以下:

  1. 遊民提供
  2. 流浪漢重裝--provision
  3. 銷燬箱和無業遊民了
  4. 流浪漢的全球地位,其次是無業遊民提供VM#
  5. 也試圖映射文件夾和網站

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 

回答

0

明白了。

導致問題的域之前的斜槓。

改變了這個:

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

要這樣:

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

首先,一個提示:使用NFS,因爲Windows文件夾共享是非常非常慢。要在Windows上添加此功能的支持,你應該安裝遊民,winnfsd

vagrant plugin install vagrant-winnfsd

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

萬一該網站的主機名之前刪除斜槓。我不確定這是否是原因,但是在您的配置中發現唯一錯誤。

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

另一個技巧:安裝流浪漢,hostsupdater插件的主機名添加到您的主機文件自動。

vagrant plugin install vagrant-hostsupdater

在你Homestead.yaml文件:

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

在腳本/宅基地。RB文件:

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

我的文件:homestead.rbHomestead.yaml