继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

php配置文件详解

html5零基础入门学习
关注TA
已关注
手记 246
粉丝 81
获赞 517

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


打开App,阅读手记
0人推荐
发表评论
随时随地看视频慕课网APP