sudo php 权限
我想通过速度 实现 ifconfig eth0 down 我看到 一些关于sudo获取权限的文章 我是如下写的代码 但是没有效果 求高手指点
首先我 visudo
然后在 # Allow members of group sudo to execute any command添加如下代码
shenwenjian ALL=NOPASSWD:/sbin/ficonfig
然后保存
PHP编码如下
$inf=shell_exec("/var/lib/sudo/sbin/ifconfig eth0 down");
print_r($inf)
求高手指点这个 sudo 获取权限的问题在哪 谢谢
------解决方案--------------------
$inf=shell_exec("sudo -u root -S /var/lib/sudo/sbin/ifconfig eth0 down");
这样试试呢?
参见这篇: http://stackoverflow.com/questions/3173201/sudo-in-php-exec
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号