As far as file permissions are concerned, when you use a php script to unzip a tar file, who is the "owne开发者_运维技巧r" user of the files created?
I'm wondering if its my ftp user because I uploaded the script file? Or does apache own the file? I know their are flags to be set to preserve the original permissions which I don't want (files where created and archived by someone else). I want my user to be the creater/owner of the files.
PS Its a cloud environment. Below is the code I uploaded. I executed by visiting the page in a browser. I can change file permissions in Dreamweaver... Does that mean I am owner?
exec('wget http://wordpress.org/latest.tar.gz');
exec('tar -xzvf latest.tar.gz');
Most likely, if run from apache, the user that apache is running as.
Whatever user runs PHP. Its either the web server's system user name, or the owner of the webroot (through suexec). If owned by the server, its likely nobody
or www-data
.
What matters most is what user PHP (server side) is running as. Try this to find out.
You can do echo shell_exec('whoami');
And that will output the name of the user. For me, it outputted apache
And yes, apache will own the files. For example, if you do something like this as root:
root@localhost# cp /home/user/foo /home/user/foo2
root@localhost# ls -l /home/user
-rw-rw-r-- 1 user user 232 Apr 12 12:00 foo
-rw-rw-r-- 1 root root 232 Apr 12 12:01 foo2
精彩评论