转载文章,亲试php
Apache2.4之后的版本编译依赖apr,因此,编译以前须要先安装apr及apr-util。html
编译参数只是一个参考做用,这个参数是我日常使用的,具体工做中的需求仍是要区别对待的web
一些注解:
--enable-so 启动模块动态装卸载
--enable-ssl 编译ssl模块
--enable-cgi 支持cgi机制(可以让静态web服务器可以解析动态请求的一个协议)
--enable-rewrite 支持url重写
--with-zlib 支持zlib压缩
--with-pcre 支持正则表达式
--with-apr=/usr/local/apr 指明依赖的apr所在目录
--with-apr-util=/usr/local/apr-util/ 指明依赖的apr-util所在的目录
--enable-mpms-shared=all 以共享方式编译的模块
--with-mpm=prefork 指明httpd的工做方式为prefork
---------------------
正则表达式
若是该虚拟目录下没有 index.html,浏览器也会显示该虚拟目录的目录结构,列出该虚拟目录下的文件和子目录。apache
如何禁止 Apache 显示目录列表呢?浏览器
要禁止 Apache 显示目录结构列表,只需将 Option 中的 Indexes 去掉便可。服务器
好比咱们看看一个目录的目录配置:ide
<Directory "D:/Apa/blabla">
Options Indexes FollowSymLinks #---------->Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
你只须要将上面代码中的 Indexes 去掉,就能够禁止 Apache 显示该目录结构。用户就不会看到该目录下的文件和子目录列表了。网站
Indexes 的做用就是当该目录下没有 index.html 文件时,就显示目录结构,去掉 Indexes,Apache 就不会显示该目录的列表了。this
第二种方法
解决办法:
一、编辑httpd.conf文件
vi ./conf/httpd.conf
找到以下内容:
?BR> <Directory “C:/Program Files/Apache2.2/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>
……
在Options Indexes FollowSymLinks在Indexes前面加上 – 符号。
即: Options -Indexes FollowSymLinks
【备注:在Indexes前,加 + 表明容许目录浏览;加 – 表明禁止目录浏览。】
这样的话就属于整个Apache禁止目录浏览了。
若是是在虚拟主机中,只要增长以下信息就行:
<Directory “D:test”>
Options -Indexes FollowSymLinks
AllowOverride None
Order deny,allow
Allow from all
</Directory>
这样的话就禁止在test工程下进行目录浏览。
备注: 切记莫把“Allow from all”改为 “Deny from all”,不然,整个网站都不能被打开。
<Finished>
还有一种方法:
能够在根目录的 .htaccess 文件中输入
<Files *>
Options -Indexes
</Files>
就能够阻止Apache 将目录结构列表出来。
要想列出上述虚拟目录的目录结构,前提是须要开启下面的模块功能,不然重启httpd服务报错,
并且若是在ifModule模块中的内容前面加#号不表示注释,须要放到要执行参数以后,不然也无
法列出虚拟目录的目录结构。
<IfModule dir_module>
DirectoryIndex index.html
#DirectoryIndex index.html index.php
</IfModule>