wil*_*ler 6 php linux accessibility
好的,有没有办法让 PHP 用户(www-data)访问服务器的其他部分,例如 /home/username/another_folder/ ?提前致谢。
将要
编辑:我是否只是将 www-data 添加到另一个组?或者类似的事情,或者还有其他方法吗?
您可以创建另一个组并将www-data(如果您的网络服务器在www-data用户下运行)添加到该组,然后将该组分配给您想要访问的所有文件。
或者,如果您只需要读取权限,并且系统上的其他用户对您的文件具有读取权限不是问题,那么只需更改您的文件(在其他地方)的权限以具有other. 例如,775对于您的目录和644文件。
请记住,即使您的网络服务器用户有权访问这些文件,您也无法在文档根目录(例如 /var/www)以外的位置提供页面。
但是,如果您为 Web 服务器配置“别名”或“虚拟主机”,则可以通过 HTTP 请求访问默认文档根目录以外的位置。
但是,如果 Web 服务器用户具有足够的权限,则位于文档根目录下并由 Web 服务器执行的 PHP 文件可以读取文档根目录之外的文件内容。
// file permissoins
/tmp/shared_by_all.txt -> 644
/home/user1 -> 751 or 755
/home/user1/shared_by_all.txt -> 644
/home/secureuser -> 750
/home/secureuser/myfile.txt -> 640 (or even 644 because of the containing directory permissions, other can not even enter the directory tree. so file is not accessible)
// file: /var/www/read_file.php
<?php
echo file_get_contents('/tmp/shared_by_all.txt'); // ok!
echo file_get_contents('/home/user1/shared_by_all.txt'); // ok!;
echo file_get_contents('/home/secureuser/myfile.txt'); // fail!;
?>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7763 次 |
| 最近记录: |