is_writable返回false

來源:互聯網
上載者:User
我有一個test.php檔案,內容如下:
if(is_writable("/home/www/testapp/image/cache"))
{
echo ("can write!");
}
else
{
echo ("can not write!");
}
?>
通過命令列執行,返回的是“can write!”
php test.php
但是,通過網站訪問,返回的是can not write!
而且通過命令sudo -u apache php test.php 執行,返回的也是can not write!

通過ps aux | grep apache查看,使用者資訊如下:
apache 17446 0.0 2.5 373988 49420 ? S Jan13 0:06 /usr/sbin/httpd
apache 17447 0.0 2.5 373760 49084 ? S Jan13 0:07 /usr/sbin/httpd
apache 17448 0.0 3.2 387204 62392 ? S Jan13 0:05 /usr/sbin/httpd
apache 17449 0.0 2.0 360468 39820 ? S Jan13 0:06 /usr/sbin/httpd
apache 17450 0.0 3.0 383112 58328 ? S Jan13 0:06 /usr/sbin/httpd
apache 17451 0.0 3.0 382332 57808 ? S Jan13 0:06 /usr/sbin/httpd
apache 17452 0.0 2.6 374792 50300 ? S Jan13 0:05 /usr/sbin/httpd
apache 17453 0.0 2.5 372472 48364 ? S Jan13 0:07 /usr/sbin/httpd
apache 17942 0.0 2.3 365588 45172 ? S Jan13 0:05 /usr/sbin/httpd
apache 19042 0.0 3.0 384096 59060 ? S Jan14 0:04 /usr/sbin/httpd
apache 19115 0.0 2.4 372488 47748 ? S Jan14 0:02 /usr/sbin/httpd

並且cache的許可權也改成了apache
drw-rw-rw- 2 apache apache 4096 10月 20 22:18 cache
drwxrwxrwx 3 apache apache 4096 1月 16 2015 catalog

我的問題是,為什麼通過網站或者apache賬戶,一直都是返回不能寫呢,請高手幫忙,非常感謝!!



回複討論(解決方案)

php test.php 可以,應該是root可以
sudo -u apache php test.php 不行

表示 apache這個使用者沒有寫入權限。

catalog 這個是777的,這個有許可權寫嗎?

那不用is_writable

我找到原因了,因為父資料夾沒有許可權,所以,就算是子檔案夾有許可權,也不行;不過還是多謝各位~

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.