1、在脚本所在目录增加.user.ini,内容如下限制php脚本访问只能访问指定目录
open_basedir = /var/www/html/project1:/tmp upload_max_filesize = 20M2、禁止php的危险函数,打开 php.ini 文件。这个文件通常位于你的PHP安装目录下,或者在服务器的配置目录中。
找到 disable_functions 指令。这个指令允许你列出你想要禁用的PHP函数。
在 disable_functions 指令后面添加你想要禁用的函数名,用逗号分隔。例如,如果你想要禁用 exec, passthru, shell_exec, system 和 proc_open 函数,你可以这样写:
; php.ini ; 其他配置... disable_functions = exec, passthru, shell_exec, system, proc_open, popen, eval, dl, mail, passthru, escapeshellarg, escapeshellcmd, chroot, scandir, chgrp, chown, shell_exec, proc_open, proc_close, proc_get_status, proc_nice, proc_terminate, ini_alter, ini_restore, ini_set, putenv, set_time_limit, dl, openlog, syslog, closelog, pfsockopen, fsockopen, stream_socket_client, leak, apache_child_terminate, posix_kill, posix_mkfifo, posix_setpgid, posix_setsid, posix_setuid, posix_setgid, posix_uname, phpinfo ; 其他配置...
保存 php.ini 文件并重启你的Web服务器(如Apache或Nginx)以使更改生效。
网友回复