映射的站点返回此站点无法访问

时间:2021-02-17 12:32:04

标签: laravel vagrant virtualbox homestead hosts

目前已设置我的 Homestead.yaml 文件以将两个不同的文件夹映射到两个不同的站点。一种用于我的 API,一种用于 phpmyadmin。这是我的 homestead.yaml 和 hosts 文件。

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

authorize: ~/.ssh/id_rsa.pub

keys:
    - ~/.ssh/id_rsa

folders:
    - map: C:\Users\nikulas\Homestead\code
      to: /vagrant/code
      

sites:
    - map: dev.api.app
      to: /vagrant/code/api/public
    - map: dev.phpmyadmin.app
      to: /vagrant/code/phpMyAdmin

databases:
    - homestead
    - subit

features:
    - mysql: false
    - mariadb: true
    - postgresql: false
    - ohmyzsh: false
    - webdriver: false

#services:
#    - enabled:
#        - "postgresql@12-main"
#    - disabled:
#        - "postgresql@11-main"

# ports:
#     - send: 50000
#       to: 5000
#     - send: 7777
#       to: 777
#       protocol: udp

主机

# 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
#      192.168.10.10    dev.api.app
#      192.168.10.10    dev.phpmyadmin.app

# localhost name resolution is handled within DNS itself.
#   127.0.0.1       localhost
#   ::1             localhost

所以一切都正常。当运行 vagrant up 和 vagrant ssh 时,如果我同时拥有 api 和 phpMyAdmin 文件夹,我可以导航到代码目录。我可以像这样在邮递员中向我的 API 发出请求

192.168.10.10/v2/example-endpoint

问题是,如果我尝试访问 dev.api.app 或 dev.phpmyadmin.app,我会收到“无法访问此站点”,而且我看不到在浏览器中导航到 phpmyadmin 的方法。

1 个答案:

答案 0 :(得分:0)

在 bash 脚本和类似的 # 中,用于评论,您的主机基本上没有评论。为了让您的主机文件正确注册您的域,应将其删除。

#      192.168.10.10    dev.api.app
#      192.168.10.10    dev.phpmyadmin.app

应该。

192.168.10.10    dev.api.app
192.168.10.10    dev.phpmyadmin.app
相关问题