LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   CentOS (https://www.linuxquestions.org/questions/centos-111/)
-   -   Apache can't save files to mounted directory (https://www.linuxquestions.org/questions/centos-111/apache-cant-save-files-to-mounted-directory-4175658161/)

jaifar 07-28-2019 09:10 AM

Apache can't save files to mounted directory
 
I have bought WD myCloud storage and I have mount it to centos 7 by adding this line to fstab

Code:

\wd_mycloud_ip_address\shared_folder /backup cifs rw,suid,username=shared_folder_username,password=shared_folder_password 0 0
after that i mount using

Code:

mount -a
it works fine, and I am able to insert/create/delete files into the /backup which is mirrored into the WD storage Note that the directory /backup has chown root:root

the problem now when I want to let the apache (using php web application) itself save files into the mounted directory /backup , I am getting an error in my web application "The destination folder is not writable."

I tried diffrent senario to solve the issue but unfortuntly it dosen't works fine.

First I have umount the /backup, changed the

Code:

chown -R apache:apache /backup
, the web application is able to save the files. but the problem this only when I umount.

second, while the /backup is mounted with "chown root:root", I have tried to change it is owner/group to apache:apache but it doesn't allow. the commend goes without an error but when I "ls -al" it show me it is still root:root.

How can I mount a /backup directory using root:root and at the same time let the web application save files into /backup using apache:apache ?

scasey 07-28-2019 09:21 AM

Quote:

Originally Posted by jaifar (Post 6019262)
How can I mount a /backup directory using root:root and at the same time let the web application save files into /backup using apache:apache ?

The directory must be writeable by the apache user or group.

jaifar 07-28-2019 09:53 AM

Quote:

Originally Posted by scasey (Post 6019266)
The directory must be writeable by the apache user or group.

I know this, but when I change the permission to apache:apache in order to resolve "writeable" issue, it doesn't change from root.

ehartman 07-28-2019 11:22 AM

Quote:

Originally Posted by jaifar (Post 6019277)
I know this, but when I change the permission to apache:apache in order to resolve "writeable" issue, it doesn't change from root.

You cannot change the owner/group from a FAT, NTFS or CIFS volume, mount just simulates an owner as those fs'es do not have the concept of ownership and/or group.
So ALL the files on your CIFS volume are always owned by the mount uid and gid.
Except for readonly/readwrite they haven't got the same permissions either, those too are simulated by the umask (cq fmask/dmask) options ON the mount command.

Probably easiest is to mount it with "you" as owner (so you can access it) and "apache" (or sometimes httpd) as the group (so apache can access it) and with a umask that allows writing by the group (like 002).

scasey 07-28-2019 05:32 PM

Yes. You don't (can't) change the ownership of the mount. You need to change the ownership/permissions of the specific directory within that mount you want apache to be able to write to...and typically only that directory.

jaifar 07-28-2019 09:25 PM

I have added apache uid and gid to the mount statement and deleted suid as following


Quote:

\wd_mycloud_ip_address\shared_folder /backup cifs rw,uid=apache_user_id,gid=apache_group_id,username=shared_folder_username,password=shared_folder_pas sword 0 0
thanks to all...


All times are GMT -5. The time now is 06:38 AM.