doudi5524 2015-01-08 17:30
浏览 63

PHP exec()无法在Raspberry apache服务器上运行

I have a Raspberry Pi with an Apache server on it (PHP5). I got a code to control my relay module but PHP does not execute the python script.

This is the code:

<html>
<head>
<meta charset="UTF-8" />
    <link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<?php
if (isset($_POST['LightON']))
{
exec("sudo python /home/pi/lighton_1.py");
}
if (isset($_POST['LightOFF']))
{
exec("sudo python /home/pi/lightoff_1.py");
}
?>
<form method="post">
<button class="btn" name="LightON">Light ON</button>&nbsp;
<button class="btn" name="LightOFF">Light OFF</button><br><br>
</form>
</html>
  • 写回答

2条回答 默认 最新

  • dongmeixian9665 2015-01-08 17:33
    关注

    Look in your php.ini if exec() is enabled. If it isn't, uncomment it and restart your PHP process (and maybe apache too)

    EDIT:
    After submitting an edit I noticed that you use sudo in your PHP exec() statement. This doesn't work if your root user is protected by a password (which it really should!).

    评论

报告相同问题?

悬赏问题

  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)