简体   繁体   中英

Shell access to files created by Apache user in PHP

My website creates files with owner apache:apache when uploading a file, like this:


drwxr-xr-x    2 apache apache   4096 Aug 28 14:07 .
drwxr-xr-x 9118 apache apache 233472 Aug 28 14:07 ..
-rw-r--r--    1 apache apache  41550 Aug 28 14:07 468075_large.jpg
-rw-r--r--    1 apache apache  26532 Aug 28 14:07 468075_medium.jpg
-rw-r--r--    1 apache apache  50881 Aug 28 14:07 468075_original.jpg
-rw-r--r--    1 apache apache   4316 Aug 28 14:07 468075_small.jpg

Now I am trying to create a file inside the same folder with the user that owns that domain in Plesk and I get permission denied.

How can I have both apache and shell user with permissions over that files?

Thanks.

You have to create a group and put your Plesk and Apache user in it. Than you have to chmod -R g+rwX on your files.

And set the default umask of your system to 002.

If that shell user is not apache but in the same group, you will need to make the folder group writeable.

chown 755 .

As it is right now it won't allow anyone other than apache to add a folder. Or, you can try to use php to do fopen?

Thanks for the answers but I finally decided to run a cron job that will open a php script from the website using wget.

That way it's the same apache user that already has access to the files. I did this basically because I've got tons of files, about 300GB of images so it would take a lot I think to apply al the new permissions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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