【发布时间】:2025-11-28 15:05:04
【问题描述】:
我正在尝试在 Centos 服务器上从 php 执行 nodejs 文件。当从终端执行该命令时,它工作正常(在使用以下命令 su -s /bin/bash apache 切换到 apache 用户之后),但是当在浏览文件时执行代码时,它会引发以下异常:
["","","#","# 致命错误,第 0 行","# 检查失败:SetPermissions(protect_start,protect_size, PageAllocator::kReadExecute).","#", "#","#","#FailureMessage 对象:0x7fffd9b37760"]
- 我也更改为绝对路径,但没有运气。
- 为 index.js 文件授予 777 权限。
- 从终端测试并正常工作:
php -r 'echo exec("/usr/bin/node /var/www/html/index.js /var/www/html/source_files/ 2>&1");'
<?php
try {
exec("/usr/bin/node /var/www/html/index.js /var/www/html/source_files/ 2>&1", $out, $err);
if ($err == 0) {
return 1;
} else {
return 0;
}
} catch (Exception $e) {
error_log($e);
return 0;
}
?>
【问题讨论】: