PHP5.3(作为Apache模块)无法写入/var/www/<project-name>/<document-root>/cache

标签 php linux apache fedora privileges

请耐心阅读,因为问题似乎很明显,但只是看起来。 情况是:

1.

OS:     fedora-16 (latest),
httpd:  apache-2.2.21,
php:    php-5.3.8 (works as apache's module)

2. 主机信息:

DOCUMENT_ROOT: /var/www/[site-name]/public_html
Kohana-3.2.0 (latest stable) installed this way:

$ pwd
/var/www/<site-name>

$ ls -alp
drwxr-xr-x.  6 apache apache 4096 Jan   7 20:35 ./
drwxr-xr-x.  8 apache apache 4096 Jan   7 20:08 ../
drwxr-xr-x.  9 apache apache 4096 Jul  25 03:26 application/
drwxr-xr-x. 10 apache apache 4096 Jul  25 03:26 modules/
drwxr-xr-x.  2 apache apache 4096 Jan   7 20:35 public_html/
drwxr-xr-x. 11 apache apache 4096 Jul  25 03:26 system/

$ cd application/; ls -alp
drwxr-xr-x. 9 apache apache 4096 Jul  25 03:26 ./
drwxr-xr-x. 6 apache apache 4096 Jan   7 20:35 ../
-rwxr-xr-x. 1 apache apache 3612 Jul  25 03:22 bootstrap.php
drwxrwxrwx. 2 apache apache 4096 Jan   8 20:14 cache/
drwxr-xr-x. 4 apache apache 4096 Jul  25 03:26 classes/
drwxr-xr-x. 2 apache apache 4096 Jul  25 03:26 config/
drwxr-xr-x. 2 apache apache 4096 Jul  25 03:26 i18n/
drwxrwxrwx. 2 apache apache 4096 Jul  25 03:26 logs/
drwxr-xr-x. 2 apache apache 4096 Jul  25 03:26 messages/
drwxr-xr-x. 2 apache apache 4096 Jul  25 03:26 views/

Command `top` says that Apache is really starts under `apache` user privileges.

那么如何才能使 application/cache 和 application/logs 目录不可写呢? - 我也检查过它们

var_dump(fopen($_SERVER['DOCUMENT_ROOT'] . '/../application/cache/something.txt', 'w+'));

相同的结果。不知道怎么会这样。没有符号链接(symbolic link),没有安装的驱动器等。 有人遇到过这样的情况吗?

最佳答案

禁用 selinux ( http://www.crypt.gen.nz/selinux/disable_selinux.html )。

顺便说一句,从安全角度来看,让 apache 成为 .php 文件的所有者是一个非常糟糕的主意

关于PHP5.3(作为Apache模块)无法写入/var/www/<project-name>/<document-root>/cache,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8857755/

相关文章:

php - group mysql 结果为多维数组

php - 如何在日期中添加连字符(无分隔符)

php - Laravel (5.7) Eloquent 多对多,双方都有查询

php - Apache 配置 ssl

php - apache + Varnish + nginx + ssl + wordpress将所有http流量重定向到https

python - 递归搜索 python 脚本

linux - 如何做目录之间的精度比较?

linux - 解压然后在linux中处理

c - 将配置参数从 apache.conf 传递到自定义 apache C 模块?

php - 推荐一个 PHP 脚本来创建 XML 站点地图? (爬/刮方法)