禁止解析PHP、限制user_agent、php相關配置

11.28 限定某個目錄禁止解析php

  1. 核心配置文件內容
<Directory /data/wwwroot/www.123.com/upload>
        php_admin_flag engine off
        <FilesMatch (.*)/.php(.*)>
        Order allow,deny
        Deny from all
        </FilesMatch>
    </Directory>
  1. curl測試時直接返回了php源代碼,並未解析
  2. 能夠寫的目錄,99%不須要解析php,靜態文件所存放的目錄,不容許存放php。

11.29 限制user_agent

  1. user_agent能夠理解爲瀏覽器標識
  2. 核心配置文件內容
<IfModule mod_rewrite.c>
        RewriteEngine on
        RewriteCond %{HTTP_USER_AGENT}  .*curl.* [NC,OR]
        RewriteCond %{HTTP_USER_AGENT}  .*baidu.com.* [NC]
        RewriteRule  .*  -  [F]
    </IfModule>//NC 忽略大小寫,F爲fobidden的意思
  1. curl -A "123123" -x127.0.0.1:80 'http://111.com/123.hph' -A 指定user_agent
    -e 指定referer 必須以「http://」開頭
    -x 省略hosts -I 僅僅查看狀態碼

11.30/11.31 php相關配置

  1. 查看php配置文件位置 /usr/local/php/bin/php -i|grep -i "loaded configuration file" 在根目錄下建立phpinfo(),以下:
<?php
    phoinfo();

經過瀏覽器查看phpifo;找到路徑,找到源碼包# cd /usr/local/src/php-7.1.6/
# cp php.ini-development /usr/local/php7/etc/php.ini
# /usr/local/apache2.4/bin/apachectl graceful此時在打開瀏覽器,查看Loaded Configuration Files的路徑php

  1. date.timezone //定義時區,Asia/Shanghai
  2. disable_functions 將如下函數禁用 eval,assert,popen,passthru,escapeshellarg,escapeshellcmd,passthru,exec,system,chroot,scandir,chgrp,chown,escapeshellcmd,escapeshellarg,shell_exec,proc_get_status,ini_alter,ini_restore,dl,pfsockopen,openlog,syslog,readlink,symlink,leak,popepassthru,stream_socket_server,popen,proc_open,proc_close //危險的函數,
  3. display on或off,打開或者關閉錯誤提示
  4. error_log//定義log路徑, log_errors//是否打開錯誤日誌, display_errors, error_reporting//定義日誌的級別,默認爲E_all,生產環境上使用E_ALL & ~E_NOTICE
  5. open_basedir =/data/wwwroot/111.com:/tmp //php.ini是針對全部站點的,能夠在apache的配置文件中作配置,以下: php_admin_value open_basedir "/data/wwwroot/111.com:/tmp/"

擴展

  1. apache開啓壓縮 http://www.aminglinux.com/bbs/thread-5528-1-1.html html

  2. apache2.2到2.4配置文件變動 http://www.aminglinux.com/bbs/thread-7292-1-1.htmllinux

  3. apache options參數 http://www.aminglinux.com/bbs/thread-1051-1-1.html shell

  4. apache禁止trace或track防止xss http://www.aminglinux.com/bbs/thread-1045-1-1.htmlapache

  5. apache 配置https 支持ssl http://www.aminglinux.com/bbs/thread-1029-1-1.html 瀏覽器

相關文章
相關標籤/搜索