LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > CentOS
User Name
Password
CentOS This forum is for the discussion of CentOS Linux. Note: This forum does not have any official participation.

Notices


Reply
  Search this Thread
Old 07-28-2019, 09:10 AM   #1
jaifar
LQ Newbie
 
Registered: Jul 2019
Posts: 4

Rep: Reputation: Disabled
Question 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 ?
 
Old 07-28-2019, 09:21 AM   #2
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,735

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Quote:
Originally Posted by jaifar View Post
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.
 
Old 07-28-2019, 09:53 AM   #3
jaifar
LQ Newbie
 
Registered: Jul 2019
Posts: 4

Original Poster
Rep: Reputation: Disabled
Lightbulb

Quote:
Originally Posted by scasey View Post
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.
 
Old 07-28-2019, 11:22 AM   #4
ehartman
Senior Member
 
Registered: Jul 2007
Location: Delft, The Netherlands
Distribution: Slackware
Posts: 1,674

Rep: Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888
Quote:
Originally Posted by jaifar View Post
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).
 
1 members found this post helpful.
Old 07-28-2019, 05:32 PM   #5
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,735

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
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.
 
Old 07-28-2019, 09:25 PM   #6
jaifar
LQ Newbie
 
Registered: Jul 2019
Posts: 4

Original Poster
Rep: Reputation: Disabled
Thumbs up

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...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Made a root directory and mounted read-only files there, can't remove them now Chripcikas Linux - Newbie 2 12-12-2018 05:33 PM
Trying to gzip all my files in one directory then save in another directory Ciik13 Linux - Newbie 2 10-13-2009 06:11 PM
iptables-save can't save settings Actionscript3 Linux - Software 4 01-29-2009 10:26 AM
Apache Directory Listing Of NFS Mount, cannot view directory list via apache luqmana Linux - Networking 2 12-19-2005 06:03 AM
NFS: a mounted to b, b mounted to c, c can't read a? Steve Cronje Linux - Networking 9 10-25-2004 09:51 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > CentOS

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration