天翼云服务器上Wamp无法外网访问

发布时间 2023-06-19 12:29:25作者: 海乐学习

在天翼云主机 上安装的Wamp默认是无法外网访问的

需要改以下四个地方

一、wamp 在  httpd.conf 中改 允许外网访问

二、wamp 在  httpd.conf 中改 80端口 改为 81  (80端口需要备案)

三、在天翼云安全组 的 入方向规则 中加入 允许  Tcp  81端口  访问

四、本地服务器的防火墙 配置81端口的入站规则 (当然也可以直接关闭防火墙)

具体方法如下

一、wamp 在  httpd.conf 中改 允许外网访问

在 httpd.conf 文件中

apache2.2 及之前版本

加入语句  Allow from all

例:

Order Deny,Allow
Deny from all
Allow from 127.0.0.1
Allow from all

apache2.4 之后的版本

加入语句  Require all granted

例:

    AllowOverride all

    #
    # Controls who can get stuff from this server.
    #

#   onlineoffline tag - don't remove

    Options +Indexes +Includes +FollowSymLinks +MultiViews
    AllowOverride All
    Require local
      
    Require all granted 

 
</Directory>

以 wamp 2.5 为例 正确的配置方法是:

打开..\wamp\bin\apache\apache2.4.9\conf 文件夹,用记事本编辑里面的文件 httpd.conf

找到  <Directory "d:/wamp/www/">     注:这个目录根据 wamp安装目录而定

在 Require all granted 下面, 添加一行 Require all granted ,保存,然后重启 wamp 服务,即可。

二、wamp 在  httpd.conf 中改 80端口 改为 81  (80端口需要备案)

这几处的80改为81

以 wamp 2.5 为例 

# Change this to Listen on specific IP addresses as shown below to 
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 12.34.56.78:80
Listen 0.0.0.0:81
Listen [::0]:81
#
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
ServerName localhost:81

三、在天翼云安全组 的 入方向规则 中加入 允许  Tcp  81端口  访问

方法一

选择实例

 选择安全组,点击  向下  箭头

 添加规则

 加入 81 端口

方法二

1.虚拟私有云

 

2.访问控制中的安全组

确认使用的安全组名称 与 要修改的 安全组 名称一致

 3、加入 允许 81 端口 访问

四、本地服务器的防火墙 配置81端口的入站规则 (当然也可以直接关闭防火墙)

依次打开:控制面板–Windows Defender防火墙–高级设置–入站规则–右侧的新建规则,

在新建入站规则中依次选择:端口–TCP 特定本地端口81(或apache中设置的开放端口)–下一步后添加个规则名称即可。