通过php"exec"挂载时出错 [英] Error on mount through php "exec"
问题描述
我正在尝试安装iscsi虚拟磁盘,但是如果我通过php中的exec函数执行命令,则会给我该错误:mount: special device /dev/sdf1 does not exist
.
但是,如果我直接在控制台中运行命令,它将运行良好!!
我能做些什么?
我正在以一种很好的方式获得/dev/sdf1
,并且它存在,但是仅通过php无法正常工作.
I'm trying to mount an iscsi virtual disk, but if I execute the command through the exec function in php this give me that error: mount: special device /dev/sdf1 does not exist
.
But if I run the command directly in the console it run well!!
What can I do?
I'm obtaining the /dev/sdf1
in a good way, and it exists, but only through php doesn't work.
我正在使用sudo
运行命令,并始终使用sudo
以www-data
用户身份在控制台中运行它,因此,我认为这是相同的环境.
I'm running the command with sudo
and run it in console as www-data
user always with sudo
, so, I suppose that is the same enviroment.
sudo mount -t ext3 /dev/sdf1 /san_disks/RIBS_2
sudoers文件具有以下几行:
The sudoers file has this lines:
www-data ALL = (root) /usr/bin/iscsiadm, /bin/mount, /bin/umount
%www-data ALL=NOPASSWD: ALL
它可以在控制台中工作.
And it works in console.
推荐答案
之所以发生这种情况,是因为未更新"/dev".我做了一个睡眠(1),而且有效!!
This was happening because "/dev" wasn't updated. I made a sleep(1) and it works!!
这篇关于通过php"exec"挂载时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!