“出于安全原因,exec() 已被禁用”
我有一个命令在服务器上运行良好。现在我正在来自不同托管服务的服务器上尝试它。我有一个包含此内容的 php.ini 文件(在根目录和当前目录中):
disable_functions =.
我收到此警告,并且 exec() 不运行。
由于安全原因,exec() 已在 210 行的 /home/nealsent/public_html/backups/backup_dbs.php 中禁用。
代码如下:
exec("mysqldump --opt db 2>&1 > db.sql", $output, $res);
I have a command working fine on a server. Now I'm trying it on a server from a different hosting service. I have a php.ini
file that contains this (in both root dir and current dir):
disable_functions =.
I'm getting this warning, and exec()
doesn't run.
exec() has been disabled for security reasons in /home/nealsent/public_html/backups/backup_dbs.php on line 210
The code is the following:
exec("mysqldump --opt db 2>&1 > db.sql", $output, $res);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
许多主机禁用某些功能,并且不允许在自定义 php.ini 中覆盖它们(仅仅因为 PHP 提供了自定义 php.ini 的能力,并不意味着所有 PHP 设置都必须配置为允许您通过以下方式更改该选项这样的)。
主机可能根本不允许 exec() 期间。你对此无能为力。
Many hosts disable certain functions, and do not allow overriding them in custom php.ini's (just because PHP offers the ability to have a custom php.ini, does not mean that all PHP setups are necessarily configured to allow you to change that option via such).
Chances are that host simply doesn't allow exec() period. Not much you can really do about that.
另一种可能性是 exec 已被 PHP 安全模式。从引用的页面来看,您似乎可以通过将正在执行的脚本放入 PHP“安全模式执行目录”来避免这种情况。
Another possibility is that exec has been disable by PHP safe mode. From the referenced page, it looks like you could avoid this by putting the script you are exec-ing into the PHP "safe mode exec dir".