Frage

I currently manage 8 different sites for my organisation and built a central management website to help manage the content on them all.

I currently have a file uploader on the administration website that allows me to upload ZIP files to the server. This script then unzips the package, and moves the files to different parts of the server.

The problem is, when I upload files through the browser, it assigns ownership to apache (for both user and group). This causes me a problem when I try to overwrite the files using FTP.

I have tried to change the owner of the uploaded files as soon as they've been uploaded / moved, both with PHPs native 'chown' function and also using the exec function to run the linux command chown but both fail (PHPs native chown displays an 'operation not permitted' error)

So my questions: 1) Am I going about this the wrong way? (My knowledge of file ownership is limited) 2) Is there a reason why I shouldn't change file ownership? 3) Are there any work arounds?

If you would like any more information, please feel free to ask.

Many thanks

Phil

Current file details of file uploaded via browser:

[file].php      permissions: adfr (0644)    Owner: Apache    Group: Apache

File details of file uploaded via FTP:

[file].php      permissions: adfr (0644)    Owner: [ftp login name]   Group: psacln
War es hilfreich?

Lösung

I do something very similar of what you do but I dont use ftp, I use scp, part ssh. With this you can do something like this:

$> scp -rp /var/www/html/somedir/* 192.168.1.100:/var/www/html/somedir/.

This way with the p flag you tell the command to copy the files and preserve permissions, ownership, date stamps. The r flag creates subdirectories as needed and recursive copies.

Just like any other command you can place several lines of scp in a script to automatize, but to avoid password use ssh generated certificates among servers.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top