溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

Apache安全配置之禁止目錄訪問的設(shè)置方法

發(fā)布時(shí)間:2020-08-08 11:18:49 來源:ITPUB博客 閱讀:353 作者:慕容鈺靈 欄目:建站服務(wù)器

這篇文章主要介紹了Apache禁止目錄訪問的配置方法,這是一個(gè)常見的、非常有必要的apache安全配置之一,需要的朋友可以參考下

在PHP網(wǎng)站開發(fā)中,為了讓網(wǎng)站目錄文件和程序代碼的安全考慮,我們必須對(duì)某些目錄或者文件的訪問權(quán)限進(jìn)行控制,來提高網(wǎng)站的安全,那么我們?cè)鯓觼韺?shí)現(xiàn)這種功能呢?這時(shí)候可以配置Apache來禁止網(wǎng)站以目錄的形式列出網(wǎng)站內(nèi)容。

在Apache中沒有配置禁止目錄訪問時(shí)候,當(dāng)你訪問 http://localhost  時(shí)會(huì)列出相關(guān)的目錄和文件列表,我們可以通過修改Apache配置文件httpd.conf來實(shí)現(xiàn)禁止列出目錄/文件列表,方法如下:

1、打開apache的配置文件“httpd.conf”

2、找到以下部分

復(fù)制代碼 代碼如下:<Directory />
Options Indexes
AllowOverride None
Order allow,deny
Allow from all
</Directory>
只需將Options Indexes修改為Options None即可。

注:根據(jù)PHP運(yùn)行環(huán)境安裝包的不同,Options Indexes也有可能是Options Indexes FollowSymLinkshttp://www.bbqmw.net/qm_bbqmbd/,一并改為Options None即可。

保存httpd.conf,重啟apache。如果此時(shí)不行,繼續(xù)修改下面的配置:
復(fù)制代碼 代碼如下:
<Directory "E:/web">
    #
    # 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 none
    #
    # 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>

如上:將里面紅色的部分,一并改過來就行了。

3、保存httpd.conf,并重啟Apache即可,此時(shí)再訪問 http://localhost  時(shí),如果沒有index.html或者index.php這些默認(rèn)的文件時(shí),就會(huì)報(bào)apache http 403 禁止訪問錯(cuò)誤信息:
復(fù)制代碼 代碼如下:Forbidden
You don't have permission to access / on this server.


向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請(qǐng)聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI