xampp多站点配置,最简洁方式

本文介绍如何使用XAMPP设置多个虚拟主机,通过在httpd-vhosts.conf文件中添加配置来实现不同项目的本地测试,无需修改hosts文件。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


首先,下载安装官方最新版本的xampp,地址: 点击

安装成功后,运行软件,点击Explorer.


会打开软件的安装目录,选择.\apache\conf\extra\httpd-vhosts.conf  ,打开。


添加如下内容:



<VirtualHost 127.0.0.2:80>
    ServerAdmin "127.0.0.2:80"  
    DocumentRoot "E:/wwwroot/xxx"
    ServerName 127.0.0.2
    ErrorLog "logs/xxx.log"
    CustomLog "logs/xxx.log" combined
</VirtualHost> 

DocumentRoot "E:/wwwroot"
<Directory "E:/wwwroot">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.4/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks Includes ExecCGI

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   AllowOverride FileInfo AuthConfig Limit
    #
    AllowOverride All

    #
    # Controls who can get stuff from this server.
    #
    Require all granted
</Directory>

,之后依次添加127.0.0.3,127.0.0.4,就直接复制

<VirtualHost 127.0.0.3:80>
    ServerAdmin "127.0.0.3:80"  
    DocumentRoot "E:/wwwroot/yyy"
    ServerName 127.0.0.3
    ErrorLog "logs/yyy.log"
    CustomLog "logs/yyy.log" combined
</VirtualHost> 

比较简单,而且不用再修改hosts文件了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值