码迷,mamicode.com
首页 > Web开发 > 详细

php相关

时间:2017-12-27 02:39:27      阅读:222      评论:0      收藏:0      [点我收藏+]

标签:php

php_admin_value open_basedir "/data/wwwroot/11php_admin_value open_basedir "/da

1.禁止解析php

在虚拟主机配置文件/usr/local/apache2.4/conf/extra/httpd-vhosts.conf中加入如下内容:

 <Directory /data/wwwroot/111.com/upload>
        php_admin_flag engine off
 </Directory>

该配置仅用了php的解析引擎,导致php无法被解析。保存配置后重启apache

在更改配之前curl的结果如下,php得到正常解析:

[root@test_01 htdocs]# curl -x127.0.0.1:80 'http://111.com/upload/123.php'
123.php authorization passed

更改配置之后则是直接输出php脚本文件中的源码

[root@test_01 htdocs]# curl -x127.0.0.1:80 'http://111.com/upload/123.php'
<?php
echo "123.php authorization passed";
?>

2.禁用部分php函数

在配置文件/usr/local/php/etc/php.ini中加入如下配置:

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

例如在仅用了phpinfo这个函数后,默认首页的phpinfo监本无法得到处理,会呈现如下的画面:

技术分享图片

在调整display参数值为off后可以不现实上述的错误信息:

; http://php.net/display-errors
display_errors = off


3.定义时区

[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone =Asia/Shanghai

4.open_basedir

open_basedir可将用户访问文件的活动范围限制在指定的区域,通常是其家目录的路径,也可用符号"."来代表当前目录。注意用open_basedir指定的限制实际上是前缀,而不是目录名。举例来说: 若"open_basedir = /dir/user", 那么目录 "/dir/user" 和 "/dir/user1"都是可以访问的。所以如果要将访问限制在仅为指定的目录,请用斜线结束路径名。例如设置成:"open_basedir= /dir/user/" 。
open_basedir也可以同时设置多个目录, 在Windows中用分号分隔目录,在Linux中用冒号分隔目录。当其作用于Apache模块时,父目录中的open_basedir路径自动被继承。

设置方法:

在虚拟主机配置文件中加入如下配置内容:

php_admin_value open_basedir "/data/wwwroot/111.com:/tmp/"


ta/wwwroot/111.com:/tmp/"1.com:/tmp/"

php相关

标签:php

原文地址:http://blog.51cto.com/lavender7n/2054978

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!