禁用PHP危险函数是必要的。前些天由于我的疏忽没禁用fsockopen函数,被人利用进行PHPDDOS攻击,导致服务器被机房关机。

编辑 php.ini

搜索 disable_functions =

如果前面有 “#” 就去掉,添加需要禁用的函数,以下供参考:

disable_functions =  phpinfo,system,exec,shell_exec,passthru,proc_open,proc_close, proc_get_status,checkdnsrr,getmxrr,getservbyname,getservbyport, syslog,popen,show_source,highlight_file,dl,socket_listen,socket_create,socket_bind,socket_accept, socket_connect, stream_socket_server, stream_socket_accept,stream_socket_client,ftp_connect, ftp_login,ftp_pasv,ftp_get,sys_getloadavg,disk_total_space, disk_free_space,posix_ctermid,posix_get_last_error,posix_getcwd, posix_getegid,posix_geteuid,posix_getgid, posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, posix_getppid,posix_getpwnam,posix_getpwuid, posix_getrlimit, posix_getsid,posix_getuid,posix_isatty, posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid, posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname,fsockopen,pfsockopen,gzinflate

保存退出

另外,建议在php.ini里面,设置 open_basedir 到用户目录,然后设置 enable_dl = Off 和 allow_url_fopen = Off

重启Apache使更改生效:service httpd restar

标签: PHP, 系统安全

添加新评论