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

来源:互联网 发布:linux 创建编辑c文件 编辑:程序博客网 时间:2024/05/21 22:50
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
原创粉丝点击