使用localhost从主机访问Vagrant机器上的symfony Web服务器 [英] Acces symfony web server on Vagrant machine from host with localhost

查看:310
本文介绍了使用localhost从主机访问Vagrant机器上的symfony Web服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个带有ubuntu 14.04(下面的流浪文件)的Vagrant机器。



我将主机端口8080转发到访客端口8000.



我在主机上有一个symfony项目(Vagrant文​​件夹)(只是构建了一个symfony new myproject)。



我ssh到来宾机和执行php app / console服务器:在/ vagrant文​​件夹上运行(web服务器已启动)



我尝试从主机浏览器访问localhost:8080而我没有回答。



如何从主机访问symfony Web服务器?



我在最高级别简化了我的流浪者和提供文件以便于阅读。



这是我的流浪文件:

 # -  *  -  mode:ruby  -  *  -  
#vi:set ft = ruby​​:

Vagrant.configure(2)do | config |
config.vm.box =ubuntu / trusty64
config.vm.networkforwarded_port,guest:8000,host:8080
config.vm.networkprivate_network,ip: 10.10.10.10
config.vm.provisionshell,路径:provision.sh
结束

provision.sh文件:

 #!/ usr / bin / env bash 
apt-get update> / dev / null
apt-get install --assume-yes php5-cli

when我在来宾机上做nmap localhost:

 在2015-10-28开始Nmap 6.40(http://nmap.org) 09:04 UTC 
localhost的Nmap扫描报告(127.0.0.1)
主机启动(延迟0.00020秒)。
未显示:996个已关闭的端口
PORT STATE SERVICE
22 / tcp open ssh
111 / tcp open rpcbind
5432 / tcp open postgresql
8000 / tcp open http-alt

非常感谢!



Jordi

解决方案

感谢@qooplmao的回答。



<我创建了一个答案,因为可能更容易找到有类似问题的另一个。



问题是symfony服务器是用 app启动的/ console server:运行刚从127.0.0.1请求中听到。



为了解决这个问题,@ qooplmao告诉我我们可以启动symfony web服务器所有的IP。



刚做: app / console server:start 0.0.0.0:8000
哦!如果你想停止它,你必须 app / console服务器:停止0.0.0.0:8000



谢谢再次为你的帮助!


I created a Vagrant machine with an ubuntu 14.04 (vagrant file below).

I forwarded host port 8080 to guest port 8000.

I have a symfony project on host (Vagrant file folder) (just a symfony new myproject built).

I ssh to guest machine and execute php app/console server:run (web server is up) on /vagrant folder

I try to acces localhost:8080 from a host browser and I have no answer.

How can I access to symfony web server from host machine?

I simplified at max level my vagrant and provision files for easy readability.

This is my vagrant file:

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure(2) do |config|
  config.vm.box = "ubuntu/trusty64"
  config.vm.network "forwarded_port", guest: 8000, host: 8080
  config.vm.network "private_network", ip: "10.10.10.10"      
  config.vm.provision "shell", path: "provision.sh"
end

provision.sh file:

#!/usr/bin/env bash
apt-get update > /dev/null
apt-get install --assume-yes php5-cli

when I do nmap localhost on guest machine:

Starting Nmap 6.40 ( http://nmap.org ) at 2015-10-28 09:04 UTC
Nmap scan report for localhost (127.0.0.1)
Host is up (0.00020s latency).
Not shown: 996 closed ports
PORT     STATE SERVICE
22/tcp   open  ssh
111/tcp  open  rpcbind
5432/tcp open  postgresql
8000/tcp open  http-alt

Thanks a lot!

Jordi

解决方案

Thanks to @qooplmao for this answer.

I create an answer because maybe it will be easier to find for another with similar problem.

The problem is that symfony server launched with app/console server:run just heard from 127.0.0.1 requests.

To solve this, @qooplmao tell me we can launch symfony web server for all ip.

Just doing: app/console server:start 0.0.0.0:8000 Oh! If you want to stop it, you have to app/console server:stop 0.0.0.0:8000

Thanks again for your help!

这篇关于使用localhost从主机访问Vagrant机器上的symfony Web服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆