久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

PHP is_writable() 函數(shù)對(duì)于可寫目錄總是返回 false

PHP is_writable() function always returns false for a writable directory(PHP is_writable() 函數(shù)對(duì)于可寫目錄總是返回 false)
本文介紹了PHP is_writable() 函數(shù)對(duì)于可寫目錄總是返回 false的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

我正在嘗試在 Red Hat 7 Amazon EC2 實(shí)例 (ami-8cff51fb) 中安裝基于 PHP 的軟件包已經(jīng)使用 yum 在其上安裝了 Apache 2.4.6 和 PHP 5.4.16.安裝失敗,因?yàn)樗f(shuō)特定目錄需要由具有 0755 或 0775 權(quán)限的網(wǎng)絡(luò)服務(wù)器寫入.

I'm trying to install a PHP-based software package in a Red Hat 7 Amazon EC2 instance (ami-8cff51fb) that has had Apache 2.4.6 and PHP 5.4.16 installed on it using yum. The installation fails because it says a particular directory needs to be writable by the webserver with 0755 or 0775 permissions.

有問(wèn)題的目錄具有 0775 權(quán)限,具有 root:apache 所有權(quán).我已經(jīng)驗(yàn)證 httpd 進(jìn)程正在由 apache 用戶運(yùn)行,并且 apache 用戶是 apache 組的成員.

The directory in question has 0775 permissions with root:apache ownership. I have verified that the httpd process is being run by the apache user and that the apache user is a member of the apache group.

如果我編輯 /etc/passwd 暫時(shí)給 apache 用戶一個(gè)登錄 shell,然后 su 到那個(gè)帳戶,我可以手動(dòng)創(chuàng)建文件作為 apache用戶在目錄中使用 touch 命令.

If I edit /etc/passwd to temporarily give the apache user a login shell and then su to that account, I am able to manually create files as the apache user within the directory using the touch command.

我查看了安裝程序腳本的源代碼,發(fā)現(xiàn)它失敗了,因?yàn)?PHP 的 is_writable() 函數(shù)為相關(guān)目錄返回 false.我創(chuàng)建了一個(gè)單獨(dú)的測(cè)試 PHP 腳本來(lái)隔離和驗(yàn)證我看到的行為:

I took a look at the source code of the installer script and identified that it's failing because PHP's is_writable() function is returning false for the directory in question. I created a separate test PHP script to isolate and verify the behaviour I'm seeing:

<?php
  $dir = '/var/www/html/limesurvey/tmp';
  if (is_writable($dir)) {
    echo $dir, ' is writable';
  } else {
    echo $dir, ' is NOT writable';
  }
?>

這會(huì)輸出不可寫消息.如果我將上面的 $dir 更改為 /tmp 那么它會(huì)正確輸出 /tmp 是可寫的.

This outputs the NOT writable message. If I change $dir above to be /tmp then it correctly outputs that /tmp is writable.

如果我將目錄權(quán)限更改為 0777 和/或?qū)⑺袡?quán)更改為 apache:apache 然后 PHP 仍然報(bào)告該目錄不可寫.我什至嘗試創(chuàng)建一個(gè)具有相同權(quán)限和所有權(quán)的 /test 目錄,但我的測(cè)試腳本仍然報(bào)告它不可寫.

If I change the directory permissions to 0777 and/or change the ownership to apache:apache then PHP still reports that the directory isn't writable. I even tried creating a /test directory set up with the same permissions and ownership and my test script still reports it as not writable.

我真的不知道如何解釋這種行為,所以歡迎提出任何想法!

I'm really at a loss as to explain this behaviour, so any ideas would be welcome!

提前致謝.

/var/www/html/limesurvey 的目錄列表如下.根據(jù) Lime Survey 的安裝說(shuō)明,tmpupload 目錄具有 0775 權(quán)限.test.php 是我上面提到的測(cè)試腳本.

The directory listing for /var/www/html/limesurvey is given below. The tmp and upload directories have 0775 permissions as per Lime Survey's installation instructions. test.php is my test script mentioned above.

[ec2-user@ip-xx-x-x-xxx limesurvey]$ pwd
/var/www/html/limesurvey
[ec2-user@ip-xx-x-x-xxx limesurvey]$ ls -al
total 80
drwxr-xr-x. 20 root apache 4096 Mar 30 11:25 .
drwxr-xr-x.  3 root root     23 Mar 25 14:41 ..
drwxr-xr-x.  2 root apache   38 Mar 10 12:56 admin
drwxr-xr-x. 16 root apache 4096 Mar 10 12:56 application
drwxr-xr-x.  3 root apache 4096 Mar 10 12:56 docs
drwxr-xr-x.  2 root apache 4096 Mar 10 12:56 fonts
drwxr-xr-x. 19 root apache 4096 Mar 10 12:56 framework
-rw-r--r--.  1 root apache  429 Mar 10 12:56 .gitattributes
-rw-r--r--.  1 root apache  399 Mar 10 12:56 .gitignore
-rw-r--r--.  1 root apache  296 Mar 10 12:56 .htaccess
drwxr-xr-x.  4 root apache 4096 Mar 10 12:56 images
-rw-r--r--.  1 root apache 6652 Mar 10 12:56 index.php
drwxr-xr-x.  5 root apache   39 Mar 10 12:56 installer
drwxr-xr-x. 89 root apache 4096 Mar 10 12:56 locale
drwxrwxr-x.  2 root apache   39 Mar 25 14:41 logs
drwxr-xr-x.  4 root apache   49 Mar 10 12:56 plugins
-rw-r--r--.  1 root apache   61 Mar 10 12:56 README
drwxr-xr-x.  4 root apache 4096 Mar 10 12:56 scripts
-rw-r--r--.  1 root apache  380 Mar 10 12:56 .scrutinizer.yml
drwxr-xr-x.  5 root apache 4096 Mar 10 12:56 styles
drwxr-xr-x.  5 root apache 4096 Mar 10 12:56 styles-public
drwxr-xr-x. 12 root apache 4096 Mar 10 12:56 templates
-rw-r--r--.  1 root apache  159 Mar 30 11:11 test.php
drwxr-xr-x.  3 root apache   20 Mar 10 12:56 themes
drwxr-xr-x. 26 root apache 4096 Mar 10 12:56 third_party
drwxrwxr-x.  5 root apache   80 Mar 26 13:45 tmp
drwxrwxr-x.  6 root apache   79 Mar 10 12:57 upload

運(yùn)行 namei -l/var/www/html/limesurvey/tmp 給出:

[ec2-user@ip-x-x-x-xxx ~]$ namei -l /var/www/html/limesurvey/tmp
f: /var/www/html/limesurvey/tmp
drwxr-xr-x root root   /
drwxr-xr-x root root   var
drwxr-xr-x root root   www
drwxr-xr-x root root   html
drwxr-xr-x root apache limesurvey
drwxrwxr-x root apache tmp

推薦答案

經(jīng)過(guò)反復(fù)思考,發(fā)現(xiàn) SELinux 正在阻止寫入目錄.我發(fā)現(xiàn)了一個(gè) good說(shuō)明發(fā)生了什么的教程.我可以通過(guò)運(yùn)行以下命令修復(fù)它:

After much head-scratching, it transpired that SELinux was preventing the directory from being written to. I found a good tutorial that explains what's going on. I was able to fix it by running this command:

sudo chcon -R -t httpd_sys_rw_content_t tmp

這篇關(guān)于PHP is_writable() 函數(shù)對(duì)于可寫目錄總是返回 false的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Joining 2 tables in SELECT(MYSQL/PHP)(在 SELECT(MYSQL/PHP) 中加入 2 個(gè)表)
How to make lt;option selected=quot;selectedquot;gt; set by MySQL and PHP?(如何使lt;option selected=“selectedgt;由 MySQL 和 PHP 設(shè)置?)
Auto populate a select box using an array in PHP(使用 PHP 中的數(shù)組自動(dòng)填充選擇框)
PHP SQL SELECT where like search item with multiple words(PHP SQL SELECT where like search item with multiple words)
json_encode produce JSON_ERROR_UTF8 from MSSQL-SELECT(json_encode 從 MSSQL-SELECT 產(chǎn)生 JSON_ERROR_UTF8)
MySQL ORDER BY rand(), name ASC(MySQL ORDER BY rand(),名稱 ASC)
主站蜘蛛池模板: 久久精品亚洲精品 | 精品一二区 | 欧美性大战xxxxx久久久 | av中文字幕在线播放 | 黄色片在线网站 | 欧美韩一区二区三区 | 观看毛片| 99视频在线看 | 一区二区免费 | 亚州精品天堂中文字幕 | 国产精品一区一区 | 成人影院在线视频 | 精品日韩一区 | 国产第一亚洲 | 午夜在线小视频 | 欧美精品欧美精品系列 | 在线免费观看黄a | 午夜视频在线 | 激情久久网 | av网址在线播放 | 欧美日韩国产精品一区 | 97碰碰碰| 色综合天天天天做夜夜夜夜做 | 日韩一级免费大片 | 99精品视频在线观看 | 毛片免费观看 | 久久综合av | 国产精品毛片一区二区三区 | 色av一区 | 欧美日韩久久精品 | 亚洲精品中文在线观看 | 最新日韩在线视频 | 国产高清视频 | 亚洲一区二区av | 中文字幕亚洲精品 | 色资源在线| 日韩精品在线视频免费观看 | 国产亚洲精品综合一区 | 91av亚洲| 成人精品视频免费 | 九九热精品视频 |