简体   繁体   English

Apache服务器文件权限

[英]Apache server file permissions

I know this was brought up many times. 我知道这是多次提出来的。 Still I can not find a sutable answer. 我仍然找不到合适的答案。

I want to upload a file to a server and want to set temporary 777 permission to the file where I put content. 我想将文件上传到服务器,并想对放置内容的文件设置777临时权限。 I am the only owner of the file and the directory and it does not seem to be an option to change or add an owner from the control panel and I dont want to set 777 to that folder. 我是文件和目录的唯一所有者,似乎不是从控制面板更改或添加所有者的选项,并且我不想将777设置为该文件夹。 Since neither apache nor script own the file chmod does not work. 由于apache和script都不拥有,因此文件chmod不起作用。 Is there a way to get the ownership to php, a particular script or the server throught chown function? 有没有办法通过chown函数将所有权授予php,特定脚本或服务器? The script that POST a file is not publically accessible btw. POST文件的脚本不可公开访问。

Thanks. 谢谢。

Dunno if I am right or not. 邓诺,如果我是对的。
First you can get the owner of the file with this 首先,您可以通过以下方式获取文件的所有者

$filename = 'index.php';
print_r(posix_getpwuid(fileowner($filename)));

with

chmod('/var/www/folder/', 0777)
chmod('/var/www/folder/index.php', 0777)

you can change any folder or file to 0777 您可以将任何文件夹或文件更改为0777
you can also check with chmod the file or folder have 您也可以使用chmod检查文件或文件夹是否具有

if( chmod($path, 0777) ) {
    chmod($path, 0755);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM