昨天配置那个wamp,但是内网通过ip不能访问,修改了配置文件还是不能用,修改了端口还是不能用,因为我用了路由器,需要端口映射,但是设置了路由器端口映射之后还是不能用,于是今天直接卸载了wamp,重新装了xampp,还是出现了一些问题,不过终于还是解决了。
首先是端口转发问题,因为我用了路由器,路由器的ip为172.16.150.129,然后分配给电脑的ip是192.168.31.2,所以用192.168.31.2可以正常访问xampp
但是用172.16.150.129就访问不了
原因是它访问的是我的路由器,我们需要在路由器上设置端口转发,转发到192.168.31.2上,即我的电脑。
端口转发的定义:端口转发是转发一个网络端口从一个网络节点到另一个网络节点的行为,其使一个外部用户从外部经过一个被激活的NAT路由器到达一个在私有内部IP地址(局域网内部)上的一个端口。
就拿我这个为例子,我用的是小米路由器,在浏览器中打开192.168.31.1,选择高级设置,端口转发

在端口转发规则列表中,点击添加规则

名称随你喜欢,
协议选择tcp就可以了,也可以选择tcp和udp,
外部端口填写你提供给外部访问的端口,然后外部访问时为:路由器ip地址+外部端口,例如:172.16.150.129:8080
内部ip地址填写路由器分配给你电脑的ip地址
最后填写映射到你电脑上的端口,因为我apache的端口设置为8181,所以这里设置为8181
点击添加,再点击保存并生效

然后再访问就可以了

进入phpMyAdmin提示使用配置文件中定义的控制用户连接失败问题

先打开phpMyAdmin目录,找到config.inc.php,打开它
找到
$cfg['Servers'][$i]['controluser'] = 'pma';
$cfg['Servers'][$i]['controlpass'] = '******';
把controluser改为你自己的,即改为跟上面user一样,比如我这个,把pma改为root
密码也一样改为你自己的
保存重新打开phpMyAdmin就可以了
局域网不能访问phpMyAdmin问题
配置了xampp后,通过127.0.0.1可以正常访问phpmyadmin

但是通过ip访问出现了这样的情况:

解决方法:
打开xampp界面,依次选择Apache->Config->Apache(httpd-xampp-conf)

也可以点击Explorer,打开目录,打开apache目录->打开conf目录->打开extra目录,找到httpd-xampp.conf文件,右键有编辑器打开


找到以下信息:
<Directory "F:/xampp/phpMyAdmin">
AllowOverride AuthConfig
Require local
ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
</Directory>
把Require local注释掉,即
<Directory "F:/xampp/phpMyAdmin">
AllowOverride AuthConfig
#Require local
ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
</Directory>
然后保存,重启apache,就可以正常访问了
