我已经安装了所有必要的工具来启动和运行vagrant。我可以通过putty从Windows主机登录vm guest。但是,当我尝试使用我的端口转发指定的端口从主机Windows操作系统访问本地主机,我不能够访问端口转发不在Vagrant工作
回答
我将它作为一个答案,因为它会更加明朗比在评论写作:
从你展示它是什么并不清楚你已经安装了Apache,Nginx的或其他web服务器,所以没有你得到预期的行为。
从VM,去运行
sudo netstat -ant
(你需要须藤否则就不能检测以root权限运行的进程的PID),你应该有一些看起来像[email protected]:/etc/init.d$ sudo netstat -nltp 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:111 0.0.0.0:* LISTEN 512/rpcbind tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 1827/apache2 tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 652/sshd tcp 0 0 0.0.0.0:58397 0.0.0.0:* LISTEN 539/rpc.statd tcp6 0 0 :::111 :::* LISTEN 512/rpcbind tcp6 0 0 :::22 :::* LISTEN 652/sshd tcp6 0 0 :::54908 :::* LISTEN 539/rpc.statd
最重要的部分是0 0.0.0.0:80
所以我必须在80端口运行的进程,并在我的情况下,其apache2
如果你没有看到的东西在端口80上运行,你需要安装,运行sudo apt-get install apache2
它将安装/启动的Apache2服务,你就可以去
现在检查是否有东西在页面上返回从虚拟机,你可以运行
curl
或任何你喜欢的[email protected]:/etc/init.d$ curl localhost <html><body><h1>It works!</h1> <p>This is the default web page for this server.</p> <p>The web server software is running but no content has been added, yet.</p> </body></html>
所以在这里它的细腻,我的页面显示。
现在,当我去到主机,做同样的,我可以看到在同一页
[email protected]:~/project/examples/vagrant/ssh$ curl http://localhost:8080
<html><body><h1>It works!</h1>
<p>This is the default web page for this server.</p>
<p>The web server software is running but no content has been added, yet.</p>
</body></html>
[email protected]:~/project/examples/vagrant/ssh$ curl http://127.0.0.1:8080
<html><body><h1>It works!</h1>
<p>This is the default web page for this server.</p>
<p>The web server software is running but no content has been added, yet.</p>
</body></html>
[email protected]:~/project/examples/vagrant/ssh$
我使用的是Ubuntu/trusty64,我认为它已经预装了apache。现在我已经运行了命令netstat -nltp,但是我看不到0.0.0.0:80。请让我知道如何在我的虚拟机上安装apache, –
编辑答案,基本上''sudo apt-get install apache2' –
@AmitKumar,请记得接受/投票答案,如果它帮助你 –
- 1. Vagrant的端口转发不起作用
- 2. 端口转发不能与Test-Kitchen和Vagrant一起工作
- 3. CKAN/Vagrant端口转发
- 4. Vagrant Apache2 http/https端口转发
- 5. VirtualBox端口转发不工作
- 6. 内置端口转发> Vagrant软件包找不到Vagrantfile.pkg
- 7. 在正在运行的系统上更改Vagrant端口转发
- 8. telnet端口转发如何工作?
- 9. bitvise端口转发工作如何?
- 10. Boot2Docker:无法让端口转发工作
- 11. 用于android模拟器的UDP端口转发; “adb转发udp:端口udp:端口”和telnet localhost adb_port不工作
- 12. 运行Vagrant领事:端口转发从客人到主机不能在Mac OS X上工作
- 13. 端口转发不起作用
- 14. 码头端口转发不起作用
- 15. 无用端口转发不起作用
- 16. iptables centOS端口转发不起作用
- 17. Vagrant - 专用网络端口转发行为
- 18. Vagrant无法转发此VM上的指定端口
- 19. 一些端口转发不工作的无业游民
- 20. 流浪汉端口转发不工作w8
- 21. 端口转发
- 22. HTTPS端口不工作的2083端口
- 23. VirtualBox的端口转发在Windows 7无法在Windows 7工作
- 24. vagrant INIT工程,vagrant UP - 不起作用
- 25. 从主机端口80到VirtualBox端口80的端口转发不起作用
- 26. Skype如何在没有端口转发的情况下工作?
- 27. XAMPP Tomcat端口不工作
- 28. 端口转发搬运工-组成
- 29. Laravel + Homestead + Vagrant不工作
- 30. vagrant up不开始工作
当我试图访问它使加载页面,并显示服务器未找到!我使用:http:// localhost:8080/index.html –
你有什么东西在虚拟机端口80上运行?尝试与http://127.0.0.1:8080/index.html –
对不起,我没有安装任何其他程序使用端口80.我也尝试127.0.0.1.:8080/index.html,但仍然不工作 –