php无法执行任何外部命令?

发布于 2024-10-05 14:57:26 字数 616 浏览 9 评论 0原文

我们在这里从 Slackware 迁移到 CentOS,它工作正常,然后在没有通知的情况下,php 停止执行外部调用,例如对“wc”和“spamc”的调用。所有此类调用在 error_log 中显示为:

sh: /usr/bin/spamc: 权限被拒绝

路径正确。我们已经正确设置了权限,apache 应该能够毫无问题地执行这些文件。我们处于安全模式,并且没有设置 base_dir。它不是 SELinux,或者至少 sestatus 说 SELinux 已禁用。

摘要:

  • PHP 无法通过 exec() 或 popen() 执行任何内容
  • 二进制文件的路径是正确的。
  • 我们未处于安全模式
  • 我们没有设置 base_dir
  • 二进制文件的权限允许 apache 用户执行它们
  • SELinux 被禁用
  • php.ini 中的disable_functions 为空
  • 我们不知道为什么它不起作用

PHP 版本 5.3.3 和 CentOS 5.5

有人知道可能会发生什么吗? 提前致谢

We moved from Slackware to CentOS here, it was working fine then without notice, php stopped executing external calls such as calls to "wc" and "spamc". All such calls appear on error_log as:

sh: /usr/bin/spamc: Permission denied

The paths are correct. We have the permissions set correctly and apache is supposed to be able to execute the files with no problem. We're NOT on safe_mode and we do not have base_dir set. It is not SELinux, or at least sestatus says SELinux is disabled.

summary:

  • PHP can't execute anything thru exec() or popen()
  • Paths to binaries are correct.
  • We are not in safe mode
  • We don't have base_dir set
  • Permissions on the binaries allow apache user to execute them
  • SELinux is disabled
  • disable_functions in php.ini is empty
  • We have no clue why it doesn't work

PHP version 5.3.3 and CentOS 5.5

Anyone has a clue of what might be happening?
Thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

凉宸 2024-10-12 14:57:26

SELinux 正在阻止您运行它们的尝试。我建议您制定规则,允许您运行所需的外部命令子集并将其作为模块加载。

SELinux is blocking your attempts to run them. I recommend you come up with rules that allow you to run the subset of external commands required and load that as a module.

ぶ宁プ宁ぶ 2024-10-12 14:57:26

发现错误了。

例如,我试图执行 /usr/bin/tidy,usr 文件夹具有 644 权限,这类似于我书中的洛夫克拉夫特式恐怖。我可以工作,因为我是root。

在疯狂地决定检查命令的所有路径组件(从根/文件夹到整洁的二进制文件)的权限后,我发现了这一点,我发现所有权限设置正确,但 usr 文件夹权限完全被搞砸了。

这是固定的。

Found the error.

I was trying to execute /usr/bin/tidy for example, the usr folder had a 644 permission which is akin to lovecraftian horror in my book. I could work because I was root.

I figured it out after going crazy and deciding to check the permissions on all the path components of the command from the root / folder to the tidy binary, I found all permissions set correctly but the usr folder perms were completely screwed.

This is fixed.

究竟谁懂我的在乎 2024-10-12 14:57:26

PHP 在服务器上作为 Apache 运行吗?我以为它以无人身份运行..

Does PHP run as Apache on the server? I thought it ran as Nobody..

卖梦商人 2024-10-12 14:57:26

https://serverfault.com/questions/207989/php-cant- execute-any-external-command/208001#208001

一般来说,centOS 上的 PHP 是以无人身份运行的,除非你将 php 编译为 fastcgi、dso 等...

https://serverfault.com/questions/207989/php-cant-execute-any-external-command/208001#208001

Generally PHP on centOS is ran as nobody unless you have compiled php as fastcgi, dso etc...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文