vagrant入门

tech2022-09-16  64

vagrant入门

Vagrant is a tool for creating and managing virtual environments that help many developers not have to care about the “works on my machine…” problem. Vagrant creates reusable development systems that can be used again and again, helping you keep your system clean of too many installations.

Vagrant是用于创建和管理虚拟环境的工具,可以帮助许多开发人员不必担心“我的机器上的工作……”问题。 Vagrant创建了可重复使用的开发系统 ,这些系统可以一次又一次地使用,从而帮助您避免过多的系统安装。

When you are focused on development and lack the skills of a sys admin, the best thing to do (if you are going to use Vagrant during development) is to try another way of setting up your Vagrant configuration.

当您专注于开发而又缺乏系统管理员的技能时,最好的办法(如果要在开发过程中使用Vagrant)是尝试另一种设置Vagrant配置的方法。

When it comes to PHP development, there are some online services that simplify the setup and configuration of these Vagrant virtual machines. Here is a list of some of these services.

在进行PHP开发时,有一些在线服务可以简化这些Vagrant虚拟机的设置和配置。 这是其中一些服务的列表。

1. PuPHPet (1. PuPHPet)

PuPHPet is probably the most “famous” of these services, and probably the most “specialized” one of them. It gives you the ability to host the VM on your local machine, on Digital Ocean, Rackspace or Amazon Web Services. You get to add forwarded ports with just a click of a button, and sharing source folders is as easy as that too. You can customize the firewall by setting rules and removing them as needed. As for web servers, you can choose between Apache and Nginx, choosing aliases and ports where to access the application.

PuPHPet可能是这些服务中最“著名”的,并且可能是其中最“专业化”的一种。 它使您能够在本地计算机,Digital Ocean,Rackspace或Amazon Web Services上托管VM。 只需单击一个按钮即可添加转发的端口,共享源文件夹也是如此。 您可以通过设置规则并根据需要删除它们来自定义防火墙。 对于Web服务器,您可以在Apache和Nginx之间进行选择,选择别名和访问应用程序的端口。

When it comes to programming languages, PuPHPet is not all about PHP. Besides PHP, you can choose to install Python, Ruby, NodeJS and HHVM. You can’t install both PHP and HHVM, since the service doesn’t allow this – use Homestead Improved for running both at the same time. When installing HHVM, you can also choose to install the nightly release, which gives you the possibility of testing Facebook’s Hack language.

当涉及到编程语言时,PuPHPet不仅仅涉及PHP。 除了PHP,您还可以选择安装Python,Ruby,NodeJS和HHVM 。 您不能同时安装PHP和HHVM,因为该服务不允许这样做–使用Homestead Enhanced可以同时运行两者。 在安装HHVM时,您还可以选择安装夜间版本,这使您可以测试Facebook的Hack语言。

As for databases, PuPHPet has the biggest repository of those, with 6 different databases available. You can choose between MySQL/MariaDB (can’t have both of them), PostgreSQL, Redis, SQLite and MongoDB. You can chose to install Adminer for DB management, but don’t install it onto the production server.

对于数据库,PuPHPet具有最大的存储库,并提供6种不同的数据库。 您可以在MySQL / MariaDB(不能同时拥有两者),PostgreSQL,Redis,SQLite和MongoDB之间进行选择。 您可以选择安装Adminer进行数据库管理,但不要将其安装到生产服务器上。

Before finishing, PuPHPet allows you to install tools like RabitMQ, Elasticsearch, etc.

在完成之前,PuPHPet允许您安装RabitMQ , Elasticsearch等工具。

All that PuPHPet wants from you is that you use a Vagrant version not lower than 1.6. Also, you need VirtualBox in order to use the configurations on your local machine. You can find the source code of PuPHPet on this GitHub repo and a more in-depth guide here.

PuPHPet希望您提供的是使用不低于1.6的Vagrant版本。 另外,您需要VirtualBox才能使用本地计算机上的配置。 您可以在此GitHub存储库中找到PuPHPet的源代码,并在此处 找到更深入的指南。

2. Protobox (2. Protobox)

Protobox is another online Vagrant service. There are many reasons to use Protobox. It actually started as a fork of PuPHPet, but turned out to be a complete other project, due to some issues related to Puppet (not PuPHPet). Protobox has grown into a great service that helps create Vagrant configurations for web application development.

Protobox是另一个在线Vagrant服务。 使用Protobox的原因很多。 它实际上是从PuPHPet的分支开始的,但由于与Puppet (不是PuPHPet)有关的一些问题,最终却是一个完整的其他项目。 Protobox已成长为一项出色的服务,可帮助为Web应用程序开发创建Vagrant配置。

When using Protobox, you can choose from a list of application types:

使用Protobox时,可以从应用程序类型列表中进行选择:

Drupal

Drupal

Laravel (which also has its own Vagrant configuration – Homestead)

Laravel (它也有自己的Vagrant配置– Homestead )

Lemonstand

柠檬摊

PyroCMS

热解CMS

Sylius

西柳斯

Symfony

Symfony

WordPress (which also has VVV – Varying Vagrant Vagrants)

WordPress(也有VVV –不断变化的无业游民)

You can add more than one of these applications to the configuration. As for the web servers, both Apache and Nginx are available. You can choose only three languages: PHP, HipHop (with HHVM) and Ruby.

您可以将多个这些应用程序添加到配置中。 对于Web服务器,Apache和Nginx均可用。 您只能选择三种语言:PHP,HipHop(带有HHVM)和Ruby。

At the time of writing this, Protobox supports only MySQL and MariaDB, but other databases, such as PostgreSQL, MongoDB, Redis and Riak are coming soon. Tools such as Ngrok and NewRelic tools (PHP Agent and Node Agent) can be installed by ticking a checkbox.

在撰写本文时,Protobox仅支持MySQL和MariaDB,但即将推出其他数据库,如PostgreSQL,MongoDB,Redis和Riak。 可以选中一个复选框来安装Ngrok和NewRelic工具( PHP Agent和Node Agent )之类的工具。

You can find the source code for Protobox in their GitHub repo.

您可以在他们的GitHub存储库中找到Protobox的源代码。

3.宽容 (3. Phansible)

Phansible is another tool for creating Vagrant configurations based on Ansible, also inspired from PuPHPet.

Phansible是另一个基于Ansible创建Vagrant配置的工具,同样受PuPHPet的启发。

Phansible is somewhat simpler than the above services. It allows both Apache and Nginx, with HHVM only when you choose Nginx. You can’t choose any other language than PHP, but you can chose between versions of PHP. Also, you can’t choose any other database other than MySQL.

Phansible比上述服务更简单。 它仅在选择Nginx时才允许使用HHVM的Apache和Nginx。 除了PHP,您不能选择任何其他语言,但是可以在PHP版本之间进行选择。 另外,除了MySQL,您不能选择任何其他数据库。

When you’re predetermined to use only Apache/Nginx, PHP and MySQL, Phansible doens’t differ that much from the other services above. Otherwise, you would have to install other tools manually.

当您预定只使用Apache / Nginx,PHP和MySQL时,Phansible与上述其他服务没有太大区别。 否则,您将必须手动安装其他工具。

4.漫游 (4. Rove)

Rove is probably the simplest of them all. You can choose any of the typical configurations, Rails and LAMP, or you can create your configuration manually.

罗夫可能是所有这些中最简单的。 您可以选择任何典型配置,即Rails和LAMP,也可以手动创建配置。

Rove supports CouchDB, MongoDB, MySQL, PostgreSQL, Redis and SQLite as databases. You can select as many as you want of them. It also supports the same languages as PuPHPet, all except HHVM.

Rove支持CouchDB,MongoDB,MySQL,PostgreSQL,Redis和SQLite作为数据库。 您可以根据需要选择任意数量。 除了HHVM之外,它还支持与PuPHPet相同的语言。

5.定制配置 (5. Customized configurations)

There are also some other Vagrant configurations that are case-specific, i.e. for a single PHP framework.

还有一些其他的Vagrant配置是特定于大小写的, 即针对单个PHP框架。

I would mention here Laravel’s Homestead, which makes Laravel development a piece of cake, both front and back end. It comes with PHP5.6, Nginx as the web server, both MySQL and PostgreSQL; and NodeJS, with Bower, Grunt and Gulp for the front-end development. There’s an improved version of Homestead here.

我在这里要提到Laravel的Homestead ,这使得Laravel的开发在前端和后端都是小菜一碟。 它带有PHP5.6,Nginx作为Web服务器,包括MySQL和PostgreSQL。 和NodeJS,以及Bower,Grunt和Gulp进行前端开发。 有宅基地的改进版本在这里 。

Phalcon also has a Vagrant configuration, which saves you the time of installing it and configuring it in an existent server, although you can follow this quick tip to install Phalcon on a Homestead Improved instance.

Phalcon还具有Vagrant配置 ,可以节省安装和在现有服务器中进行配置的时间,尽管您可以按照此快速提示在Homestead Improvementd实例上安装Phalcon。

WordPress has its own Vagrant configuration, VVV – Varying Vagrant Vagrants. There is a full tutorial on SitePoint which shows you how to use VVV.

WordPress有其自己的Vagrant配置,即VVV – Varying Vagrant Vagrants 。 在SitePoint上有完整的教程 ,向您展示了如何使用VVV。

最后的话 (Final words)

Vagrant may be difficult to use sometimes, but is worth pursuing as it can be exceptionally useful. If you are tired of configuring your machine for every project you have, then Vagrant is the right tool for you. If you face problems while configuring your machine, then using a prepackaged vagrant box is the best answer to your problems. Any alternatives to the services above we’ve missed? Let us know!

流浪者有时可能很难使用,但值得一去,因为它可能非常有用。 如果您厌倦了为自己拥有的每个项目配置机器,那么Vagrant是适合您的工具。 如果在配置计算机时遇到问题,则使用预包装的无用盒是解决问题的最佳方法。 我们错过了以上服务的替代方案吗? 让我们知道!

翻译自: https://www.sitepoint.com/5-easy-ways-getting-started-php-vagrant/

vagrant入门

相关资源:VagrantandPHP-源码
最新回复(0)