即使具有(似乎)正确的文件权限,上传目标文件夹似乎也不可写
The upload destination folder does not appear to be writable even with (seem to be) correct file permissions
我已经在这个论坛上调查过很多类似的问题,但 none 似乎解决了我的问题。
我会在底部列出我在这个论坛上看到的一些问题页面,但让我先谈谈我对这个问题的看法。
我正在使用 codeigniter v 2.x
PHP 5.5.32
MariaDB 5.5.44
CentOS 7.2.1511
下面是我的应用程序的位置 vits。
[root@VITSServer html]# pwd
/var/www/html
[root@VITSServer html]# ls -al
total 16
drwxrwxr-x. 6 apache apache 92 Nov 9 17:55 .
drwxr-xr-x. 4 root root 31 Nov 20 2015 ..
-rwxr--r--. 1 apache apache 1150 Oct 28 2015 favicon.ico
-rwxrwxrwx. 1 apache apache 20 Oct 12 2015 info.php
drwxrwxr-x. 11 apache apache 4096 Oct 27 2015 laravel5
drwxr-xr-x. 2 apache apache 22 Oct 14 2015 test
drwxrwxr-x. 7 apache apache 4096 Nov 10 11:16 vits
drwxr-xr-x. 3 apache apache 17 Nov 9 17:56 vits_v2.0
[root@VITSServer html]#
下面是vits目录
[root@VITSServer vits]# ll
total 1504
drwxrwxr-x. 15 apache apache 4096 Nov 9 17:27 application
drwxrwxr-x. 7 apache apache 4096 Nov 9 18:01 assets
drwxrwxrwx. 4 apache apache 8192 Nov 9 18:08 files
-rwxrwxr-x. 1 apache apache 6452 Nov 9 17:50 index.php
drwxrwxr-x. 8 apache apache 4096 Nov 9 17:27 system
-rwxrwxr-x. 1 apache apache 1503295 Nov 9 17:27 vits_db.sql
我的上传路径在"files"目录下。如上所示,我已经将它设置为 777 并将 owner:group 设置为 apache。怎么我的上传仍然 returns 一个错误指出 "The upload destination folder does not appear to be writable".
我检查了我的php_info,似乎一切都应该没问题。
现在的问题是,我是不是漏掉了什么?
我已经查看过的 Whosebug 页面:
- The upload destination folder does not appear to be writable. (Codeigniter)
- Codeigniter Permission denied images upload
- Uploading File Issue In Codeigniter
- 和许多其他...
刚刚弄明白了。
显然我的 selinux 阻止 它被上传,即使正确的权限和所有权。
我用 ff 命令禁用了我的 selinux:
setenforce 0
[更新]
或者,为了将您的 selinux 状态保持为 enabled,我们可以更改目标上传目录的上下文。
有两种方法:
via chcon command. However, changes made with the chcon command do not survive a file system relabel, or the execution of the
restorecon command
via semanage fcontext. Which is a persistent change.
希望这对其他人也有帮助。
我已经在这个论坛上调查过很多类似的问题,但 none 似乎解决了我的问题。
我会在底部列出我在这个论坛上看到的一些问题页面,但让我先谈谈我对这个问题的看法。
我正在使用 codeigniter v 2.x PHP 5.5.32 MariaDB 5.5.44 CentOS 7.2.1511
下面是我的应用程序的位置 vits。
[root@VITSServer html]# pwd
/var/www/html
[root@VITSServer html]# ls -al
total 16
drwxrwxr-x. 6 apache apache 92 Nov 9 17:55 .
drwxr-xr-x. 4 root root 31 Nov 20 2015 ..
-rwxr--r--. 1 apache apache 1150 Oct 28 2015 favicon.ico
-rwxrwxrwx. 1 apache apache 20 Oct 12 2015 info.php
drwxrwxr-x. 11 apache apache 4096 Oct 27 2015 laravel5
drwxr-xr-x. 2 apache apache 22 Oct 14 2015 test
drwxrwxr-x. 7 apache apache 4096 Nov 10 11:16 vits
drwxr-xr-x. 3 apache apache 17 Nov 9 17:56 vits_v2.0
[root@VITSServer html]#
下面是vits目录
[root@VITSServer vits]# ll
total 1504
drwxrwxr-x. 15 apache apache 4096 Nov 9 17:27 application
drwxrwxr-x. 7 apache apache 4096 Nov 9 18:01 assets
drwxrwxrwx. 4 apache apache 8192 Nov 9 18:08 files
-rwxrwxr-x. 1 apache apache 6452 Nov 9 17:50 index.php
drwxrwxr-x. 8 apache apache 4096 Nov 9 17:27 system
-rwxrwxr-x. 1 apache apache 1503295 Nov 9 17:27 vits_db.sql
我的上传路径在"files"目录下。如上所示,我已经将它设置为 777 并将 owner:group 设置为 apache。怎么我的上传仍然 returns 一个错误指出 "The upload destination folder does not appear to be writable".
我检查了我的php_info,似乎一切都应该没问题。
现在的问题是,我是不是漏掉了什么?
我已经查看过的 Whosebug 页面:
- The upload destination folder does not appear to be writable. (Codeigniter)
- Codeigniter Permission denied images upload
- Uploading File Issue In Codeigniter
- 和许多其他...
刚刚弄明白了。
显然我的 selinux 阻止 它被上传,即使正确的权限和所有权。
我用 ff 命令禁用了我的 selinux:
setenforce 0
[更新]
或者,为了将您的 selinux 状态保持为 enabled,我们可以更改目标上传目录的上下文。
有两种方法:
via chcon command. However, changes made with the chcon command do not survive a file system relabel, or the execution of the restorecon command
via semanage fcontext. Which is a persistent change.
希望这对其他人也有帮助。