把Linux虚拟机中代码挂载到Mac下进行编辑
作者: 何忠利 • 发表于 2019-02-22
这边就不介绍NFS是什么了,自行百度下肯定比我说的好。
1.我的虚拟机系统(centos)
[root@localhost ~]# uname -a
Linux localhost.localdomain 3.10.0-862.el7.x86_64 #1 SMP Fri Apr 20 16:44:24 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
2.虚拟机的IP(10.211.55.30)
[root@localhost ~]# ifconfig
```
inet 10.211.55.30 netmask 255.255.255.0 broadcast 10.211.55.255
```
3.检查是否有NFS所需要的两个包(没有就yum安装,提示complete表示成功)
[root@localhost ~]# rpm -qa | grep nfs
[root@localhost ~]# rpm -qa | grep rpcbind
[root@localhost ~]#
[root@localhost ~]# yum -y install nfs-utils rpcbind
```
```
Complete!
4.创建目录与代码
[root@localhost ~]# mkdir /hezhongli/www
[root@localhost ~]# echo '<?php phpinfo();' > /hezhongli/www/index.php
5.配置
[root@localhost ~]# echo '/hezhongli/www *(rw,no_root_squash,insecure)' > /etc/exports
[root@localhost ~]# exportfs -r
6.启动服务(一定要先启动rpcbind服务)
[root@localhost ~]# service rpcbind start
Redirecting to /bin/systemctl start rpcbind.service
[root@localhost ~]# service nfs start
Redirecting to /bin/systemctl restart nfs.service
7.回到自己Mac终端,挂载(无任何输出提示表示成功!)
hezhonglideMacBook-Pro:~ hezhongli$ mount_nfs 10.211.55.30:/hezhongli/www ./Project/
hezhonglideMacBook-Pro:~ hezhongli$
8.Mac下Finder中共享的IP查看是否存在,存在有编辑器打开看是否有编辑权限,没有权限的话查看NFS配置。
总结:我就是这种开发模式使用快两年多了,虚拟机软件为Parallels Desktop,这种开发模式的好处不用多说,首先Linux中安装软件就比较好安装,不会把自己本地电脑配置搞的特别乱,如果要迁移环境直接把虚拟机打包成镜像,不过近几年很火的Docker貌似解决了这种问题(关键是自己不太会玩,哭笑 ^~^)。
如有错误或者问题请邮箱联系!
文章关键词:
# Linux
# Mac
# NFS挂载
阅读量:
999
返回主页