Apache安装常见配置

本文由守望者MS整理修改并完善

打开Apache下的conf文件夹,修改“httpd.conf”这个配置文件
默认路径如:C:\Program Files\Apache Software Foundation\Apache2.2\conf

1、修改主目录

将“<Directory " ">”和“DocumentRoot”这里修改一致,如

<Directory "D:\website\maked\new_popx.us">
DocumentRoot "D:\website\maked\new_popx.us" //如果你要一个apache配置多个web应该,这里DocumentRoot没必要和Directiry一样。
                                                                       //例如你可以将DocumentRoot设置为DocumentRoot "D:\website\maked\weibo"                                                                             //DocumentRoot "D:\website\maked\XXX"

2、修改首页文件

<IfModule dir_module>
     DirectoryIndex index.html index.htm index.shtml
</IfModule>


3、增加虚拟目录

在 httpd.conf 的 alias_module 下增加一别名定义项,
如:Alias "/gg" "D:\website\gg",即可定义虚拟目录。

/gg 是网页的目录名称
"D:\website\gg" 是网页文件的物理路径

Alias "/gg" "D:\website\gg"
<Directory "D:\website\gg">
Options FollowSymLinks
AllowOverride None
order allow,deny
Allow from all
</Directory>

4、禁止目录访问

<Directory "D:\website\maked\gg\edison">
Options Indexes FollowSymLinks
AllowOverride None
order allow,deny
Allow from all
</Directory>

将其中的“Options Indexes FollowSymLinks”取消,或者将其修改为“Options -Indexes FollowSymLinks”

5、虚拟主机配置

<Directory />
     Options FollowSymLinks
     AllowOverride None
     order deny,allow
     Deny from all
</Directory>

1、先将其中的“Deny from all”修改成“Allow from all”  //如果是一个apache配置多个web应用,在http.conf文件中只需要一个<Directory></Directory>即可
2、要保证 Listen 80
3、然后写入下面的代码

NameVirtualHost *:80

<VirtualHost *:80>
ServerName www.429006.com
DocumentRoot "D:\website\gg"
</VirtualHost>

<VirtualHost *:80>
ServerName 1.429006.com
DocumentRoot "D:\website\firefox"
</VirtualHost>

注意:其中的“NameVirtualHost *:80”不能丢,还有就是这里面的“*:80”是不能修改的,不要以为“*”是需要修改的,这里不能修改。

6、虚拟主机权限设置

<Directory "虚拟主机网站目录">
Options Indexes FollowSymLinks
AllowOverride None
order allow,deny
Allow from all
</Directory>

posted @ 2011-05-19 00:19  守望者MS  阅读(531)  评论(0编辑  收藏  举报