Mounted NFS directory not writable by Apache / PHP

Posted by phpfour on Server Fault See other posts from Server Fault or by phpfour
Published on 2012-03-26T11:30:51Z Indexed on 2012/03/26 11:32 UTC
Read the original article Hit count: 228

Filed under:
|
|
|
|

Need some help here with NFS. Here's what I have (all servers running CentOS 5.6 with SELinux):

172.17.20.1 - Primary server with static IP. Varnish redirects requests to the web servers.
172.17.20.2 - Web server 1
172.17.20.3 - Web server 2

The application residing on the web servers is running Drupal and I need both of them to share the same files directory. I have created a folder in 172.17.20.1 called /var/nfs with root user. Here is my /etc/exports content:

/var/nfs    172.17.20.2(rw,sync,no_root_squash) 172.17.20.3(rw,sync,no_root_squash)

On both the web servers (172.17.20.2/3), I have it mounted like below:

[root@web2 ~]# mount
...
172.17.20.1:/var/nfs on /mnt/nfs/var/nfs type nfs (rw,sync,hard,intr,addr=172.17.20.1)

On all the servers, I've added the user apache to the root group to get the desired write access:

[root@main ~]# cat /etc/group
root:x:0:root,apache
....
....
apache:x:48:

[root@web1 ~]# cat /etc/group
root:x:0:root,apache
....
....
apache:x:48:

Despite all this, when I try to write files into the /mnt/nfs/var/nfs folder from Drupal/PHP, it cannot write to it. I even tried with a simple PHP upload script but it doesn't work, so the problem is not with Drupal.

Any help you guys can do is much appreciated. I've spent hours and hours with it, without any success :(

Thanks in advance.

© Server Fault or respective owner

Related posts about centos

Related posts about permissions