CentOS 共享 windows 文件夹
操作步骤如下:
1、挂载命令
mount -t cifs -o username=user,password=123456,gid=500,uid=500 //{ip}/upload /share/upload
2、遇到的问题及解决方法
a、mount: block device //{ip}/upload is write-protected, mounting read-only
mount: cannot mount block device //{ip}/result read-only
或 mount: wrong fs type, bad option, bad superblock on \{ip}{dir}
missing codepage or helper program, or other error
(for several filesystems (e.g. nfs, cifs) you might
need a /sbin/mount. helper program)
In some cases useful info is found in syslog - try
dmesg | tail or so
解决方法:
yum search cifs
yum install -y cifs-utils
b、mount error(13): Permission denied
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
解决方法:切换用户。
c、umount: /mnt/files: device is busy.
(In some cases useful info about processes that use
the device is found by lsof(8) or fuser(1))
解决方法:退出一次窗口。
d、mount -t cifs -ro username=user,password=123456 //{ip}/[{dir}/{dir}/{dir}] /share/upload
提示:mount: //{ip}/upload is not a valid block device
原因:只能挂一层
解决方法:windows 上面 FileUpload 目录设置共享,命令修改为:
mount -t cifs -o username=user,password=123456 //{ip}/upload /share/upload
e、上传文件:提示 The upload destination folder does not appear to be writable.(没有写入权限)
解决方法:挂载时设置权限组,命令如下:mount -t cifs -o username=user,password=123456,gid=500,uid=500 //{ip}/upload /share/upload
500 为 www。
f、mount -t cifs -o username=user,password=123456 \{ip}/{dir} /share/upload
出现错误提示:mount.cifs: bad UNC (\{ip}/{dir})
正确为:mount -t cifs -o username=user,password=123456 //{ip}/{dir} /share/upload
3、项目中的使用步骤
1、创建文件夹,修改拥有者权限
2、挂载 mount -t cifs -o username=guest,password=”“,gid=501,uid=501 //192.168.1.24/upload /share/upload
3、创建软链接
cd /usr/local/nginx/html/website/
ln -s /share/upload upload
遇到的问题:
PHP 写入文件时出现:The upload destination folder does not appear to be writable
解决方法:挂载时指定目录权限或者挂载命令增加 gid=501,uid=501。
参考资料:
http://blog.sina.com.cn/s/blog_544f183101013zd7.html
http://blog.csdn.net/pearhuaer/article/details/8681359
版权声明: 本文为 InfoQ 作者【风翱】的原创文章。
原文链接:【http://xie.infoq.cn/article/741b940b651b5f8b87170a6b6】。
本文遵守【CC-BY 4.0】协议,转载请保留原文出处及本版权声明。
评论