博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
vagrant虚拟机_与Vagrant Share在网络上共享您的虚拟机
阅读量:2511 次
发布时间:2019-05-11

本文共 9981 字,大约阅读时间需要 33 分钟。

vagrant虚拟机

Vagrant Share is a new feature of that lets you share your local development environment to the web in literally seconds. You can even set it up to let others SSH into your virtual machine. I not only find this incredibly useful, but it's quite cool as well.

Vagrant Share是一项新功能,可让您在几秒钟内将本地开发环境共享到Web。 您甚至可以对其进行设置,以允许其他人SSH进入您的虚拟机。 我不仅发现这非常有用,而且也很酷。

喜欢流浪汉吗? 签出苏格兰威士忌盒-我们死了的简单LAMP流浪者盒 ( Like Vagrant? Check out Scotch Box - Our Dead Simple LAMP Vagrant Box )

I'm a huge fan of Vagrant! If you don't know what it is,
我是Vagrant的忠实粉丝! 如果您不知道它是什么, . In layman's terms, you set a whole bunch of config options in a file, then tell Vagrant to use that configuration to provision and build you a server. Your server can be provisioned locally (making local development painless) or even on a provider such as Amazon or Digital Ocean. Here's a tutorial I wrote on 。 用外行的话来说,您在文件中设置了一整套配置选项,然后告诉Vagrant使用该配置来配置和构建服务器。 您的服务器可以在本地进行配置(使本地开发变得轻松),甚至可以在诸如Amazon或Digital Ocean之类的提供商上进行配置。 这是我写的 . By the end of that tutorial, you'll have a PHP 5.4 LAMP stack running locally on your machine. 教程。 在该教程结束时,您将在计算机上本地运行一个PHP 5.4 LAMP堆栈。

什么是流浪云? ( What is Vagrant Cloud? )

I finally updated my Vagrant to 1.5+ (1.6.3 to be exact). I never liked to upgrade because I was afraid of things breaking or plugins not being compatible. With Vagrant 1.5+ though, Vagrant promised and a ton of cool new features. It also comes with the new and awesome service . Vagrant Cloud makes collaboration with Vagrant easy for teams small or large. Some things Vagrant Cloud offers are:

终于将我的Vagrant更新为1.5+(准确地说是1.6.3)。 我从不喜欢升级,因为我担心事情会破裂或插件不兼容。 不过,随着Vagrant 1.5+的发布,Vagrant承诺了和大量酷炫的新功能。 它还带有新的,强大的服务 。 Vagrant Cloud使无论规模大小的团队都能轻松地与Vagrant进行协作。 Vagrant Cloud提供的一些功能是:

  • Box Hosting (You may have to host the box yourself)

    Box Boxing(您可能必须自己托管Box)
  • Discover Public and Private Boxes

    发现公共箱和私人箱
  • Vagrant Share

    流浪者份额
  • Vagrant Share Static Names

    流浪者共享静态名称
  • Vagrant Share Custom Domain

    流浪者共享自定义域
  • Organization/Teams/ACLs

    组织/团队/ ACL

So, say I need a virtual environment for Node.js, PHP, or Ruby, I can login to Vagrant Cloud, search some shared boxes, and then find one to help me get started with my development environment. Some of these boxes are full-featured and require almost no overhead configuration. This collaboration from community boxes is really cool for small teams who don't have the luxury of full-time Server Admin and Operations people.

因此,说我需要一个用于Node.js,PHP或Ruby的虚拟环境,我可以登录到Vagrant Cloud,搜索一些共享框,然后找到一个可以帮助我开始开发环境的框。 其中一些功能齐全,几乎不需要任何开销配置。 对于那些没有专职服务器管理员和运营人员的小团队来说,社区箱的协作真的很棒。

Vagrant Share is the other huge part of Vagrant Cloud. Vagrant Share lets you easily share your Vagrant Virtual Machine to the web and make it accessible to anyone. So, say you quickly need to share with a client or team member your progress - rather than setting up a full-blown staging environment, you can just run vagrant share to get a temporary URL on .

Vagrant Share是Vagrant Cloud的另一个重要组成部分。 通过Vagrant Share,您可以轻松地将您的Vagrant虚拟机共享到Web,并使任何人都可以访问。 因此,假设您很快需要与客户或团队成员分享您的进度-而不是建立完善的登台环境,您只需运行vagrant share即可在上获取临时URL。

This is neat, but Vagrant actually takes this a a step further. With Vagrant Share you can even share SSH access to your VM with anyone from anywhere in the world! I've heard of some people setting this up while on the same network, but with this, as long as the user is connected to the Vagrant Cloud, it doesn't matter which network they are on. This is super useful for debugging and collaborating. The rest of this tutorial will walk you though how to set this up.

这很干净,但是Vagrant实际上又向前迈了一步。 借助Vagrant Share,您甚至可以与世界各地的任何人共享对VM的SSH访问 ! 我听说有人在同一网络上进行设置,但是有了这个,只要用户连接到Vagrant Cloud,他们在哪个网络上都没有关系。 这对于调试和协作非常有用。 本教程的其余部分将带您逐步了解如何进行设置。

更新无业游民 ( Update Vagrant )

The first thing you need to do is make sure you have the latest Vagrant version installed. I completely uninstalled Vagrant and reinstalled from scratch (including ) since it's quick, easy, and clean. the official instructions on uninstalling Vagrant. To uninstall Vagrant on Mac, just run these commands from the terminal:

您需要做的第一件事是确保您安装了最新的Vagrant版本。 我完全卸载了Vagrant,并从头开始重新安装(包括 ),因为它既快速,简便又干净。 有关卸载Vagrant的官方说明。 要在Mac上卸载Vagrant,只需在终端上运行以下命令:

sudo rm -rf /Applications/Vagrantsudo rm /usr/bin/vagrantsudo rm -rf ~/.vagrant.d

Then and reinstall any plugins you use. Here are the ones from my so you can continue to use that setup:

然后 ,然后重新安装您使用的所有插件。 这是我因此您可以继续使用该设置:

vagrant plugin install vagrant-berkshelf --plugin-version '>= 2.0.1'vagrant plugin install vagrant-hostmanagervagrant plugin install vagrant-omnibus

创建一个Vagrant Cloud帐户 ( Create a Vagrant Cloud Account )

The next thing you'll need to do is create a if you already don't have one. Vagrant Cloud is completely free for basic users (which provides plenty of support). If you need some of the more advanced options, they have some very cheap and reasonable . Everything we'll be doing is under the free tier, however.

接下来您需要做的就是创建一个如果您还没有)。 Vagrant Cloud对基本用户完全免费(提供大量支持)。 如果您需要一些更高级的选择,则它们的非常便宜且合理。 但是,我们要做的一切都是免费的。

Create a Vagrant Cloud Account

使用Vagrant验证您的Vagrant Cloud帐户 ( Authenticate Your Vagrant Cloud Account with Vagrant )

Now that you have successfully signed up for a Vagrant Cloud account, you'll need to authenticate Vagrant Cloud with your install of Vagrant. From the command line, run the following code :

现在您已经成功注册了Vagrant Cloud帐户,您将需要使用Vagrant安装对Vagrant Cloud进行身份验证。 在命令行中,运行以下代码:

vagrant login

It should prompt you with steps that would look something like this:

它应该提示您一些类似以下的步骤:

Vagrant Login CLI

That's it! You're now authenticated. For whatever reason, if you ever need to logout, you can just run:

而已! 您现在已通过身份验证。 无论出于何种原因,如果您需要注销,都可以运行:

vagrant login --logout
.

创建一个无所事事的环境 ( Create an Environment with Vagrant )

Now that we have our Vagrant Cloud setup, we'll create a virtual environment so we can share it. We're going to be using the exact same from the last to make things easy. Make sure you have installed if you didn't follow the last tutorial.

现在我们已经有了Vagrant Cloud设置,我们将创建一个虚拟环境以便我们可以共享它。 我们将使用与上一期完全相同的 ,以操作。 如果不遵循上一教程,请确保已安装 。

git clone git@github.com:MiniCodeMonkey/Vagrant-LAMP-Stack.git vagrant-share-democd vagrant-share-demovagrant up
Note: You can name this whatever you want. You can also open up the
注意:您可以随意命名。 您也可以打开
Vagrantfile and name the project something else besides "projectname".
Vagrantfile并为项目命名,除了“ projectname”。

After that runs, you can now navigate to to see your Vagrant LAMP stack is working:

运行之后,您现在可以导航到以查看您的Vagrant LAMP堆栈正在工作:

Vagrant LAMP Stack

运行共享命令 ( Run the Share Command )

Now that everything is setup, all you need to do is run the vagrant share command:

现在已经完成了所有设置,您所需要做的就是运行vagrant share命令:

vagrant share

It will look something like this:

它看起来像这样:

Vagrant Share

That's all there is to it! Now you can visit the outputted URL and see your VM from any network anywhere in the world. As you start developing your application, it's important that you make sure things like URLs are relative and not absolute.

这里的所有都是它的! 现在,您可以访问输出的URL,并从世界上任何地方的任何网络查看您的VM。 在开始开发应用程序时,重要的是要确保URL之类的内容是相对的而不是绝对的。

Since this works by creating a local tunnel, you can make changes and see them reflected immediately. For example, change some text and visit the URL to see it updated instantly. This is really useful for when you need:

由于这是通过创建本地隧道进行的,因此您可以进行更改并立即看到更改。 例如,更改一些文本并访问URL即可立即看到它的更新。 这在需要时非常有用:

  • Help from a colleague

    同事的帮助
  • Show or demo for a client

    显示或演示客户
  • Debug using a third-party program (e.g.: )

    使用第三方程序进行调试(例如: )

The connection will automatically close after about one hour. To close the connection manually, just enter:

大约一小时后,连接将自动关闭。 要手动关闭连接,只需输入:

ctrl c
SSL Support The Vagrant Share utility supports SSL as well. You can do:
SSL支持 Vagrant Share实用程序也支持SSL。 您可以执行以下操作:
vagrant share --https 443 to get an SSL encrypted URL.
vagrant share --https 443以获取SSL加密的URL。

SSH共享 ( SSH Sharing )

HTTP sharing like the example above is great for many reasons, but you can even share SSH access to your VM through Vagrant Cloud. To do this, make sure you terminate the previous share, then enter this command:

像上面的示例一样,HTTP共享之所以很棒,有很多原因,但是您甚至可以通过Vagrant Cloud共享对VM的SSH访问。 为此,请确保终止先前的共享,然后输入以下命令:

vagrant share --ssh

This time when the command runs, you'll be prompted to create a password. After you create your password, Vagrant will actually print the code that you can share to grant SSH access to your VM to someone else. It will look something like this:

这次运行命令时,系统将提示您创建密码。 创建密码后,Vagrant实际上将打印您可以共享的代码,以将对您的VM的SSH访问权限授予其他人。 它看起来像这样:

vagrant connect --ssh terrible-bear-6896

Now, if someone is authenticated with the Vagrant Cloud and runs that command, they'll get full SSH access to your VM. They'll also have to enter the password you created. This can be really useful for debugging and quickly helping someone fix a bug or issue. Collaborating locally just got a whole lot easier. You can terminate the share the same way you did with HTTP Sharing.

现在,如果某人通过Vagrant Cloud进行了身份验证并运行了该命令,他们将获得对您的VM的完全SSH访问权限。 他们还必须输入您创建的密码。 这对于调试并快速帮助某人修复错误或问题非常有用。 在本地进行协作变得非常容易。 您可以使用与HTTP共享相同的方式终止共享。

结论 ( Conclusion )

That's all there is to using Vagrant Share. Some people mimic this or get pretty close to it with local tunnel tools or pseudo DNS tools like:

这就是使用Vagrant Share的全部内容。 有些人使用本地隧道工具或伪DNS工具(例如:

Vagrant Share makes this process easier, seamless, and ultra-fast. It also has the added benefit of allowing people SSH access to a VM from anywhere in the world.

Vagrant Share使此​​过程更加轻松,无缝和超快。 它还具有允许人们通过SSH从世界任何地方访问VM的额外好处。

I really enjoy using Vagrant, and it has made my development much more efficient. I imagine as Vagrant Cloud grows, they'll start managing deployment for users, too. So from Vagrant Cloud you can Share temporary links, one-click provision to Digital Ocean or Amazon, and more. I may be wrong, but I really can see them growing Vagrant Cloud to manage servers similar to tool does.

我真的很喜欢使用Vagrant,它使我的开发效率更高。 我想随着Vagrant Cloud的发展,他们也将开始为用户管理部署。 因此,从Vagrant Cloud中,您可以共享临时链接,到Digital Ocean或Amazon的一键式配置等等。 我可能是错的,但我确实可以看到他们正在扩大Vagrant Cloud来管理类似于工具的服务器。

翻译自:

vagrant虚拟机

转载地址:http://hnywd.baihongyu.com/

你可能感兴趣的文章
Nginx配置文件nginx.conf中文详解(总结)
查看>>
【2020-3-21】Mac安装Homebrew慢,解决办法
查看>>
influxdb 命令行输出时间为 yyyy-MM-dd HH:mm:ss(年月日时分秒)的方法
查看>>
jxl写入excel实现数据导出功能
查看>>
linux文件目录类命令|--cp指令
查看>>
.net MVC 404错误解决方法
查看>>
linux系统目录结构
查看>>
git
查看>>
btn按钮之间事件相互调用
查看>>
Entity Framework 4.3.1 级联删除
查看>>
codevs 1163:访问艺术馆
查看>>
冲刺Noip2017模拟赛3 解题报告——五十岚芒果酱
查看>>
并查集
查看>>
sessionStorage
查看>>
代码示例_进程
查看>>
Java中关键词之this,super的使用
查看>>
人工智能暑期课程实践项目——智能家居控制(一)
查看>>
前端数据可视化插件(二)图谱
查看>>
kafka web端管理工具 kafka-manager【转发】
查看>>
获取控制台窗口句柄GetConsoleWindow
查看>>