2013-10-27 22:42:01
来 源
kejihao
Linux Apache配置
这里分享一下Apache服务器常用的配置代码,希望对于初学Apache服务器相关的朋友有帮助,更多Apache安装、配置、报错处理等资源请本站内搜索。
打开Apache下的conf文件夹,修改“httpd.conf”这个配置文件

默认路径如:C:Program FilesApache Software FoundationApache2.2conf

1、修改主目录

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

<Directory "D:websitemakednew_popx.us">

DocumentRoot "D:websitemakednew_popx.us"

2、修改首页文件

<IfModule dir_module>

DirectoryIndex index.html index.htm index.shtml

</IfModule>

3、增加虚拟目录

在 httpd.conf 的 alias_module 下增加一别名定义项,

如:Alias "/gg" "D:websitegg",即可定义虚拟目录。

/gg 是网页的目录名称

"D:websitegg" 是网页文件的物理路径

Alias "/gg" "D:websitegg"

<Directory "D:websitegg">

Options FollowSymLinks

AllowOverride None

order allow,deny

Allow from all

</Directory>

4、禁止目录访问

<Directory "D:websitemakedggedison">

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”

2、要保证 Listen 80

3、然后写入下面的代码

NameVirtualHost *:80

<VirtualHost *:80>

ServerName www.429006.com

DocumentRoot "D:websitegg"

</VirtualHost>

<VirtualHost *:80>

ServerName 1.429006.com

DocumentRoot "D:websitefirefox"

</VirtualHost>

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

6、虚拟主机权限设置

<Directory "虚拟主机网站目录">

Options Indexes FollowSymLinks

AllowOverride None

order allow,deny

Allow from all

</Directory>

声明: 此文观点不代表本站立场;转载须要保留原文链接;版权疑问请联系我们。