php 使用 exce不执行与 报错
"Fatal error: Uncaught think\\exception\\ErrorException: error_log(\/www\/wwwroot\/test.limiaokeji.cn\/runtime\/log\/202202\/16_cli.log): failed to open stream: Permission denied in \/www\/wwwroot\/test.limiaokeji.cn\/thinkphp\/library\/think\/log\/driver\/File.php:169", "Stack trace:", "#0 [internal function]: think\\Error::appError(2, 'error_log(\/www\/...', '\/www\/wwwroot\/te...', 169, Array)", "#1 \/www\/wwwroot\/test.limiaokeji.cn\/thinkphp\/library\/think\/log\/driver\/File.php(169): error_log('[ 2022-02-16T17...', 3, '\/www\/wwwroot\/te...')", "#2 \/www\/wwwroot\/test.limiaokeji.cn\/thinkphp\/library\/think\/log\/driver\/File.php(75): think\\log\\driver\\File->write('[ 2022-02-16T17...', '\/www\/wwwroot\/te...', false, true)", "#3 \/www\/wwwroot\/test.limiaokeji.cn\/thinkphp\/library\/think\/Log.php(179): think\\log\\driver\\File->save(Array, true)", "#4 \/www\/wwwroot\/test.limiaokeji.cn\/thinkphp\/library\/think\/Error.php(93): think\\Log::save()", "#5 [internal function]: think\\Error::appShutdown()", "#6 {main}", " thrown in \/www\/wwwroot\/test.limiaokeji.cn\/thinkphp\/library\/think\/log\/driver\/File.php on line 169"
问题原因:
runtime目录没有给到777权限,日志写入失败导致的报错。
解决办法:
给目录项目的runtime目录777权限即可
不执行:
出于安全的原因,服务器是不允许php或者其他语言执行exec命令的,当你有特殊需要php在服务器执行exec命令时,你需要设置两个地方,不然就无法执行成功。
修改php.ini
找到php配置文件php.ini,
在文件里搜索“disable_functions”,找到它后把“exec”、“shell_exec”去掉,然后保存文件。