通过 PHP 执行 Openwrt UCI 命令 [英] Execute Openwrt UCI command through PHP

查看:84
本文介绍了通过 PHP 执行 Openwrt UCI 命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 PHP 为 openwrt 开发简单(非常简单)的前端.为此,我需要通过 PHP shell_exec() 或 system() 函数调用许多 openwrt UCI(统一配置接口)命令.我在终端中尝试过的所有 UCI 命令都运行良好.但是一旦我通过上述功能运行它们,它们就无法正常工作.

Im developing simple (dead simple) front end for openwrt using PHP. To do this I need to call many openwrt UCI (Unified conf. interface) commands through PHP shell_exec() or system() functions. All the UCI commands that I tried in terminal are working perfectly fine. But as soon as I run them through above functions they are simply not working.

作为示例,我运行以下两个在终端中运行良好的命令

As an example I run following two commands which worked well in terminal

uci set wireless.@wifi-iface[0].ssid=test
uci commit

但是一旦我通过 PHP 运行它们,就什么也没有发生.他们根本不工作.我制作 .sh 文件并保存以上两行,然后再次使用 PHP 运行该文件!结果是一样的.但是当我通过终端执行 .sh 文件时它可以工作!!

But as soon as I run them through PHP nothing happens. They are simply not working. The I make .sh file and save above two lines and run that files using PHP but again!! results are the same. But when I execute .sh file through terminal it works!!

为了测试,我将两个文件的权限都设置为 777.但这没有帮助.通过 PHP 运行 shell 命令是否有任何其他要求,例如对 PHP 或 Apache 的 root 访问权限?我是新手,如果有人可以提供帮助,我将不胜感激

For testing I set the both file permission to 777. but that doesn't helps. Is there are any additional requirements to run shell commands through PHP like root access to the PHP or Apache ? I'm new to this and I would thankful if someone can help

我的apache错误日志

my apache error_log

[Wed Aug 19 08:26:53 2015] [error] [client 192.168.2.117] uci
[Wed Aug 19 08:26:53 2015] [error] [client 192.168.2.117] : 
[Wed Aug 19 08:26:53 2015] [error] [client 192.168.2.117] I/O error
[Wed Aug 19 08:26:53 2015] [error] [client 192.168.2.117]

我使用 apache 作为网络服务器,并使用 openwrt Chaos Calmer 15.05-rc3 作为我在 Raspberry pi 2 之上的基础固件

Im using apache as a web server and openwrt Chaos Calmer 15.05-rc3 as my base firmware on top of Raspberry pi 2

推荐答案

我设法使用 uhttpd Web 服务器而不是 Apache 解决了我的问题.Apache 不知何故没有足够的权限直接执行 UCI 命令.uhttpd openwrt默认的web服务器可以直接执行这个命令

I managed to solve my problem using uhttpd web server instead of Apache. Apache somehow doesn't have enough privileges to execute UCI commands directly. uhttpd the default web server in openwrt can execute this commands directly

这篇关于通过 PHP 执行 Openwrt UCI 命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆