Permissions on a mounted NFS share
I am trying to make a php script on a webserver write into a folder /data on a fileserver.
Apache 2.2, PhP 5.x. It's just a test configuration but I'd like to understand the thing somehow as I am not very experienced regarding permissions when it comes to webservers.
I am sharing the folder /data on the fileserver by adding
/data 192.168.20.6(rw,sync,no_subtree_check)
Mount the folder by
sudo mount 192.168.20.5:/data /mnt/data
Create a link to the webroot(does that makes sense at all?)
sudo ln -s /mnt/data /webroot/site1/share
Then I get this:
Warning: fopen(/webroot/site1/share/data/uploads/Fotoraum/Original/Bluehend/test.txt): failed to open stream: Permission denied
Where and how do I have to adjust permissions in a sane manner to allow the script to write into /data and its subfolders?
Thanks a lot!
php nfs
bumped to the homepage by Community♦ 3 hours ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
|
show 5 more comments
I am trying to make a php script on a webserver write into a folder /data on a fileserver.
Apache 2.2, PhP 5.x. It's just a test configuration but I'd like to understand the thing somehow as I am not very experienced regarding permissions when it comes to webservers.
I am sharing the folder /data on the fileserver by adding
/data 192.168.20.6(rw,sync,no_subtree_check)
Mount the folder by
sudo mount 192.168.20.5:/data /mnt/data
Create a link to the webroot(does that makes sense at all?)
sudo ln -s /mnt/data /webroot/site1/share
Then I get this:
Warning: fopen(/webroot/site1/share/data/uploads/Fotoraum/Original/Bluehend/test.txt): failed to open stream: Permission denied
Where and how do I have to adjust permissions in a sane manner to allow the script to write into /data and its subfolders?
Thanks a lot!
php nfs
bumped to the homepage by Community♦ 3 hours ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
I suppose the warning is from a webserver? They typically run under a separate user, e.g.www
. You mounted usingsudo
, hence the mountpoint is owned byroot
. Please post the output ofls -ld /mnt/data
andsu <www-user>; touch /webroot/site1/share/foo.txt
– Sebastian
Sep 9 '14 at 21:26
btw, using a mounted nfs volume might not be a very good idea: (a) if the fileserver is offline, the webservice stops working (b) network/server latency. Perhaps it's better store the files locally and then sync them over regularily?
– Sebastian
Sep 9 '14 at 21:30
make sure that user that is creating a link has ownership ofdata
folder.
– Raza
Sep 9 '14 at 21:59
mammal here :) @sebastian drwxr-xr-x 14 nobody nogroup 4096 Sep 9 22:36 /mnt/data
– mammal
Sep 11 '14 at 18:32
@sebastian Doing the ls -ld on the link gives me this lrwxrwxrwx 1 root root 9 Sep 11 21:54 data -> /mnt/data btw the files that we put on the nfs are just the huge original files of the pictures we store. Smaller resized versions are on local storage ;) To behonest, I don't know who the www-user is...
– mammal
Sep 11 '14 at 20:00
|
show 5 more comments
I am trying to make a php script on a webserver write into a folder /data on a fileserver.
Apache 2.2, PhP 5.x. It's just a test configuration but I'd like to understand the thing somehow as I am not very experienced regarding permissions when it comes to webservers.
I am sharing the folder /data on the fileserver by adding
/data 192.168.20.6(rw,sync,no_subtree_check)
Mount the folder by
sudo mount 192.168.20.5:/data /mnt/data
Create a link to the webroot(does that makes sense at all?)
sudo ln -s /mnt/data /webroot/site1/share
Then I get this:
Warning: fopen(/webroot/site1/share/data/uploads/Fotoraum/Original/Bluehend/test.txt): failed to open stream: Permission denied
Where and how do I have to adjust permissions in a sane manner to allow the script to write into /data and its subfolders?
Thanks a lot!
php nfs
I am trying to make a php script on a webserver write into a folder /data on a fileserver.
Apache 2.2, PhP 5.x. It's just a test configuration but I'd like to understand the thing somehow as I am not very experienced regarding permissions when it comes to webservers.
I am sharing the folder /data on the fileserver by adding
/data 192.168.20.6(rw,sync,no_subtree_check)
Mount the folder by
sudo mount 192.168.20.5:/data /mnt/data
Create a link to the webroot(does that makes sense at all?)
sudo ln -s /mnt/data /webroot/site1/share
Then I get this:
Warning: fopen(/webroot/site1/share/data/uploads/Fotoraum/Original/Bluehend/test.txt): failed to open stream: Permission denied
Where and how do I have to adjust permissions in a sane manner to allow the script to write into /data and its subfolders?
Thanks a lot!
php nfs
php nfs
edited Sep 10 '14 at 0:55
Ramesh
23.3k32101182
23.3k32101182
asked Sep 9 '14 at 21:20
mammal
612
612
bumped to the homepage by Community♦ 3 hours ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
bumped to the homepage by Community♦ 3 hours ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
I suppose the warning is from a webserver? They typically run under a separate user, e.g.www
. You mounted usingsudo
, hence the mountpoint is owned byroot
. Please post the output ofls -ld /mnt/data
andsu <www-user>; touch /webroot/site1/share/foo.txt
– Sebastian
Sep 9 '14 at 21:26
btw, using a mounted nfs volume might not be a very good idea: (a) if the fileserver is offline, the webservice stops working (b) network/server latency. Perhaps it's better store the files locally and then sync them over regularily?
– Sebastian
Sep 9 '14 at 21:30
make sure that user that is creating a link has ownership ofdata
folder.
– Raza
Sep 9 '14 at 21:59
mammal here :) @sebastian drwxr-xr-x 14 nobody nogroup 4096 Sep 9 22:36 /mnt/data
– mammal
Sep 11 '14 at 18:32
@sebastian Doing the ls -ld on the link gives me this lrwxrwxrwx 1 root root 9 Sep 11 21:54 data -> /mnt/data btw the files that we put on the nfs are just the huge original files of the pictures we store. Smaller resized versions are on local storage ;) To behonest, I don't know who the www-user is...
– mammal
Sep 11 '14 at 20:00
|
show 5 more comments
I suppose the warning is from a webserver? They typically run under a separate user, e.g.www
. You mounted usingsudo
, hence the mountpoint is owned byroot
. Please post the output ofls -ld /mnt/data
andsu <www-user>; touch /webroot/site1/share/foo.txt
– Sebastian
Sep 9 '14 at 21:26
btw, using a mounted nfs volume might not be a very good idea: (a) if the fileserver is offline, the webservice stops working (b) network/server latency. Perhaps it's better store the files locally and then sync them over regularily?
– Sebastian
Sep 9 '14 at 21:30
make sure that user that is creating a link has ownership ofdata
folder.
– Raza
Sep 9 '14 at 21:59
mammal here :) @sebastian drwxr-xr-x 14 nobody nogroup 4096 Sep 9 22:36 /mnt/data
– mammal
Sep 11 '14 at 18:32
@sebastian Doing the ls -ld on the link gives me this lrwxrwxrwx 1 root root 9 Sep 11 21:54 data -> /mnt/data btw the files that we put on the nfs are just the huge original files of the pictures we store. Smaller resized versions are on local storage ;) To behonest, I don't know who the www-user is...
– mammal
Sep 11 '14 at 20:00
I suppose the warning is from a webserver? They typically run under a separate user, e.g.
www
. You mounted using sudo
, hence the mountpoint is owned by root
. Please post the output of ls -ld /mnt/data
and su <www-user>; touch /webroot/site1/share/foo.txt
– Sebastian
Sep 9 '14 at 21:26
I suppose the warning is from a webserver? They typically run under a separate user, e.g.
www
. You mounted using sudo
, hence the mountpoint is owned by root
. Please post the output of ls -ld /mnt/data
and su <www-user>; touch /webroot/site1/share/foo.txt
– Sebastian
Sep 9 '14 at 21:26
btw, using a mounted nfs volume might not be a very good idea: (a) if the fileserver is offline, the webservice stops working (b) network/server latency. Perhaps it's better store the files locally and then sync them over regularily?
– Sebastian
Sep 9 '14 at 21:30
btw, using a mounted nfs volume might not be a very good idea: (a) if the fileserver is offline, the webservice stops working (b) network/server latency. Perhaps it's better store the files locally and then sync them over regularily?
– Sebastian
Sep 9 '14 at 21:30
make sure that user that is creating a link has ownership of
data
folder.– Raza
Sep 9 '14 at 21:59
make sure that user that is creating a link has ownership of
data
folder.– Raza
Sep 9 '14 at 21:59
mammal here :) @sebastian drwxr-xr-x 14 nobody nogroup 4096 Sep 9 22:36 /mnt/data
– mammal
Sep 11 '14 at 18:32
mammal here :) @sebastian drwxr-xr-x 14 nobody nogroup 4096 Sep 9 22:36 /mnt/data
– mammal
Sep 11 '14 at 18:32
@sebastian Doing the ls -ld on the link gives me this lrwxrwxrwx 1 root root 9 Sep 11 21:54 data -> /mnt/data btw the files that we put on the nfs are just the huge original files of the pictures we store. Smaller resized versions are on local storage ;) To behonest, I don't know who the www-user is...
– mammal
Sep 11 '14 at 20:00
@sebastian Doing the ls -ld on the link gives me this lrwxrwxrwx 1 root root 9 Sep 11 21:54 data -> /mnt/data btw the files that we put on the nfs are just the huge original files of the pictures we store. Smaller resized versions are on local storage ;) To behonest, I don't know who the www-user is...
– mammal
Sep 11 '14 at 20:00
|
show 5 more comments
2 Answers
2
active
oldest
votes
per your comment I think the following option is better than chmod -R 775 /mnt/data
when using mount
, you can specify the user and group which owns the files, maybe you want to use the following:
sudo mount 192.168.20.5:/data /mnt/data -o uid=<uid-of-www-data>,gid=<gid-of-www-data>
the values uid
and gid
of www-data
can be found in /etc/passwd
and /etc/group
.
The uid and gid options do not apply to NFS mounts. (Perhaps you're confusing NTFS?)
– roaima
Aug 22 '17 at 22:54
add a comment |
You can do chmod 6777 on the shared folder from the nfs server, so that any files being created on the file belongs to the owner group of the folder.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f154679%2fpermissions-on-a-mounted-nfs-share%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
per your comment I think the following option is better than chmod -R 775 /mnt/data
when using mount
, you can specify the user and group which owns the files, maybe you want to use the following:
sudo mount 192.168.20.5:/data /mnt/data -o uid=<uid-of-www-data>,gid=<gid-of-www-data>
the values uid
and gid
of www-data
can be found in /etc/passwd
and /etc/group
.
The uid and gid options do not apply to NFS mounts. (Perhaps you're confusing NTFS?)
– roaima
Aug 22 '17 at 22:54
add a comment |
per your comment I think the following option is better than chmod -R 775 /mnt/data
when using mount
, you can specify the user and group which owns the files, maybe you want to use the following:
sudo mount 192.168.20.5:/data /mnt/data -o uid=<uid-of-www-data>,gid=<gid-of-www-data>
the values uid
and gid
of www-data
can be found in /etc/passwd
and /etc/group
.
The uid and gid options do not apply to NFS mounts. (Perhaps you're confusing NTFS?)
– roaima
Aug 22 '17 at 22:54
add a comment |
per your comment I think the following option is better than chmod -R 775 /mnt/data
when using mount
, you can specify the user and group which owns the files, maybe you want to use the following:
sudo mount 192.168.20.5:/data /mnt/data -o uid=<uid-of-www-data>,gid=<gid-of-www-data>
the values uid
and gid
of www-data
can be found in /etc/passwd
and /etc/group
.
per your comment I think the following option is better than chmod -R 775 /mnt/data
when using mount
, you can specify the user and group which owns the files, maybe you want to use the following:
sudo mount 192.168.20.5:/data /mnt/data -o uid=<uid-of-www-data>,gid=<gid-of-www-data>
the values uid
and gid
of www-data
can be found in /etc/passwd
and /etc/group
.
answered Sep 12 '14 at 12:36
Sebastian
5,28632947
5,28632947
The uid and gid options do not apply to NFS mounts. (Perhaps you're confusing NTFS?)
– roaima
Aug 22 '17 at 22:54
add a comment |
The uid and gid options do not apply to NFS mounts. (Perhaps you're confusing NTFS?)
– roaima
Aug 22 '17 at 22:54
The uid and gid options do not apply to NFS mounts. (Perhaps you're confusing NTFS?)
– roaima
Aug 22 '17 at 22:54
The uid and gid options do not apply to NFS mounts. (Perhaps you're confusing NTFS?)
– roaima
Aug 22 '17 at 22:54
add a comment |
You can do chmod 6777 on the shared folder from the nfs server, so that any files being created on the file belongs to the owner group of the folder.
add a comment |
You can do chmod 6777 on the shared folder from the nfs server, so that any files being created on the file belongs to the owner group of the folder.
add a comment |
You can do chmod 6777 on the shared folder from the nfs server, so that any files being created on the file belongs to the owner group of the folder.
You can do chmod 6777 on the shared folder from the nfs server, so that any files being created on the file belongs to the owner group of the folder.
answered Dec 11 '17 at 6:21
sunical
1
1
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f154679%2fpermissions-on-a-mounted-nfs-share%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I suppose the warning is from a webserver? They typically run under a separate user, e.g.
www
. You mounted usingsudo
, hence the mountpoint is owned byroot
. Please post the output ofls -ld /mnt/data
andsu <www-user>; touch /webroot/site1/share/foo.txt
– Sebastian
Sep 9 '14 at 21:26
btw, using a mounted nfs volume might not be a very good idea: (a) if the fileserver is offline, the webservice stops working (b) network/server latency. Perhaps it's better store the files locally and then sync them over regularily?
– Sebastian
Sep 9 '14 at 21:30
make sure that user that is creating a link has ownership of
data
folder.– Raza
Sep 9 '14 at 21:59
mammal here :) @sebastian drwxr-xr-x 14 nobody nogroup 4096 Sep 9 22:36 /mnt/data
– mammal
Sep 11 '14 at 18:32
@sebastian Doing the ls -ld on the link gives me this lrwxrwxrwx 1 root root 9 Sep 11 21:54 data -> /mnt/data btw the files that we put on the nfs are just the huge original files of the pictures we store. Smaller resized versions are on local storage ;) To behonest, I don't know who the www-user is...
– mammal
Sep 11 '14 at 20:00