apache 虚拟主机配置

本文详细介绍了如何在Apache服务器上配置虚拟主机,包括修改httpd.conf文件以启用虚拟主机功能,以及在httpd-vhosts.conf中设置具体配置项,如ServerName、ServerAlias等。

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

原文: http://blog.youkuaiyun.com/ReadyYes/article/details/51038192
进入C:\Apache24\conf\httpd.conf
这里写图片描述
把那个“#”号去掉

进入C:\Apache24\conf\extra\httpd-vhosts.conf 配置如下

#*代表当前服务器的所有IP地址
<VirtualHost *:80>
    #主机名
    ServerName www.zy.com
    #主机别名 多个主机别名用空格分开
    ServerAlias zy.com xy.com
    ServerAdmin admin@zy.com

    DocumentRoot "E:/phptest"

    #Directory 中的路径要和DocumentRoot的路径一致,Directory配置访问权限

    <Directory "E:/phptest">
        Options Indexes FollowSymLinks
        #默认主页
        DirectoryIndex test.php
        #自定义后缀php处理 
        AddType application/x-httpd-php .php .ppp .phtml
        AllowOverride all
        Require all granted
    </Directory>


    #配置虚拟目录
    Alias /abc "E:/php100"
    #配置虚拟目录权限
    <Directory "E:/php100">
       Options Indexes FollowSymLinks
       AllowOverride all
       Require all granted
    </Directory>
    ErrorLog "logs/dummy-www.zy.com-error.log"
    CustomLog "logs/dummy-www.zy.com-access.log" common
</VirtualHost>



<VirtualHost *:80>

        DocumentRoot "C:\Apache24\htdocs"

        <Directory "C:\Apache24\htdocs">
            Options Indexes FollowSymLinks
            #默认主页
            DirectoryIndex index.html
            #自定义后缀php处理 
            AddType application/x-httpd-php .php .ppp .phtml
            AllowOverride all
            Require all granted
        </Directory>

        ServerName localhost

</VirtualHost>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值