我一直试图让laravel工作一周以上并且已经接近了,但我无法在我的网络浏览器中使用该项目。我收到了指定的' No输入文件"当我直接到127.0.0.1:8000。我已经尝试了我在网络上找到的所有解决方案,但找不到解决方案。我正在使用最新版本的vagrant,virtualbox,composer和homestead。
我的Yaml是:
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: ~/Projects
to: /home/vagrant/Code
sites:
- map: laravel.dev
to: /home/vagrant/Code/laravel-basics/public
hhvm: true
databases:
- homestead
variables:
- key: APP_ENV
value: local
Vagrant文件是:
require 'json'
require 'yaml'
VAGRANTFILE_API_VERSION = "2"
confDir = $confDir ||= File.expand_path("~/.homestead")
homesteadYamlPath = confDir + "/Homestead.yaml"
afterScriptPath = confDir + "/after.sh"
aliasesPath = confDir + "/aliases"
require File.expand_path(File.dirname(__FILE__) + '/scripts/homestead.rb')
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
if File.exists? aliasesPath then
config.vm.provision "file", source: aliasesPath, destination: "~/.bash_aliases"
end
Homestead.configure(config, YAML::load(File.read(homesteadYamlPath)))
if File.exists? afterScriptPath then
config.vm.provision "shell", path: afterScriptPath
end
end
Vagrant.configure("2") do |config|
config.vm.box = "laravel/homestead"
config.vm.network :forwarded_port, host: 4567, guest: 80
end
主机文件
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
127.0.0.1 laravel.dev
答案 0 :(得分:0)
我不知道你从哪里获得了端口8000
。
这一行:
config.vm.network :forwarded_port, host: 4567, guest: 80
说,在您的主计算机上(您正在从中读取此内容),端口4567
将被转发到您的客户计算机(您启动的VM)端口{{1 }}
然而,这不是必须知道的。默认情况下,Apache和Nginx会侦听端口80,当您访问URL时,所有浏览器都会使用它。
这意味着80
文件中的这一行
/etc/hosts
允许您在没有任何进一步的情况下前往http://laravel.dev。
如果仍然无效,您可以选择以下几种方法:
127.0.0.1 laravel.dev
进入虚拟机并阅读Nginx日志。我相信他们应该在$ vagrant ssh
。