11.28 限定某个目录禁止解析php
- 核心配置文件内容
<Directory /data/wwwroot/www.123.com/upload>
php_admin_flag engine off
<FilesMatch (.*)/.php(.*)>
Order allow,deny
Deny from all
</FilesMatch>
</Directory>
- curl测试时直接返回了php源代码,并未解析
- 能够写的目录,99%不须要解析php,静态文件所存放的目录,不容许存放php。
11.29 限制user_agent
- user_agent能够理解为浏览器标识
- 核心配置文件内容
<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的意思
- 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相关配置
- 查看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
- date.timezone //定义时区,Asia/Shanghai
- 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 //危险的函数,
- display on或off,打开或者关闭错误提示
- error_log//定义log路径, log_errors//是否打开错误日志, display_errors, error_reporting//定义日志的级别,默认为E_all,生产环境上使用E_ALL & ~E_NOTICE
- open_basedir =/data/wwwroot/111.com:/tmp //php.ini是针对全部站点的,能够在apache的配置文件中作配置,以下: php_admin_value open_basedir "/data/wwwroot/111.com:/tmp/"
扩展
-
apache开启压缩 http://www.aminglinux.com/bbs/thread-5528-1-1.html html
-
apache2.2到2.4配置文件变动 http://www.aminglinux.com/bbs/thread-7292-1-1.htmllinux
-
apache options参数 http://www.aminglinux.com/bbs/thread-1051-1-1.html shell
-
apache禁止trace或track防止xss http://www.aminglinux.com/bbs/thread-1045-1-1.htmlapache
-
apache 配置https 支持ssl http://www.aminglinux.com/bbs/thread-1029-1-1.html 浏览器