轉載文章,親試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>