ubuntu - 无法从 vagrantbox 外部访问通过 vagrant 的 apigility

标签 ubuntu zend-framework2 vagrant laminas-api-tools

我使用 Ubuntu-Vagrant 通过 Apigility 制作 API。
Apigility 已安装并且运行良好:

$ sudo php -S 10.10.10.30:8888 -t public public/index.php
PHP 5.6.4-1+deb.sury.org~trusty+1 Development Server started at Tue Jan 27 13:40:23 2015
Listening on http://10.10.10.30:8888
Document root is /var/www/public
Press Ctrl-C to quit.

当我从 vagrantbox 内部执行 wget 时,我收到了由 Apigility 提供的格式良好的 html 文件。当我从我的访客系统 (osX) 浏览网址 (http://10.10.10.30:8888) 时,该网站无法访问。

防火墙似乎也可以:
$ sudo netstat -tulpn

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:46165           0.0.0.0:*               LISTEN      619/rpc.statd   
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      2371/sshd       
tcp        0      0 10.10.10.30:8888        0.0.0.0:*               LISTEN      5717/php        
tcp        0      0 0.0.0.0:1080            0.0.0.0:*               LISTEN      1062/mailcatcher
tcp        0      0 0.0.0.0:1025            0.0.0.0:*               LISTEN      1062/mailcatcher
tcp        0      0 0.0.0.0:59106           0.0.0.0:*               LISTEN      -               
tcp        0      0 127.0.0.1:9000          0.0.0.0:*               LISTEN      1010/php-fpm.conf)
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN      1016/mysqld     
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      572/rpcbind     
tcp6       0      0 :::22                   :::*                    LISTEN      2371/sshd       
tcp6       0      0 :::443                  :::*                    LISTEN      1345/apache2    
tcp6       0      0 :::42974                :::*                    LISTEN      619/rpc.statd   
tcp6       0      0 :::39553                :::*                    LISTEN      -               
tcp6       0      0 :::111                  :::*                    LISTEN      572/rpcbind     
tcp6       0      0 :::80                   :::*                    LISTEN      1345/apache2    
udp        0      0 0.0.0.0:19413           0.0.0.0:*                           794/dhclient    
udp        0      0 0.0.0.0:741             0.0.0.0:*                           572/rpcbind     
udp        0      0 0.0.0.0:51436           0.0.0.0:*                           -               
udp        0      0 0.0.0.0:44542           0.0.0.0:*                           619/rpc.statd   
udp        0      0 127.0.0.1:795           0.0.0.0:*                           619/rpc.statd   
udp        0      0 0.0.0.0:68              0.0.0.0:*                           794/dhclient    
udp        0      0 0.0.0.0:848             0.0.0.0:*                           -               
udp        0      0 0.0.0.0:111             0.0.0.0:*                           572/rpcbind     
udp        0      0 10.10.10.30:123         0.0.0.0:*                           2666/ntpd       
udp        0      0 10.0.2.15:123           0.0.0.0:*                           2666/ntpd       
udp        0      0 127.0.0.1:123           0.0.0.0:*                           2666/ntpd       
udp        0      0 0.0.0.0:123             0.0.0.0:*                           2666/ntpd       
udp6       0      0 :::741                  :::*                                572/rpcbind     
udp6       0      0 :::10482                :::*                                794/dhclient    
udp6       0      0 :::50958                :::*                                -               
udp6       0      0 :::111                  :::*                                572/rpcbind     
udp6       0      0 fe80::a00:27ff:fe3a:123 :::*                                2666/ntpd       
udp6       0      0 ::1:123                 :::*                                2666/ntpd       
udp6       0      0 :::123                  :::*                                2666/ntpd       
udp6       0      0 :::34952                :::*                                619/rpc.statd   

那可能是什么问题?

最佳答案

您可以转发端口或建立专用网络:
在 Vagrantfile 中,您可以将此行添加到转发端口:
config.vm.network “forwarded_port”, guest :80,主机:81
下面这行当访问“localhost:81”时,请求会被转发到VM的80端口。
或者做一个私有(private)的newotk:
config.vm.network“private_network”,ip:“192.168.10.10”
在另一行中,将通过 IP 192.168.10.10 访问 guest VM,您可以访问它:
http://192.168.10.10:8080
为简单起见,您可以在系统上的 hosts 文件中添加一个条目:
192.168.10.10 虚拟机
并访问:http://myvm:8080

霍尔普这有帮助。

关于ubuntu - 无法从 vagrantbox 外部访问通过 vagrant 的 apigility,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28172176/

相关文章:

mysql - 使用 vagrant 导入数据库 mysql。没有这样的文件或目录

chef - 调试 Chef Recipe 而无须浪费和重新配置

android - 错误的IDE Android Studio

ubuntu - 安装 snap "core"(3604) ([start snap-core-3604.mount] 失败

php - Behat - 未找到上下文类。

zend-framework2 - ZF2中CSRF的默认超时

mysql - laravel php artisan 迁移问题

python - 如何设置 PyCharm 使 '^M' 不出现在 ubuntu 中

java - Servlet POST 数据根据调用者进行裁剪

zend-framework2 - 在win7上的不同目录中的wamp 2.5中创建vhost返回禁止错误