从PHP关机 - 让apache的权限 [英] Shutdown from php - giving apache permission

查看:118
本文介绍了从PHP关机 - 让apache的权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的工作有一个网络接口(阿帕奇)一个嵌入式Linux系统上。基本上我需要关闭和重启功能添加到Web界面。然而,我遇到的权限问题上运行时:

I am working on a embedded linux system with a web interface (apache). Basically I need to add shutdown and restart functionality to the web interface. However, I am running into permission issues when running:

EXEC(现在关机)等等......通过网页拨打电话时(即Apache的)。

exec("shutdown now") etc...when calling through the webpage(ie apache).

到底我该如何让这些命令来自Apache被称为?

How the heck do I allow these commands to be called from apache?

请问preFER不是得给阿帕奇完全的root权限,但系统的安全性是不是在我的情况下,一个巨大的交易,因此,如果这是唯一的出路,我该怎么办呢?

Would prefer not to have to give apache full root permissions, but system security is not a huge deal in my case, so if that is the only way, how can I do that?

推荐答案

制作一个Apache sudoer是一个危险的举动,我会避免。我认为QID接近这个......最简单的解决办法是建立一个cron作业下运行每X秒,并检查是否在Apache可以写入到一个目录的文件根目录。有阿帕奇当你想关闭添加文件和脚本的cron应该有一个触发器(一)删除该文件及(b)重新启动机器。

Making Apache a sudoer is a dangerous move and I'd avoid it. I think QID is close on this... the easiest solution is to set up a cron job under root that runs every X seconds and checks for a file in a directory that apache can write to. Have apache add that file when you want to shut down, and the cron script should have a trigger that (a) removes the file and (b) restarts the machine.

只是要小心,它正确地删除该文件,并给自己当你测试,或者服务器只会不断重新启动,这将是一个烂摊子一个pretty长的cron延迟。

Just be careful that it removes the file correctly and give yourself a pretty long cron delay when you're testing, or the server will just reboot continuously and that would be a mess.

这篇关于从PHP关机 - 让apache的权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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