【发布时间】:2017-03-22 17:54:29
【问题描述】:
我正在使用 raspberry pi 进行一个项目,以使用移动设备打开和关闭 LED 灯条。
我遇到的最后一个问题是让脚本从托管在树莓派上的 apache 服务器运行。
<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.py");
}
if (isset($_POST['LightOFF'])) {
exec("sudo python /home/pi/lightOff.py");
}
?>
<form method="post">
<button class="btn" name="LightON">Light ON</button>
<button class="btn" name="LightOFF">Light OFF</button><br><br>
</form>
</html>
Python 脚本在运行树莓派上的命令行时可以完美运行。但是当在 apache 服务器上运行时,什么也没有发生。我在这里做错了什么?它与权限有关吗?我对linux和php很陌生,请记住这一点。
为什么 Python 可以在本地工作,而不能在服务器上工作?
谢谢!
【问题讨论】: