使用虚拟服务器作为开发环境,符号链接到主机上的文件是否安全?

发布于 2024-11-16 21:15:01 字数 1002 浏览 3 评论 0原文

我曾经使用 MAMP(或者只是本地 Apache/PHP/MySQL 堆栈)来处理 Web 项目。我已经升级到一个实时 Ubuntu 服务器,它更接近我工作的网站的生产环境。

现在我正尝试进一步优化我的工作流程。我的目标是让一个在 VirtualBox 中运行的 Linux 服务器自动挂载本地文件夹共享(从主机)并使用符号链接来访问文件(即 client:/var/www/dev 是到 host:/Users 的符号链接) /查理/开发/)。

如果可以避免的话,我不想将文件存储在虚拟服务器上。我更喜欢直接在本地访问文件,而不必等待主机和客户端之间的缓冲问题。即,如果我在 IDE 中打开客户端上的多个文件,然后我关闭笔记本电脑,那么一旦打开它,就会出现一些缓冲区问题。我的 IDE 已打开项目,这些项目引用位于尚不可用的网络共享上的文件夹和文件。在虚拟机唤醒的几秒钟内,OSX 已经报告无法找到共享并已断开连接、IDE 阻塞等。

那么我在问什么呢?嗯,这安全吗/是否有我没有看到的明显陷阱/更好的方法来做到这一点?

编辑:对于任何偶然发现这篇文章的人来说,最终设置是在 Mac 上的 VirtualBox 中运行的 Linux 虚拟机,带有 NFS 和从我的 Apache Web 根目录到我的安装的符号链接。

我使用 NFS Manager (http://www.bresink.com/osx/NFSManager.html) 在我的主机上设置 NFS 服务器,并将用户映射到我的主帐户。这确保了当我的 VM 挂载 NFS 共享时,它可以执行所需的任何操作(读取、写入、修改)。然后我将此行添加到虚拟机上的 /etc/fstab 中,以便在启动时自动挂载共享:“123.456.89.1:/Users/charlie/nfs_share /mnt/nfs_share nfs”(其中 123 是虚拟 NAT 上的主机 IP)。

结果是一个杀手级的开发环境,我可以使用 Finder、Aptana(或您选择的任何编辑器)Photoshop 等在本地处理文件,并同时在我的“真正的”Apache/Lighttpd/MySQL/PHP 环境中测试它们!

I used to use MAMP (or just a local Apache/PHP/MySQL stack) to work on web projects. I've since graduated to a live Ubuntu server which is much closer to the production environments for the sites I work on.

Now I'm trying to take this a step further to optimize my workflow. My goal is to have a Linux server running in VirtualBox that automounts a local folder share (from the host) and uses a symlink to gain access to the files (i.e. client:/var/www/dev is a symlink to host:/Users/charlie/dev/).

I don't want to keep my files stored on the virtual server if it can be avoided. I prefer having direct local access to the files and not having to wait for buffering issues between the host and the client. i.e., if I have several files that are located on the client open in my IDE and I close my laptop, as soon as I open it there's a bit of a buffer issue. My IDE has open project(s) that reference folders and files located on a network share that isn't yet available. In the few seconds it takes for the virtual machine to wake up, OSX is already reporting that the share can't be found and was disconnected, the IDE chokes up, etc.

So what am I asking? Well, is this safe / are there obvious pitfalls I'm not seeing / better ways to do this?

Edit: For anyone that stumbles upon this post, the final setup is a Linux virtual machine running in VirtualBox on a Mac with NFS and a symlink from my Apache web root to my mount.

I used NFS Manager (http://www.bresink.com/osx/NFSManager.html) to setup the NFS Server on my host computer with user mapping to my primary account. This ensures that when my VM mounts the NFS share it can do whatever it needs (reading, writing, modifying). Then I added this line to /etc/fstab on my VM to automount the share on boot: "123.456.89.1:/Users/charlie/nfs_share /mnt/nfs_share nfs" (where 123 is my host IP on the virtual NAT).

The result is a killer development environment where I can use Finder, Aptana (or whatever your editor of choice is) Photoshop, etc to work on files locally and simultaneously test them out in my "real" Apache/Lighttpd/MySQL/PHP environment!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

多情癖 2024-11-23 21:15:01

我使用完全相同的设置来访问 Ubuntu 主机和 Windows 来宾之间的文档文件夹。同上,在我的 iMac 上。唯一的问题是在两个平台上编辑时的 CR/LS,但这对您的设置来说不是问题。

I am using the exact same setup for accessing my documents folder between my Ubuntu host and the windows guest. Idem on my iMac. The only issues are when editing on the 2 platforms are the CR/LS, but that will be no issue on your setup.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文