局域网设备访问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
c
<Directory />
AllowOverride none
# Require all denied
Require all granted
</Directory>
c
#
# 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
c
<Files ".ht*">
# Require all denied
Require all granted
</Files>
c
<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
c
<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下的手机访问:
局域网设备使用域名访问WampServer
参考:https://www.freebasic.cn/p/2436.html
这里借助小米路由器实现
所使用的路由器型号是小米路由器AX1500(据客服说这是目前支持自定义hosts的最便宜的路由器)
将手机连接至小米路由器,打开米家app
将wamp所在主机的IP映射到想要的域名
然后局域网内的手机就可通过域名访问wamp
Wamp配置HTTPS
参考:
https://blog.csdn.net/weixin_38336920/article/details/83309481
https://juejin.cn/post/7080419291308228644
检查端口
先检查443端口是否被占用
powershell输入
shell
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
依次执行
c
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
将以下内容前的#去掉
c
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端口
c
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
增加以下内容
c
<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文件,将其加载至描述文件
然后安装描述文件