这里的问题与 /etc/exports 中的条目有关。它应该是
folder ip(rw,**all_squash**,sync,no_subtree_check)
我错过了 all_squash 位。除此之外,请确保服务器上的文件夹归 nfsnobody 所有。在我的设置中,如果 65534,我的客户端和服务器 nfsnobodies 都以用户 ID 结束。但是,非常值得检查这个 (/etc/groups) 或其他...。
这里有一些有用的参考资料
How to setup an NFS SErver
NFS on CentOS
为了任何想要设置 NFS 服务器的人的利益,我在下面给出了在我的 CentOS 6 64 位机器上对我有用的方法。
SERVER
yum install nfs-utils nfs-utils-lib - install NFS
rpm -q nfs-utils - check the install
/etc/init.d/rpcbind start
chkconfig --levels 235 nfs on
/etc/init.d/nfs start
chkconfig --level 35 rpcbind on
完成此操作后,您应该创建要共享的文件夹
mkdir folder
chown 65534:65534 folder
chmod 755 folder
现在定义要共享/导出的文件夹。使用您最喜欢的文本编辑器(vi 或其他)
打开/创建/etc/exports
folder clientIP (rw,all_squash,sync,no_subtree_check)
Client
Install, check, bind and start as above
mount -t nfs serverIP:folder clientFolderLocation
如果一切顺利,您现在应该可以在客户端上编写一个小脚本
<?php
$file = $_SERVER['DOCUMENT_ROOT']."/../nfsfolder/test.txt";
file_put_contents($file,'Hello world of NFS!');
?>
浏览它并发现 test.txt 现在存在于服务器上,内容为“Hello world of NFS”。在示例中,我将已安装的驱动器放置在 document_root 之前的一层。