RHEL + PHP:外写入文件在/ var / www / html等? [英] RHEL + PHP : writing files outside /var/www/html?

查看:160
本文介绍了RHEL + PHP:外写入文件在/ var / www / html等?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图打开读/写文件。我一直在开发Ubuntu上,暂时还没有任何问题。现在是时候部署到RHEL服务器,我发现似乎有一个文件的位置某种限制被写入。

I'm trying to open a file for read/write. I've been developing on Ubuntu, and have had no problems whatsoever. Now it's time to deploy to the RHEL server, and I discover there seems to be some kind of restriction on the location of a file to be written.

在RHEL,我不能,除非它是在/ var / www / html等打开该文件。我无法弄清楚如何让其他位置。我需要处理不同的卷上的文件,磁盘空间管理的原因。

On RHEL, I can't open the file unless it's under /var/www/html. I can't figure out how to allow other locations. I need to manipulate files on a different volume, for disk space management reasons.

以下是code的是Ubuntu上正常工作无论在什么位,但在RHEL休息,如果该文件是Web根目录以外的:

The following is the bit of code that works fine on Ubuntu no matter what, but breaks on RHEL if the file is outside the web root:

$repometa = fopen( "/path/to/file/it/does/exist/and/has/good/perms", "r+b");

实际的错误如下所示,这是不可思议的,因为权限是蛮好的(由阿帕奇用户所拥有的,与0644烫发的文件,755在显示目录)。

The actual error is as follows, which is weird, because the permissions are just fine (owned by the "apache" user, with 0644 perms on file, 755 on dirs).

fopen(<thefile>): failed to open stream: Permission denied

有人能指出我介绍如何取消打破RHEL的阿帕奇/ PHP的配置允许文件系统写入备用位置的文件?

Can someone point me to the documents that describe how to un-break RHEL's Apache/PHP config to allow writing to alternate locations on the file system?

谢谢,
  〜保

Thanks, ~ Paul

推荐答案

由于写在 httpd_selinux(8)手册页,你必须给文件和目录的特定文件的上下文如果你希望能够读取或写信给他们。详情请参见手册页,牢记PHP脚本运行的后台程序,除非你已经专门设置了PHP作为CGI运行。

As written in the httpd_selinux(8) man page, you must give files and directories specific file contexts if you want to be able to read from or write to them. See the man page for details, keeping in mind that PHP scripts run as the daemon unless you have specifically set up PHP to run as CGI.

这篇关于RHEL + PHP:外写入文件在/ var / www / html等?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆