无论出于何种原因,我都无法让多个网站与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
我尝试了以下内容:
例如:
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 :(得分:1)
首先,一个提示:使用nfs因为windows文件夹共享非常慢。要在Windows上添加对此功能的支持,您应该安装vagrant-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
另一个提示:安装vagrant-hostsupdater插件,自动将主机名添加到主机文件中。
vagrant plugin install vagrant-hostsupdater
在你的Homestead.yaml文件中:
aliases: ["project1.app", "project2.dev"]
在scripts / homestead.rb文件中:
config.hostsupdater.aliases = settings["aliases"]
答案 1 :(得分:0)
知道了。
导致问题的域之前的斜杠。
改变了这个:
pods
对此:
sites:
- map: /project1.app
to: /home/vagrant/Code/project1/public
- map: /project2.dev
to: /home/vagrant/Code/project2/public