wamp配置局域网访问

背景

  • wampserver 3.1.7、Apache 2.4.37、PHP 7.2.14、MySql 5.7.24、thinkcmf 5.0
  • 没有测试环境,产品及UI想看页面效果
  • wampserver运行中
  • 我只是个渣渣前端orz

配置

1. httpd-vhosts.conf

项目运行的时候,点击wamp图标 => Apache => httpd-vhosts.conf

# Virtual Hosts
#

  ServerName localhost
  ServerAlias localhost
  DocumentRoot "${INSTALL_DIR}/www"
  
    Options +Indexes +Includes +FollowSymLinks +MultiViews
    AllowOverride All
    Require all granted // 改这里
  



#

    ServerName 项目名称
    DocumentRoot "f:/你的项目路径/public"
    
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
        Require all granted // 改这里
    

require后面的值可以是某个具体的局域网段等,具体可以自己搜索了解。我这里是允许了所有。

到这里其实局域网内访问只能到localhost你的管理页面,也就是这个:

wamp配置局域网访问_第1张图片

然后你点击你的某个项目,比如说test(your virtualhost => test)的时候,会报错说域名解析错误。这时候还差一步,我这里用了巧法,把localhost指向了我的项目。如果有大佬知道其实应该怎么搞的,麻烦指教谢谢。

# Virtual Hosts
#

  ServerName localhost
  ServerAlias localhost
  # 把localhost指向了我的项目
  DocumentRoot "f:/你的项目路径/public" 
  
    Options +Indexes +Includes +FollowSymLinks +MultiViews
    AllowOverride All
    Require all granted // 改这里
  

2. 关闭防火墙

其实网上的教程都是到上面就把事情做完了,但由于我在弄的时候,先是出现403,后面又说域名解析错误。在403的时候我就去把防火墙关掉了。域名解析错误的时候我就上面那样把Localhost指向我的项目,然后就可以局域网访问我的本地项目了。

题外话

另外记录一个hack,想登录thinkcmf的后台的时候,老是说我密码错误,但同事明明就能登录上去。
后来hack一下,把这里改了一下,绕过密码校验,成功登录上去了:)
wamp配置局域网访问_第2张图片

你可能感兴趣的:(wampserver,php,前端)