发布于 2016-02-05 01:53:58 | 204 次阅读 | 评论: 1 | 来源: 网友投递

这里有新鲜出炉的精品教程,程序狗速度看过来!

Apache Web服务器

Apache是世界使用排名第一的Web服务器软件。它可以运行在几乎所有广泛使用的计算机平台上,由于其跨平台和安全性被广泛使用,是最流行的Web服务器端软件。


在windows和RH都碰到过,只要把主目录指到其他地方后就出现权限不够的403提示,郁闷了好久。
后来发现,原来又是Apache没配置 好,是apache的mod_authz_host模块在起控制作用。
1.如果不启用vhosts
只需修改 httpd.conf
默认Directory节如下,注意红色部分,表示目录/usr/local/apache/htdocs允许所有 主机访问
 
<Directory "/usr/local/apache/htdocs"> 
# 
# 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.2/mod/core.html#options 
# for more information. 
# 
#Options Indexes FollowSymLinks 
# 
# AllowOverride controls what directives may be placed in .htaccess files. 
# It can be "All", "None", or any combination of the keywords: 
# Options FileInfo AuthConfig Limit 
# 
AllowOverride None 
# 
# Controls who can get stuff from this server. 
# 
Order allow,deny 
Allow from all 
</Directory> 

由于主目录被指到别的地方了,所以将蓝色部分/usr/local/apache/htdocs换成你新的主目录就OK了。
2.启用vhosts
启 用vhosts的话,你就可以不作上面的修改了,因为VirtualHost可以单独配置这个节的属性,所以我们在VirtualHost这个节里配置的 话就更方便了,下面的配置中,我把我的网站放在/var/vhosts/www.test.cn下。
 
/usr/local/apache/conf/extra/httpd-vhosts.conf 
<VirtualHost *:80> 
<Directory "/var/vhosts/www.test.cn" > 
#Deny from all 
Allow from all 
</Directory> 
DocumentRoot "/var/vhosts/www.test.cn" 
ServerName www.test.cn 
</VirtualHost> 

如果把Deny from all的注释去掉,那么服务器就会拒绝所有访问(和我们刚开始把主目录移动到htdocs外而没做任何配置修改时一样,哈哈)
补充一点:
如果你是写个index.php放在目录下测试,可要注意了,记得加上默认主页index.php
DirectoryIndex index.html index.php

最新网友评论  共有(1)条评论 发布评论 返回顶部
tjlnazm 发布于2016-08-10 01:18:15
终于他妈的解决了,花了老子半天时间.
支持(0)  反对(0)  回复

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务