解决xampp 外网访问不了

装完xampp5.6 后发现局域网(外网)不能访问!

这个问题困扰我很久,在网上找,修改http.conf   http-xampp.conf 等都没效果‘

而且网上大部分解决办法,包括官网上写的也是 

<LocationMatch "^/(?i:(?:xampp|security|licenses|phpmyadmin|webalizer|server-status|server-info))">
    Order deny,allow
  #Deny from all
    Allow from 127.0.0.0/8
    ErrorDocument 403 /error/HTTP_XAMPP_FORBIDDEN.html.var
</LocationMatch>

我真想骂人! 因为这些文件根本就没有什么<locationMatch></locationMatch>好吗?

原因我想是 很久之前的版本的xampp了! 看来更新的太慢了,现在人都不解决这个问题了。

后来找到一个和我一样问题的。http://blog.youkuaiyun.com/Yade_Lei/article/details/52081907

确实应该考虑防火墙的设置

方法1.界面配置,在CentOS7 ->杂项->防火墙软 设置 但是看起来比较复杂,可以参考http://blog.youkuaiyun.com/xlgen157387/article/details/52672988

在 CentOS 7
暫時開放 ftp 服務
firewall-cmd --add-service=ftp

永久開放 ftp 服務
firewall-cmd --add-service=ftp --permanent
永久關閉
firewall-cmd --remove-service=ftp --permanent
success

讓設定生效
systemctl restart firewalld

檢視設定是否生效
iptables -L -n | grep 21
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:21 ctstate NEW

檢查防火牆狀態
firewall-cmd --state
running

systemctl stop firewalld
firewall-cmd --state
not running


firewall-cmd --list-all
public (default)
  interfaces:
  sources:
  services: dhcpv6-client ftp ssh
  ports:
  masquerade: no
  forward-ports:
  icmp-blocks:
  rich rules:

在 FirewallD 的服務名稱
firewall-cmd --get-service
amanda-client bacula bacula-client dhcp dhcpv6 dhcpv6-client dns ftp high-availability http https imaps ipp ipp-client ipsec kerberos kpasswd ldap ldaps libvirt libvirt-tls mdns mountd ms-wbt mysql nfs ntp openvpn pmcd pmproxy pmwebapi pmwebapis pop3s postgresql proxy-dhcp radius rpc-bind samba samba-client smtp ssh telnet tftp tftp-client transmission-client vnc-server wbem-https

查詢服務的啟用狀態
firewall-cmd --query-service ftp
yes
firewall-cmd --query-service ssh
yes
firewall-cmd --query-service samba
no
firewall-cmd --query-service http
no

自行加入要開放的 Port
firewall-cmd --add-port=3128/tcp
firewall-cmd --list-all
public (default)
  interfaces:
  sources:
  services: dhcpv6-client ftp ssh
  ports: 3128/tcp
  masquerade: no
  forward-ports:
  icmp-blocks:

  rich rules:

 

总结:基本上2种指令就OK了

firewall-cmd --add-service=

firewall-cmd --add-ports=


方法2:配置iptables ,

如果没有装运行:yum install iptables-services

可以看防火墙状态: systemctl status iptables.service

可以看防火墙是否是活动的。


解决方法来了:

执行:gedit   /etc/sysconfig/iptables  

添加命令:

#SSH
-A INPUT -p tcp --dport 22 -j ACCEPT
#HTTP
-A INPUT -p tcp --dport 80 -j ACCEPT
-A INPUT -p tcp --dport 8080 -j ACCEPT
#HTTPS
-A INPUT -p tcp --dport 443 -j ACCEPT
#POP3
-A INPUT -p tcp --dport 110 -j ACCEPT
#SMTP
-A INPUT -p tcp --dport 25 -j ACCEPT
#FTP
-A INPUT -p tcp --dport 21 -j ACCEPT
-A INPUT -p tcp --dport 20 -j ACCEPT
#DNS
-A INPUT -p tcp --dport 53 -j ACCEPT

执行:systemctrl restart iptables.service 启动防火墙端口

4、添加开机自启动,默认不会 开启启动

执行:systemctl enable iptables.service#设置防火墙开机启动

但是开机后:查看是否启动: systemctl status iptables.service

显示的是enable 但是 Active :inactive(dead)

表示未成功启动,原因是没有屏蔽firewalld防火墙,执行

systemctl stop firewalld
systemctl mask firewalld
解决!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值