Can't open file in php if one of directories i

2019-08-03 05:27发布

问题:

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.

I have symlink

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

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 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).

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?

回答1:

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

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 path symlink