Apache顯示目錄列表及icons目錄的問題


今天想部署下開源項目pig,發現它的mysql需要5.7.8 +,為了能支持多個版本並且可以方便切換,所以選擇了phpstudy_pro

剛開始Apache不支持目錄訪問

修改配置

<VirtualHost _default_:80>
    DocumentRoot "D:/WWW"
    FcgidInitialEnv PHPRC "D:/phpstudy_pro/Extensions/php/php7.3.4nts"
    AddHandler fcgid-script .php
    FcgidWrapper "D:/phpstudy_pro/Extensions/php/php7.3.4nts/php-cgi.exe" .php
  <Directory "D:/WWW">
      Options Indexes FollowSymLinks ExecCGI
      AllowOverride All
      Order allow,deny
      Allow from all
     Require all granted
      DirectoryIndex index.php index.html
  </Directory>
</VirtualHost>

關鍵: Indexes顯示目錄

添加后發現

搜索了下Apache的配置目錄conf,發現在conf/original/extra/httpd-autoindex.conf,將下面的都注釋掉

#Alias /icons/ "${SRVROOT}/icons/"

#<Directory "${SRVROOT}/icons">
#    Options Indexes MultiViews
#    AllowOverride None
#    Require all granted
#</Directory>

#
# AddIcon* directives tell the server which icon to show for different
# files or filename extensions.  These are only displayed for
# FancyIndexed directories.
#
AddIconByEncoding (CMP,/icons/compressed.gif) x-compress x-gzip

#AddIconByType (TXT,/icons/text.gif) text/*
#AddIconByType (IMG,/icons/image2.gif) image/*
#AddIconByType (SND,/icons/sound2.gif) audio/*
#AddIconByType (VID,/icons/movie.gif) video/*

#AddIcon /icons/binary.gif .bin .exe
#AddIcon /icons/binhex.gif .hqx
#AddIcon /icons/tar.gif .tar
#AddIcon /icons/world2.gif .wrl .wrl.gz .vrml .vrm .iv
#AddIcon /icons/compressed.gif .Z .z .tgz .gz .zip
#AddIcon /icons/a.gif .ps .ai .eps
#AddIcon /icons/layout.gif .html .shtml .htm .pdf
#AddIcon /icons/text.gif .txt
#AddIcon /icons/c.gif .c
#AddIcon /icons/p.gif .pl .py
#AddIcon /icons/f.gif .for
#AddIcon /icons/dvi.gif .dvi
#AddIcon /icons/uuencoded.gif .uu
#AddIcon /icons/script.gif .conf .sh .shar .csh .ksh .tcl
#AddIcon /icons/tex.gif .tex
#AddIcon /icons/bomb.gif core

#AddIcon /icons/back.gif ..
#AddIcon /icons/hand.right.gif README
#AddIcon /icons/folder.gif ^^DIRECTORY^^
#AddIcon /icons/blank.gif ^^BLANKICON^^

 注:

  對於沒有進行安全配置的Apache服務器,默認情況可以用xxx.com/icons/的方式打開Apache目錄下的icons文件夾,並且會羅列出文件列表,這樣很不安全。

  所以對上面代碼進行注釋,可以增加安全性。

  當然也應該禁止Apache顯示目錄索引(只需將 Option 中的 Indexes 去掉即可),這里是為了方便本地使用才打開的

重啟Apache

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM