Vagrant 上装 了一个开发环境 做好配置了为什么 浏览器请求没有反应?

分享 knewmei ⋅ 于 3年前 ⋅ 最后回复由 knewmei 2年前 ⋅ 5108 阅读
D:\Oracle\server>vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'web'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: server_default_1418176788117_2739
Vagrant cannot forward the specified ports on this VM, since they
would collide with some other application that is already listening
on these ports. The forwarded port to 8080 is already in use
on the host machine.

To fix this, modify your current projects Vagrantfile to use another
port. Example, where '1234' would be replaced by a unique host port:

  config.vm.network :forwarded_port, guest: 80, host: 1234

Sometimes, Vagrant will attempt to auto-correct this for you. In this
case, Vagrant was unable to. This is usually because the guest machine
is in a state which doesn't allow modifying port forwarding.

D:\Oracle\server>vagrant reload
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: hostonly
    default: Adapter 3: bridged
==> default: Forwarding ports...
    default: 80 => 8080 (adapter 1)
    default: 22 => 2222 (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Connection timeout. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
    default: /vagrant => D:/Oracle/server
    default: /var/www/html => E:/www

D:\Oracle\server>

用SSH 127.0.0.1 2222 可以进到机器中

不解析PHP文件是为什么!

本文章首发在 Laravel China 社区
成为第一个点赞的人吧 :bowtie:
回复数量: 20
  • NauxLiu https://github.com/nauxliu
    3年前

    配置文件贴出来看下

  • knewmei
    3年前

    难道讲我还要这个环境里在装一个LNMP?

  • Summer MOD A Life-long learner.
    3年前

    我们不是有 Markdown 可以用吗, 一上来一堆乱七八糟的字符...

  • knewmei
    3年前

    @Summer 我错了 下次用这个发

  • Summer MOD A Life-long learner.
    3年前

    @knewmei 哈哈, 我已经把你改过来了. 还有, 评论里你贴的内容 太乱了, 我删了, 你重新贴下咯.

    你用的是最新版本的 Homestead 吗?

    难道讲我还要这个环境里在装一个LNMP?

    Homestead 里面已经有软件了, 见这里: https://doc.laravel-china.org/docs/homestead#included-software

    Homestead 运行的脚本可以见这里: https://github.com/laravel/settler

  • dinghua
    3年前

    @knewmei 可以SSH进去查看nginx是否运行

    service nginx status

  • knewmei
    3年前

    config.vm.box = "web"

    config.vm.network : forwarded_port, guest: 80, host: 8080

    config.vm.network : private_network, ip: "192.168.33.10"

    config.vm.network : public_network, ip: "192.168.1.198"

    config.vm.synced_folder "E:/www", "/var/www/html"

    就改了这4个配置 127.0.0.1:2222 进nginx 没有问题 whereis php 找不到文件。

  • knewmei
    3年前

    @Summer 下了一天,这个网速 用的新版本的!

  • Summer MOD A Life-long learner.
    3年前

    有可能是没有 provision 完全, 试试看:

    vagrant provision

    然后再

    vagrant reload

    试试

  • knewmei
    3年前
        好的在试试
    
  • knewmei
    3年前
    
    D:\Oracle\server>vagrant reload
    ==> default: Attempting graceful shutdown of VM...
    ==> default: Clearing any previously set forwarded ports...
    ==> default: Clearing any previously set network interfaces...
    ==> default: Preparing network interfaces based on configuration...
        default: Adapter 1: nat
        default: Adapter 2: hostonly
    ==> default: Forwarding ports...
        default: 80 => 8000 (adapter 1)
        default: 3306 => 33060 (adapter 1)
        default: 5432 => 54320 (adapter 1)
        default: 35729 => 35729 (adapter 1)
        default: 22 => 2222 (adapter 1)
    ==> default: Running 'pre-boot' VM customizations...
    ==> default: Booting VM...
    ==> default: Waiting for machine to boot. This may take a few minutes...
        default: SSH address: 127.0.0.1:2222
        default: SSH username: vagrant
        default: SSH auth method: private key
        default: Warning: Connection timeout. Retrying...
    ==> default: Machine booted and ready!
    ==> default: Checking for guest additions in VM...
    ==> default: Setting hostname...
    ==> default: Configuring and enabling network interfaces...
    ==> default: Mounting shared folders...
        default: /vagrant => D:/Oracle/server
        default: /home/vagrant/Blog => E:/www
    ==> default: Machine already provisioned. Run `vagrant provision` or use the `--
    provision`
    ==> default: to force provisioning. Provisioners marked to run always will still
     run.
    配置信息
    VAGRANTFILE_API_VERSION = "2"
    Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
      # Configure The Box
      config.vm.box = "ubuntu/trusty64"
      config.vm.hostname = "homestead"
      config.vm.network :private_network, ip: "192.168.33.10"
      config.vm.synced_folder "E:/www", "/home/vagrant/Blog"
      config.vm.provider "virtualbox" do |vb|
        vb.customize ["modifyvm", :id, "--memory", "2048"]
        vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
        vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
      end
      # Configure Port Forwarding
      config.vm.network "forwarded_port", guest: 80, host: 8000
      config.vm.network "forwarded_port", guest: 3306, host: 33060
      config.vm.network "forwarded_port", guest: 5432, host: 54320
      config.vm.network "forwarded_port", guest: 35729, host: 35729
      # Run The Base Provisioning Script
      config.vm.provision "shell" do |s|
        s.path = "./scripts/provision.sh"
      end
    end
    看来我是注定用不上这高大上的工具了。。。
    
    
  • knewmei
    3年前

    @dinghua 没有运行~

  • Summer MOD A Life-long learner.
    3年前

    @knewmei 运行 vagrant provision 了吗?

  • knewmei
    3年前

    @Summer 不能启用。

  • Summer MOD A Life-long learner.
    3年前

    @knewmei

    无法理解 不能启用 什么意思.

    运行 vagrant provision 的时候报错??

  • knewmei
    3年前
    
       没有出错,但是进SSH 后PHP NGINX 都没运行
    
    
  • Summer MOD A Life-long learner.
    3年前

    @knewmei

    发现过几次 Homestead 里面的软件有问题, 都是因为: vagrant provision 运行不全面造成的 (报错, 断网, 下载东西错误 etc.. ).

  • knewmei
    3年前

    配置文件直接用的这个 https://github.com/laravel/settler

    SSH 进去 找不到NGINX

    以下上我的配置过程

     
     cd 箱子文件中 添加箱子文件
    vagrdnt add box base home.box
    初始化
    vagrant init base
    修改Vagrantfile文件
    去掉# 变成
    #config.vm.network :forwarded_port, guest: 80, host: 8080
     config.vm.network :forwarded_port, guest: 80, host: 8080
     # config.vm.network :public_network
    变为
     config.vm.network :public_network, ip: “192.168.1.198”
    修改
     # config.vm.synced_folder “../data”, “/vagrant_data”
    改为
     config.vm.synced_folder “E:/www”, “/var/www/html”
    vagrant provision
    vagrant reload
    ssh 127.0.0.1:2222 
    service nginx status
    得到
    nginx:
    什么都没有。。
    访问 192.168.1.198   打不开~~
    
    
  • junxuanzlg
    2年前

    你的时候就算你们

  • junxuanzlg
    2年前

    你是个

暂无评论~~

  请勿发布不友善或者负能量的内容。与人为善,比聪明更重要!