linux系統下怎么預防php木馬_Linux教程
隨著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木馬拿我們沒轍了,遺憾的是這樣的話,利用文本數據庫的那些東西就都不能用了。
- 相關鏈接:
- 教程說明:
Linux教程-linux系統下怎么預防php木馬。