首页 > 服务器 > Linux服务器 > 正文

linux系统下怎么预防php木马

2020-05-26 23:49:38
字体:
来源:转载
供稿:网友

随着php语言的流行,安全问题能忽视,现在比较多的一种木马就是php木马,大家对此也非常的头疼。现在我给大家讲一下在linux下如何预防php木马。

1.首先修改httpd.conf,如果你只允许你的php脚本程序在web目录里操作,可以修改httpd.conf文件限制php的操作路径。比如你的web目录是/usr/local/apache/htdocs,那么在httpd.conf里加上这么几行:
php_admin_valueopen_basedir /usr/local/apache/htdocs
这样,如果脚本要读取/usr/local/apache/htdocs以外的文件将不会被允许,如果错误显示打开的话会提示这样的错误:
Warning:open_basedirrestrictionineffect.Fileisinwrongdirectoryin/usr/local/apache/htdocs/open.phponline4等等。
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木马拿我们没辙了,遗憾的是这样的话,利用文本数据库的那些东西就都不能用了。

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表