首页 > Web开发 > 详细

php配置文件详解

时间:2016-05-26 11:38:43      阅读:165      评论:0      收藏:0      [点我收藏+]

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


本文出自 “愺艮搥豩” 博客,请务必保留此出处http://riverxyz.blog.51cto.com/533303/1783334

php配置文件详解

原文:http://riverxyz.blog.51cto.com/533303/1783334

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!