主机访问虚拟机中linux上的web服务

centos上使用的httpd服务是运行在VM中

网络:centos使用的是静态地址192.168.137.2  虚拟机使用的NAT连接方式,Vmnet8的地址是192.168.137.1,并将本地连接共享给Vmnet8,以便于centos使用

在httpd下下config文件中的http.conf  /etc/httpd/config/http.config 文件中 添加LISTEN 192.168.137.2:80条目

启动service httpd

此时centos中的浏览器应该就可以使用192.168.137.2了

但是,主机不能访问

继续添加防火墙规则

[root@localhost sbin]# iptables -I INPUT -p tcp --dport 80 -j ACCEPT
[root@localhost sbin]# /etc/rc.d/init.d/iptables save
iptables:将防火墙规则保存到 /etc/sysconfig/iptables:     [确定]
[root@localhost sbin]# /etc/init.d/ip
ip6tables  iptables
[root@localhost sbin]# /etc/init.d/iptables restart
iptables:清除防火墙规则:                                 [确定]
iptables:将链设置为政策 ACCEPT:filter                    [确定]
iptables:正在卸载模块:                                   [确定]
iptables:应用防火墙规则:                                 [确定]

此时可以在主机浏览器中访问虚拟机中的web服务了

转载于:https://www.cnblogs.com/qingsongwang/p/centos-web-service-on-vmware.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值