我正在使用Mac OSX El Capitan 10.11.2。我对vagrant很陌生,这将是我在Symfony中的第一个项目。我设置了环境以启动我的第一个symfony 4项目。一切都已正确安装(包括VirtualBox,Vagrant)。我更新了主机文件,编辑了Homestead.yaml,最后,当我想在Chrome中访问我的域(symf01.test)时,收到一条消息,提示无法访问此站点,并且自动下载了一个文本文件,其中包含这样的信息:
<?php
use Symfony\Component\Debug\Debug;
use Symfony\Component\HttpFoundation\Request;
require dirname(__DIR__).'/config/bootstrap.php';
if ($_SERVER['APP_DEBUG']) { unmask(0000);
Debug::enable();}
if ($trustedProxies = $_SERVER['TRUSTED_PROXIES'] ?? $_ENV['TRUSTED_PROXIES'] ?? false)
{ Request::setTrustedProxies(explode(',', $trustedProxies), Request::HEADER_X_FORWARDED_ALL ^ Request::HEADER_X_FORWARDED_HOST);}
if ($trustedHosts = $_SERVER['TRUSTED_HOSTS'] ?? $_ENV['TRUSTED_HOSTS'] ?? false)
{ Request::setTrustedHosts([$trustedHosts]);}
$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
$request = = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
这是我的Homestead.yaml文件:
ip:"192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: /Users/username/Homestead/code/simba
to: /home/vagrant/simba
type: "nfs"
sites:
- map: symf01.test
to: /home/vagrant/simba/public
type: symfony
databases:
- homestead
# ports:
# - send: 50000
# to: 5000
# - send: 7777
# to: 777
# protocol: udp
# blackfire:
# - id: foo
# token: bar
# client-id: foo
# client-token: bar
# zray:
# If you've already freely registered Z-Ray, you can place the token here.
# - email: foo@bar.com
# token: foo
# Don't forget to ensure that you have 'zray: "true"' for your site.
答案 0 :(得分:0)
为将来参考,它有所帮助:
...
sites:
- map: symf01.test
to: /home/vagrant/simba/public
type: symfony
到
...
sites:
- map: symf01.test
to: /home/vagrant/simba/public
type: "symfony4"
语法上存在差异。 type
的值必须用引号引起来。
type
告诉Homestead如何修改.htaccess
文件,以便可以正确访问您的网站。