允许php文件写入除www-data拥有的位置之外的其他位置 [英] allow php files to write to locations other than those owned by www-data

查看:97
本文介绍了允许php文件写入除www-data拥有的位置之外的其他位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我能够将浏览器中打开的php文件中的内容写入到我按如下配置的某个位置/var/www/data

I am able to write content from a php file opened in the browser to a certain location /var/www/data which I configured as follows

cd /var/www/
sudo mkdir data
sudo chown www-data:www-data data
sudo chmod 755 data

但是,是否有可能将类似的数据写入www.data不拥有的另一个位置,例如/var/www/html/MyProjectRootFolder?

However, is it possible to write similar data to another location like /var/www/html/MyProjectRootFolder which is not owned by www-data ?

推荐答案

通常,Web服务器的配置不允许应用程序写入其自己的Doc根目录之外的文件夹.但是,您可以对文档根目录中的/var/www/data这样的位置执行符号链接/var/www/html/MyProjectRootFolder之类的操作,该应用程序已经可以 对其进行写入.

Generally the web server's configuration is not going to allow applications to write to folders outside of their own Doc root. However, you could do something like symlink /var/www/html/MyProjectRootFolder to a location like /var/www/data within your Doc root that the application already can write to.

根据情况,您可能还需要确保Web服务器用户仍然对符号链接的内容具有读取权限,或者也不起作用.

Depending, you may also need to make sure that the web server user still has read permissions to the symlinked content, or that won't work either.

这篇关于允许php文件写入除www-data拥有的位置之外的其他位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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