绝大多数 PHP 应用都只是单纯的 WEB 程序,很少用得到一些系统调用。一般最多用到一些列目录、读写删文件等。其他 system 、 passthru 等函数使用的最多的地方是 Web Shell 。作为一个运行着众多应用的服务器的运维,没有办法保证每一个程序的绝对安全,所能做的就是在自己的能力范围内尽可能增强系统安全性,通过权限隔离、限制等方法构筑“最后一道防线”。禁用一些一般不会用到的 PHP 函数就很有帮助。我的做法是在全局的 php.ini 中禁用掉这些函数,对于极个别需要其中某些函数的应用,在相应的 Apache VirtualHost/Directory 配置中通过 php_admin_value 来去掉限制。

disable_functions =
; System APIs (process related)
system, exec, shell_exec, passthru, proc_open, proc_close, proc_get_status, popen,
; Other system APIs
syslog, show_source, highlight_file, dl, sys_getloadavg, disk_total_space, disk_free_space,
; Rarely used network APIs (may be used by some admin tools)
checkdnsrr, getmxrr, getservbyname, getservbyport, 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,
; POSIX APIs
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,
; Process Control APIs (disabled by default in Debian/Ubuntu)
pcntl_alarm, pcntl_fork, pcntl_waitpid, pcntl_wait, pcntl_wifexited, pcntl_wifstopped, pcntl_wifsignaled, pcntl_wexitstatus, pcntl_wtermsig, pcntl_wstopsig, pcntl_signal, pcntl_signal_dispatch, pcntl_get_last_error, pcntl_strerror, pcntl_sigprocmask, pcntl_sigwaitinfo, pcntl_sigtimedwait, pcntl_exec, pcntl_getpriority, pcntl_setpriority

欢迎补充!