如果目录之一是符号链接,则无法在php中打开文件 [英] Can't open file in php if one of directories is a symlink

查看:97
本文介绍了如果目录之一是符号链接,则无法在php中打开文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有3个站点处于实时,暂存和开发状态,开发站点具有实时和数据库副本中所有文件的副本,但是暂存不是,因为它们都位于同一台物理服务器上(暂存和开发),所以我想从dev同步链接文件可以生存(30GB),但是我的php脚本无法打开路径中的一个目录为symlink的文件.

I have 3 sites live, staging and development, devel site have copy of all files from live and database copy but staging is not since they are both on the same physical server (staging and devlopment) I want to synlink files from dev to live (it's 30GB) but my php script can't open files where one directory in path is symlink.

我有符号链接

/srv/www/staging.server.com/htdocs/people/ to /srv/www/dev.server.com/htdocs/people/

并且我有示例文件/srv/www/dev.server.com/htdocs/people/gnokii/zuluwarrior.svg,我可以从comman行和浏览器中访问它(通过/srv/www/staging.server.com/htdocs/people/zuluwarrior.svg),但是php无法打开该文件.

and I have example file /srv/www/dev.server.com/htdocs/people/gnokii/zuluwarrior.svg I can access it (by /srv/www/staging.server.com/htdocs/people/zuluwarrior.svg) from comman line and from the browser but php can't open that file.

file_exists返回false,而file返回空数组. (我有将svg转换为png的代码,该代码在实时服务器和开发服务器上均可工作,因此无法在暂存阶段使用).

file_exists return false and file return empty array. (I have code that convert svg to png that work on both live and dev server but don't on staging because of this).

是否有一些PHP配置无法解决Synlinks?我找到了suhosin.executor.allow_symlink = Off,但我认为它是用于执行脚本的.有什么想法,如何解决?

Is there some php config that disble synlinks? I found suhosin.executor.allow_symlink = Off but I think it's for executing scripts. Any ideas, how to fix this?

推荐答案

我发现将base_dir设置为'/srv/www/staging.server.com'并将suhosin.executor.allow_symlink设置为Off

I found the reason base_dir was set to '/srv/www/staging.server.com' and suhosin.executor.allow_symlink was set to Off

使用open_basedir时,此标志重新激活symlink(),即 在Suhosin> = 0.9.6中默认禁用.允许symlink()同时 使用open_basedir实际上是一种安全隐患.

This flag reactivates symlink() when open_basedir is used, which is disabled by default in Suhosin >= 0.9.6. Allowing symlink() while open_basedir is used is actually a security risk.

这篇关于如果目录之一是符号链接,则无法在php中打开文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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