如何配置xampp的虚拟主机

发布时间:2025-11-06 点击:3
如何配置xampp的虚拟主机?xampp有时候你需要一些顶级域名访问方式来访问你本地的项目也就是虚拟主机配置,这时候就需要配置虚拟主机,给你的目录绑定一个域名,实现多域名绑定访问。
一、修改httpd.conf
文件目录 xampp => apache =>conf => httpd.conf
1.在文件内搜索 关键字“httpd-vhosts.conf”,找到如下字段
# virtual hosts include conf/extra/httpd-vhosts.conf//确保此段开头没有#2.在文件内搜索关键字“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//确保此处路径是你要访问的项目的根路径 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>//设置访问的ip ##serveradmin webmaster@dummy-host2.example.com documentroot d:/www//你的项目文件目录 servername testname.dev//此项目的名称 ##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//你的项目文件目录 servername testname.dev//此项目的名称,通过此名称来访问项目,还需配置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在进行访问
西部数码虚拟主机入口:https://www.west.cn/services/webhosting/


作为一个合格的域名抢注者,易名这个工具你知道吗?
阿里云服务器便宜购买教程
php如何实现ios推送
租用服务器好还是放云平台好
备案网站无法打开-域名及账户问题
云服务器一开始没有备案也能用
我重新提交了尽快核实一下
华为云服务器建了一个网站如何发布出去