php学习笔记五:使用 xampp 部署多个站点

1: 用记事本打开C:/WINDOWS/system32/drivers/etc/hosts文件,配置如下:
127.0.0.1 phptest


2:修改 httpd-vhosts.conf 文件
用记事本打开C:\xampp\apache\conf\httpd.conf文件,
找到Include conf/extra/httpd-vhosts.conf,确认前面没有加#.


3:C:\xampp\apache\conf\extra\httpd-vhosts.conf,在此文件末尾添加如下内容:
#如果修改过端口号,需要把 80 改为已经修改的值(查找 Listen xxx 的设置,xxx为端口号)


#虚拟站点-begin
<VirtualHost *:8081>
    DocumentRoot "d:/xampp/htdocs/"
    ServerName localhost
</VirtualHost>


#phptest 也可以设置为 www.test.com 等
<VirtualHost *:8081>
    DocumentRoot "D:/WorkTest/Php"
    ServerName phptest
</VirtualHost>
#虚拟站点-end


4:C:\xampp\apache\conf\httpd.conf,在此文件末尾添加如下内容:


<Directory "D:/WorkTest/Php">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>


5:重启Apache服务。


6:访问测试(如果页面访问出现“Access forbidden!Error 403”错误继续往下看)
http://localhost:8081/
http://phptest:8081/


7:解决 Access forbidden!Error 403 问题
7.1 在 httpd.conf 里找到如下配置
#
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other 
# <Directory> blocks below.
#
<Directory />
    AllowOverride none
    Require all denied
</Directory>
7.2 修改为以下内容
#
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other 
# <Directory> blocks below.
#
<Directory />
    #AllowOverride none
    #Require all denied
Order deny,allow
Allow from all
</Directory>


8:重启Apache服务后,执行 步骤6 查看结果。











  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值