1、防止跳出web目录
最先修正httpd.conf,假设你只准许你的php脚本顺序在web目录里操作,还能够修正httpd.conf文件限定php的操作途径。比如你的web目录是/usr/local/apache/htdocs,那么在httpd.conf里加上这么几行:
php_admin_value open_basedir /usr/local/apache
/htdocs
这样,假设脚本要读取/usr/local/apache/htdocs以外的文件将不会被准许,假设错误显示翻开的话会提示这样的错误:
Warning: open_basedir restriction in effect. File is in wrong directory in
/usr/local/apache/htdocs/open.php on line 4
等等。
2、防止php木马执行webshell
翻开safe_mode,
在,php.ini中配置
disable_functions= passthru,exec,shell_exec,system
二者选一即可,也可都选
3、防止php木马读写文件目录
在php.ini中的
disable_functions= passthru,exec,shell_exec,system
后面加上php处理文件的函数
首要有
fopen,mkdir,rmdir,chmod,unlink,dir
fopen,fread,fclose,fwrite,file_exists
closedir,is_dir,readdir.opendir
fileperms.copy,unlink,delfile
即成为
disable_functions= passthru,exec,shell_exec,system,fopen,mkdir,rmdir,chmod,unlink,dir
,fopen,fread,fclose,fwrite,file_exists
,closedir,is_dir,readdir.opendir
,fileperms.copy,unlink,delfile
ok,大功告成,php木马拿咱们没辙了,遗憾的是这样的话,运用文本数据库的那些东西就都不能用了。
假设是在windos平台下搭建的apache咱们还须要留意一点,apache默许运转是system权限,这很恐惧,这让人觉得很不爽.那咱们就给apache降降权限吧。
net user apache fuckmicrosoft /add
net localgroup users apache /del