zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    PHP中关于字符串的连接
    好用的FireFox(FF)插件
    Scripted Operation
    Scripted device
    chgrp chown
    wait_for_devices
    mysql create user
    mysql
    create user mysql
    Inserting/Removing shutters and filters
  • 原文地址:https://www.cnblogs.com/baby123/p/11326611.html
Copyright © 2011-2022 走看看