Home > Backend Development > PHP Tutorial > sudo php 权限解决思路

sudo php 权限解决思路

WBOY
Release: 2016-06-13 10:24:49
Original
1000 people have browsed it

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

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template