如何配置xampp的虛擬主機(jī)?xampp有時(shí)候你需要一些頂級(jí)域名訪問方式來訪問你本地的項(xiàng)目也就是虛擬主機(jī)配置,這時(shí)候就需要配置虛擬主機(jī),給你的目錄綁定一個(gè)域名,實(shí)現(xiàn)多域名綁定訪問。
一、修改httpd.conf
文件目錄 xampp => apache =>conf => httpd.conf
1.在文件內(nèi)搜索 關(guān)鍵字“httpd-vhosts.conf”,找到如下字段
# virtual hosts
include conf/extra/httpd-vhosts.conf//確保此段開頭沒有#2.在文件內(nèi)搜索關(guān)鍵字“allowoverride all”,找到如下字段
<directory d:/xampp/cgi-bin>
allowoverride all
options none
require all granted
</directory>
//修改為
<directory d:/xampp/cgi-bin>
options indexes followsymlinks includes execcgi
allowoverride all
order allow,deny
allow from all
</directory>3.搜索字段“documentroot”,如下
documentroot d:/xampp/htdocs//確保此處路徑是你要訪問的項(xiàng)目的根路徑
ps:可以配置特定的根路徑,比如: documentroot d:/www二、修改httpd-vhosts.conf
文件目錄 xampp => apache =>conf => extra => httpd-vhosts.conf
文件最后面可看到如下
##<virtualhost *:80>
##serveradmin webmaster@dummy-host2.example.com
##documentroot d:/xampp/htdocs/dummy-host2.example.com
##servername dummy-host2.example.com
##errorlog logs/dummy-host2.example.com-error.log
##customlog logs/dummy-host2.example.com-access.log common
##</virtualhost>1.用ip訪問
<virtualhost 127.0.0.5:80>//設(shè)置訪問的ip
##serveradmin webmaster@dummy-host2.example.com
documentroot d:/www//你的項(xiàng)目文件目錄
servername testname.dev//此項(xiàng)目的名稱
##errorlog logs/dummy-host2.example.com-error.log
##customlog logs/dummy-host2.example.com-access.log common
</virtualhost>2.用servername訪問
<virtualhost *:80>
##serveradmin webmaster@dummy-host2.example.com
documentroot d:/www//你的項(xiàng)目文件目錄
servername testname.dev//此項(xiàng)目的名稱,通過此名稱來訪問項(xiàng)目,還需配置hosts文件
##errorlog logs/dummy-host2.example.com-error.log
##customlog logs/dummy-host2.example.com-access.log common
</virtualhost>3.配置hosts文件
文件目錄 c:\windows\system32\drivers\etc\hosts
在文件中加入
127.0.0.1 testname.dev三、修改完記得重啟aphache在進(jìn)行訪問
西部數(shù)碼虛擬主機(jī)入口:https://www.west.cn/services/webhosting/