Windows环境下PHP多虚拟机设置、Apache+php+mysql

1.首先在你的系统盘下C:/Windows/System32/drivers/etc找到hosts文件,用记事本打开如下:

# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

# localhost name resolution is handled within DNS itself.
 127.0.0.1       localhost
# ::1             localhost
 127.0.0.1       www.youdomain.com
其中www.youdomain.com为你的虚拟主机

2.在你的apache下的httpd.conf下添加Include conf/extra/vhosts.conf,再在extra文件夹下写一下vhost.conf文件,如下:

NameVirtualHost 127.0.0.1:80

<VirtualHost www.youdomain.com:80>
  ServerName www.youdomain.com
  DocumentRoot "E:/youdomain.com/document_root"
 
  <Directory "E:/youdomain.com/document_root">
    Options Indexes FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all 
  </Directory>

</VirtualHost>

需要开启httpd.conf的LoadModule rewrite_module modules/mod_rewrite.so

重启apache,这样就OK了。

不过虚拟主机是目录式的,如要为index.php为导向转接,(所有的文件都通过mod_rewrite发送到这个文件)可在E:/youdomain.com/document_root添加文件内容为:

RewriteEngine on
RewriteRule !/.(js|gif|jpg|png|css)$ index.php
文件名是.htaccess(注意这就是扩展名)。

更多参考请baidu,google相关httpd.conf .htaccess的设置说明。


xampp Apache Access forbidden! Error 403 解决方法

  (2013-06-14 11:29:00)
标签: 

xampp

 

apache

 

403

 

access

 

forbidden

分类: Apache
今天下载了最新的xampp,配置了一个虚拟主机,一直在报错,Access forbidden! Error 403 
xampp <wbr>Apache <wbr>Access <wbr>forbidden! <wbr>Error <wbr>403 <wbr>解决方法

这很明显是服务器不允许访问文件,但是我的虚拟主机配置如下:
DocumentRoot "D:/work/test"
ServerName test
Options None  
Order allow,deny  
Allow from all  
竟然还是访问不成功,折腾了一会终于发现在httpd.conf里面有这个配置。
xampp <wbr>Apache <wbr>Access <wbr>forbidden! <wbr>Error <wbr>403 <wbr>解决方法

把这个改成如下配置,重启apache就行了。
xampp <wbr>Apache <wbr>Access <wbr>forbidden! <wbr>Error <wbr>403 <wbr>解决方法

我想这应该是xampp里面关于虚拟主机配置的一个bug,因为我在单个的虚拟主机里面已经有了Allow from all   这个配置,根据软件设计的思想,应该是局部的配置优先级要大于全局的设置,这个还有待改进。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值