【Wamp】局域网设备访问WampServer | 使用域名访问Wamp | Wamp配置HTTPS

局域网设备访问WampServer

参考:https://www.jianshu.com/p/d431a845e5cb

修改Apache的httpd.conf文件
D:\Academic\Wamp\program\bin\apache\apache2.4.54.2\conf\httpd.conf

搜索 Require local 和Require all denied,改为Require all granted

<Directory />
    AllowOverride none
    # Require all denied
    Require all granted
</Directory>
    #
    # Controls who can get stuff from this server.
    #
#   Don't modify this line - Instead modify Require of VirtualHost in httpd-vhost.conf
    # Require local
    Require all granted
<Files ".ht*">
    # Require all denied
    Require all granted
</Files>
<Directory "${SRVROOT}/cgi-bin">
    AllowOverride None
    Options None
    Require all granted
</Directory>

修改Apache的httpd-vhosts.conf文件
D:\Academic\Wamp\program\bin\apache\apache2.4.54.2\conf\extra\httpd-vhosts.conf

  <Directory "${INSTALL_DIR}/www/">
    Options +Indexes +Includes +FollowSymLinks +MultiViews
    AllowOverride All
    # Require local
    Require all granted
  </Directory>

重启WampServer

设置Windows防火墙
在这里插入图片描述
在这里插入图片描述
这时本机应该能访问localhost
在这里插入图片描述
默认的根目录是在Wamp安装路径的WWW子文件夹
D:\Academic\Wamp\program\www

查看本机IP
在这里插入图片描述
同一局域网内的设备访问

同一WiFi下的手机访问:
http://192.168.31.208

图片名称

局域网设备使用域名访问WampServer

参考:https://www.freebasic.cn/p/2436.html
这里借助小米路由器实现

所使用的路由器型号是小米路由器AX1500(据客服说这是目前支持自定义hosts的最便宜的路由器)

将手机连接至小米路由器,打开米家app
在这里插入图片描述
将wamp所在主机的IP映射到想要的域名

在这里插入图片描述

然后局域网内的手机就可通过域名访问wamp
http://www.attackgoofish.com

在这里插入图片描述

Wamp配置HTTPS

参考:
https://blog.csdn.net/weixin_38336920/article/details/83309481
https://juejin.cn/post/7080419291308228644

检查端口

先检查443端口是否被占用
powershell输入

Get-Process -Id (Get-NetTCPConnection -LocalPort 443).OwningProcess

在这里插入图片描述

发现443端口已经被vmware占用,所以wamp改用4443端口

openssl生成公私钥

cmd下切换到 D:\Academic\Wamp\program\bin\apache\apache2.4.54.2\bin

依次执行

openssl genrsa -aes256 -out private.key 2048
openssl genrsa -aes256 -out private.key 2048
openssl req -new -x509 -nodes -sha1 -key private.key -out certificate.crt -days 36500 -config D:\Academic\Wamp\program\bin\apache\apache2.4.54.2\conf\openssl.cnf

其中第一条命令要求输入口令,记住该口令,第二条命令会用到
第三条命令要求输入公钥证书的CN等信息,其中Common Name我输入的是想用到的域名www.attackgoofish.com
在这里插入图片描述

执行结束后会在 D:\Academic\Wamp\program\bin\apache\apache2.4.54.2\bin 目录下生成 certificate.crt 和 private.key 两个文件,将这两个文件复制到 D:\Academic\Wamp\program\bin\apache\apache2.4.54.2\bin 新创建的key文件夹

在这里插入图片描述

修改配置

修改httpd.conf

位于D:\Academic\Wamp\program\bin\apache\apache2.4.54.2\conf

将以下内容前的#去掉

Include conf/extra/httpd-ssl.conf
LoadModule ssl_module modules/mod_ssl.so
LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
修改httpd-ssl.conf

记得使用的是4443端口

Listen 4443

SSLProtocol all -SSLv3
SSLProxyProtocol all -SSLv3

<VirtualHost _default_:4443>

DocumentRoot "D:/Academic/Wamp/program/www"
ServerName localhost:4443
ServerAdmin ziyiz@localhost
ErrorLog "D:/Academic/Wamp/program/bin/apache/apache2.4.54.2/logs/error.log"
TransferLog "D:/Academic/Wamp/program/bin/apache/apache2.4.54.2/logs/access.log"

SSLEngine on

SSLCertificateFile "conf/key/certificate.crt"

SSLCertificateKeyFile "conf/key/private.key"

<FilesMatch "\.(cgi|shtml|phtml|php)$">
    SSLOptions +StdEnvVars
</FilesMatch>
<Directory "${SRVROOT}/cgi-bin">
    SSLOptions +StdEnvVars
</Directory>

CustomLog "${SRVROOT}/logs/ssl_request.log" \
          "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"

</VirtualHost> 
修改httpd-vhosts.conf

位于D:\Academic\Wamp\program\bin\apache\apache2.4.54.2\conf\extra
增加以下内容

<VirtualHost *:4443>
  ServerName localhost
  ServerAlias localhost
  DocumentRoot "${INSTALL_DIR}/www"
  SSLEngine on
  SSLCertificateFile "conf/key/certificate.crt"
  SSLCertificateKeyFile "conf/key/private.key"  
</VirtualHost>

然后重启wamp

iPhone访问测试

自己生成的证书,iPhone可能不认,需要将证书 “certificate.crt” 导入描述文件
导入到iPhone之后,点击crt文件,将其加载至描述文件
在这里插入图片描述
然后安装描述文件
在这里插入图片描述

使用手机访问https://www.attackgoofish.com

在这里插入图片描述

相关推荐

  1. HTTP访问某个域名详细过程】

    2024-07-13 04:44:02       28 阅读
  2. 使用Spring Boot和mkcert解决本地及局域网HTTPS访问

    2024-07-13 04:44:02       27 阅读
  3. nginx怎么配置https访问

    2024-07-13 04:44:02       29 阅读
  4. 关于配置SSL,但是无法使用https访问的问题

    2024-07-13 04:44:02       32 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-13 04:44:02       66 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-13 04:44:02       70 阅读
  3. 在Django里面运行非项目文件

    2024-07-13 04:44:02       57 阅读
  4. Python语言-面向对象

    2024-07-13 04:44:02       68 阅读

热门阅读

  1. UE5 04-重新加载当前场景

    2024-07-13 04:44:02       24 阅读
  2. 【泛型】学习笔记

    2024-07-13 04:44:02       28 阅读
  3. python之修饰器介绍及示例

    2024-07-13 04:44:02       20 阅读
  4. 力扣1717.删除子字符串的最大得分

    2024-07-13 04:44:02       27 阅读
  5. 说一下你对dom驱动和数据驱动的理解

    2024-07-13 04:44:02       24 阅读
  6. GESP CCF C++ 一级认证真题 2024年6月

    2024-07-13 04:44:02       28 阅读