PHP Exec()或System()导致500错误

时间:2012-07-13 10:24:03

标签: php system exec

我认为这是一个相当简单的问题。这是我的测试代码(显然,当我真正写这个时,我会添加安全预防措施) -

<?php
    if (isset($_POST['url']) && !empty($_POST['url'])) {
        system('wget --no-parent --timestamping --convert-links --page-requisites --no-directories --no-host-directories -erobots=off '.$_POST['url']);
} else {
    echo '<form method="post"><input type="url" name="url"><input type="submit"></form>';
}

?>

我需要启用/安装PHP或Apache2中的某些模块吗?我通过浏览器访问此页面,如果有帮助的话。即使尚未调用该命令(if语句的那部分未运行),也会发生这种情况,如果我注释掉system()或exec()行,则500错误消失。

2 个答案:

答案 0 :(得分:0)

您提供的代码出错;最后你把点放在了错误的地方:

 '.$_POST['url']);

而不是

 .'$_POST['url']);

答案 1 :(得分:0)

您的代码适合我,请检查您是否已禁用system功能。您可以使用ini_get('disable_functions')检查是否已禁用。