PHP로 실행할 때 마운트가 스크립트에서 작동하지 않습니다.

PHP로 실행할 때 마운트가 스크립트에서 작동하지 않습니다.

그래서 apache2 html 폴더에 있는 스크립트가 있고 http 게시물에 의해 실행되어야 합니다. 스크립트에는 루트가 필요하므로(전혀 안전하지 않다는 것을 알고 있으므로 무시하십시오.) sudoers 파일에서 사용자 www-data를 www-data ALL=(ALL) NOPASSWD: ALL. 스크립트를 실행하면 cif 파일 시스템을 마운트하는 것을 제외하면 꽤 잘 작동합니다.

스크립트는 PHP에 의해 실행됩니다.

exec("sudo ./miniosetup $folder $address $path $User $Pass $S3User $S3Pass $Port");

스크립트는 다음과 같이 마운트되어야 합니다.

ipadress=$(host $address | cut -d' ' -f4 | head -n 1)
echo "$ipadress $minuname $minpwd" >> log_mount
echo "mount -v -t cifs //$address/$usePath/ /mnt/$filesystemname/ -o username=$username,password=$password" >> log_mount
sudo mount -v -t cifs //$address/$usePath/ /mnt/$filesystemname/ -o username=$username,password=$password >> log_mount
if [ ! $? -eq 0 ]
then
  echo "mount  -v -t cifs //$ipadress/$usePath/ /mnt/$filesystemname/ -o username=$username,password=$passwords" >> log_mount
  sudo mount -v -t cifs //$ipadress/$usePath/ /mnt/$filesystemname/ -o username=$username,password=$password >> log_mount
fi

log_mount 파일은 다음과 같습니다:

192.168.0.5 testingUsr testingTest
mount -v -t cifs //srv01/netstorage/testminio/ /mnt/testingTester/ -o username=FILESYSTEMUSERNAME,password=FILESYSTEMPASSWORD

그러나 내가 실행할 때 mount결코 표시되지 않습니다. 파일 시스템도 /mnt/testingTester/. 동일한 매개변수를 사용하여 스크립트를 수동으로 실행하면 모든 것이 잘 작동합니다. 아이디어가 부족하기 때문에 어떤 아이디어라도 감사하겠습니다.

편집: sudo가 작동합니다. 그렇지 않으면 스크립트는 세 번째 줄에 "루트로 실행하세요"라고 출력합니다.if [ "$EUID" -ne 0 ]; then echo "Please run as root" exit; fi

편집: 나는 apache2가 일종의 샌박스에서 실행될 수 있다고 생각했습니다. 누구든지 확인하거나 거부할 수 있습니까?

관련 정보