在PHP我做了以下內容:用戶WWW的數據不能刪除文件
exec('remove_file.sh', $output, $return);
其中remove_file.sh是下面的腳本:
#!/bin/sh
rm -f /tmp/test.pdf
我證實,此腳本由WWW-運行data和test.pdf由myuser擁有,但擁有666(rw-rw-rw-)權限。/tmp由root擁有並擁有666權限。
該腳本返回1(一般錯誤),沒有任何輸出。
如果我從終端嘗試:
sudo su www-data -c 'rm -f /tmp/test.pdf'
我得到:
cannot remove `/tmp/test.pdf': Operation not permitted
如何從一個PHP腳本刪除此文件?
'ls -al/tmp/test.pdf'的輸出是什麼? – fyr 2013-04-22 08:54:37
你嘗試過設置執行位嗎? chmod 777給rwxrwxrwx?目錄的權限是什麼? HTTP://unix.stackexchange。com/questions/21251/why-do-directories-need-the-executable-x-permission-to-be-opened – Waygood 2013-04-22 09:00:36
$ fyr即:-rw-rw-rw- 1 myuser myuser – tihe 2013-04-22 09:03:24