PHPStudy设置局域网访问

  • A+
所属分类:网络技术

PHPStudy是一款轻量级PHP服务器,搭建环境迅速。但是与XAMPP之类服务器不同的是,PHPStudy默认只有本机才能设置域名、访问网站。需要更改vhost.conf中的文件,才可以使得内网可以访问。

打开PHPStudy设置,通过“打开配置文件”,打开vhosts-ini.con这个文件,打开,找到如下代码:

<VirtualHost *:80>
DocumentRoot "E:\phpstudy\PHPTutorial\WWW\public"
ServerName test.com
ServerAlias test.com

其中,test.com指的是你设置的本机访问的域名。这里没有设置局域网访问,所以局域网访问过去,看到的是类似FTP列表的形式。将这段代码改成:

<VirtualHost *:80>
DocumentRoot "E:\phpstudy\PHPTutorial\WWW\public"
ServerName test.com
ServerName 127.0.0.1
ServerName 192.168.0.102
ServerAlias test.com

其中,192.168.0.102是我本机的IP地址。即在ServerName里,将本机的IP地址和localhost添加到服务器栏。设置完成后,局域网内其他机器打开浏览器,输入192.168.0.102,即可访问你本机上的test.com

weinxin
独角兽驿站
公众号

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: