LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Apache + Php server file owners and user groups (https://www.linuxquestions.org/questions/linux-server-73/apache-php-server-file-owners-and-user-groups-626855/)

Seregwethrin 03-09-2008 03:58 PM

Apache + Php server, file folder owners and user groups
 
Hello friends;

I've apache 1.3 and php5 server (CentOS 4) with proftpd.

Apache runs at User: apache, Group: web

User directories like this
/home/xxx.com/public_html (User: xxx.com, Group: web - and all subfiles,subfolders)

/home/yyy.net/public_html (User: yyy.net, Group: web - and all subfiles,subfolders)

And I've proftpd server. All users have their own ftp access to only their homes.

Everything works great. But I've two questions.

1) When i upload a file with php over apache, uploaded files owner are apache, group are web. Apache's user and group. How can i change it's owner to xxx.com or yyy.net after upload? Or is there any other solution ?

Suexec: If i run apache with site's users (xxx.com user for /home/xxx.com, and yyy.net user for /home/yyy.net) all scripts will have write and delete access at their site. So that i don't need to chmod folders to 0777 for reading and writing. Site panels (plesk, cpanel vs..) are different.

2) All sites have the same group, so i can read all files. I can access xxx.com's files from yyy.net. How can i disable this?

rylan76 03-11-2008 01:39 PM

Quote:

Originally Posted by Seregwethrin (Post 3083316)
Hello friends;

1) When i upload a file with php over apache, uploaded files owner are apache, group are web. Apache's user and group. How can i change it's owner to xxx.com or yyy.net after upload? Or is there any other solution ?

In php, after uploading the file, can't you just do something like

exec('chown owner.owner filename.ext');

I know php has a chmod() that you can do, I think it also has a chgrp() / chown() filesystem library call in the PHP core?

I. e. you upload the file, then change it with PHP to another group / user that is NOT Apache's "nobody" user?

Seregwethrin 03-11-2008 02:15 PM

Yes i can do it with php but i want it automatic.

For example, editing scripts like vBulletin, IPB, Joomla for that is very difficult.


All times are GMT -5. The time now is 04:59 AM.