温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

php配置文件详解

发布时间:2020-04-26 16:36:46 来源:网络 阅读:358 作者:草根追逐 栏目:web开发

1、限制php高风险项目

编辑php配置文件

/usr/local/php/etc/php.ini

找到disable_functions =

添加限制条目

eval,assert,popen,passthru,escapeshellarg,esacapshellcmd,passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_get_status,ini_restore,dl,pfsockopen,openlog,syslog,readlink,symlink,leak,popepassthru,stream_socket_server,proc_open,proc_close

2、访问错误提示显示开关关闭并且打开php错误日志记录


display_errors = Off

log_errors = On

3、更改日志文件位置

error_log = /usr/local/php/log/php_errors.log

4、更改错误级别

error_reporting = E_ALL & ~E_NOTICE

5、限制访问目录

open_basedir =/data/www:/tmp

也可以在虚拟主机配置文件限制访问目录

在此段 ServerAlias www.aaa.com下添加以下限制条件

php_admin_value open_basedir "/data/www:/tmp"

使用curl或浏览器访问显示结果为正确200

[root@redhat www2]# curl -x127.0.0.1:80 -I www.test.com/forum.php

HTTP/1.1 200 OK

Date: Thu, 26 May 2016 01:29:04 GMT

Server: Apache/2.2.31 (Unix) PHP/5.4.36

X-Powered-By: PHP/5.4.36

将正确目录改成错误目录/data/www2后

php_admin_value open_basedir "/data/www2:/tmp"

显示结果为错误500:

[root@redhat www2]# curl -x127.0.0.1:80 -I www.test.com/forum.php

HTTP/1.0 500 Internal Server Error

Date: Thu, 26 May 2016 01:48:31 GMT

Server: Apache/2.2.31 (Unix) PHP/5.4.36

X-Powered-By: PHP/5.4.36

Cache-Control: max-age=0

Expires: Thu, 26 May 2016 01:48:31 GMT

Connection: close

Content-Type: text/html


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI