这里的问题与输入有关/etc/出口。它应该读
folder ip(rw,**all_squash**,sync,no_subtree_check)
我错过了 all_squash 位。除此之外,请确保服务器上的文件夹归 nfsnobody 所有。在我的设置中,我的客户端和服务器 nfsnobodies 最终都以用户 ID 65534 结束。但是,非常值得检查此(/etc/groups),否则...。
这里有一些有用的参考
如何设置 NFS 服务器 http://chschneider.eu/linux/server/nfs.shtml
CentOS 上的 NFS http://www.howtoforge.com/setting-up-an-nfs-server-and-client-on-centos-5.5
为了让任何想要设置 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 之前的一级。