在机箱里 碰一下机箱就重启
When I wrote the first article on WordPress and Vagrant I introduced WordPress VVV. VVV is a Vagrant configuration for developing WordPress themes and contributing to the core. One common problem, however, is that many people were overwhelmed with VVV. Especially those new to Vagrant, who just wanted to get something simple up and running fast. There are many other Vagrant configurations, one of the easiest to use and most popular in WordPress circles is Chassis.
当我在WordPress和Vagrant上撰写第一篇文章时,我介绍了WordPress VVV 。 VVV是一个Vagrant配置,用于开发WordPress主题并为核心做出贡献。 但是,一个普遍的问题是,许多人不知所措。 尤其是对Vagrant来说是新手,他们只是想简化并快速运行。 机箱还有许多其他的Vagrant配置,其中一种最易于使用且最受欢迎的配置是Chassis 。
Chassis is a simple Vagrant configuration, popular among WordPress plugin and theme developers. It’s easy to get started with and use on a per project development. In this article I’ll walk you through setting up Chassis. The folder structure is a bit different, so we’ll get into that too. The Chassis configuration has a hierarchy, so understanding how that works is also important. The last topic we’ll cover is extending Chassis by adding plugins that include more features.
Chassis是一个简单的Vagrant配置,在WordPress插件和主题开发人员中很流行。 每个项目的开发都很容易上手和使用。 在本文中,我将引导您完成机箱的设置。 文件夹结构有些不同,因此我们也将对此进行介绍。 机箱配置具有层次结构,因此了解其工作原理也很重要。 我们将讨论的最后一个主题是通过添加包含更多功能的插件来扩展机箱。
There are several reasons why someone would choose to use Chassis for WordPress development. Firstly, Chassis is lightweight. In contrast, VVV is rather heavy as it comes with a wide range of tools. The problem with VVV is that it can take a long time to install, and it’s slow. In comparison, Chassis takes just a couple of minutes to install.
有人选择使用机箱进行WordPress开发的原因有几个。 首先,机箱轻巧。 相反,VVV具有很多种工具,因此非常笨重。 VVV的问题是安装时间可能很长,而且速度很慢。 相比之下,机箱仅需几分钟即可安装。
Chassis is so lightweight, that it only comes with:
机箱非常轻巧,仅随附:
WordPress 4.0 WordPress 4.0 PHP 5.4 (includes the cURL and GD extensions) PHP 5.4(包括cURL和GD扩展) Nginx Nginx的 MySQL MySQLWhere is phpMyAdmin? Everything else that you may want to install, such as phpMyAdmin for example, comes as an extension. Memcache is also available, Xdebug is comming soon.
phpMyAdmin在哪里? 您可能要安装的所有其他内容(例如phpMyAdmin)都作为扩展名附带。 Memcache也可用,Xdebug即将推出。
The installation is easy and the Chassis documentation covers it very well. You need to install the latest version of Vagrant and VirtualBox. However, Chassis requires an additional tool to work with the network. You can choose either Bonjour or Avahi. If you’re on Mac then you will already have Bonjour pre-installed. If you’re on Windows you can install Bonjour via iTunes. If you use Linux then you’ll have to install Avahi by executing:
安装非常容易,并且机箱文档对此进行了很好的介绍。 您需要安装最新版本的Vagrant和VirtualBox。 但是,机箱需要使用其他工具来与网络配合使用。 您可以选择Bonjour或Avahi。 如果您使用的是Mac,那么您已经预装了Bonjour。 如果您使用Windows,则可以通过iTunes安装Bonjour。 如果使用Linux,则必须通过执行以下步骤安装Avahi:
[shell] sudo apt-get install avahi-dnsconfd [/shell]
[shell] sudo apt-get install avahi-dnsconfd [/ shell]
You can get a copy of Chassis from the GitHub repo, just execute:
您可以从GitHub存储库中获取Chassis的副本,只需执行以下命令:
[shell] git clone http://github.com/Chassis/Chassis.git chassis cd chassis git submodule update –init [/shell]
[shell] git clone http://github.com/Chassis/Chassis.git机箱cd机箱git子模块更新–init [/ shell]
The command git submodule update --init makes sure you download every submodule.
git submodule update --init命令可确保您下载了每个子模块。
A nice feature of Chassis is the separation of the WordPress and development directories. By default the folder that contains the themes, plugins and uploads folder is the content folder. When you first clone the repository, there is no content folder. The WordPress folder is called wp but there is no content folder. You can start creating the folder yourself and build the structure. The team behind Chassis has a predefined content folder available on GitHub (called ‘Supercharger’). Supercharger comes with some plugins, such as WordPress SEO, WordPress Importer, Limit Login Attempts and the Regenerate Thumbnails plugin.
Chassis的一个不错的功能是将WordPress和开发目录分开。 默认情况下,包含主题,插件和上载文件夹的文件夹为内容文件夹。 第一次克隆存储库时,没有内容文件夹。 WordPress文件夹称为wp但没有内容文件夹。 您可以自己开始创建文件夹并构建结构。 Chassis背后的团队在GitHub上有一个预定义的内容文件夹(称为“ Supercharger”)。 Supercharger附带了一些插件,例如WordPress SEO,WordPress导入程序,限制登录尝试和Regenerate Thumbnails插件。
[shell] git clone https://github.com/Chassis/Supercharger.git content cd content git submodule update –init [/shell]
[shell] git clone https://github.com/Chassis/Supercharger.git内容cd内容git子模块更新–init [/ shell]
To get up and running, you only need to vagrant up and everything will be installed. Chassis uses a ‘precise64’ box by default. The first time you vagrant up the project the box will be downloaded if no other Vagrant configuration has used it before. To do this, navigate to the root of the project and then execute:
要启动并运行,您只需要vagrant up就可以安装所有内容。 机箱默认情况下使用“ precise64”框。 如果您之前没有任何其他Vagrant配置使用vagrant up此项目,则首次下载该项目时,将下载该框。 为此,请导航到项目的根目录,然后执行:
[shell] vagrant up [/shell]
[shell]无所事事[/ shell]
Wait until the installation finishes. You now have a ready to use environment. Everything is pre-configured, there’s no need for the famous 5 minutes configuration. After the installation finishes, visit http://vagrant.local/ in your browser and see if it works. You should see a ready to use WordPress site, skipping the installation process.
等待安装完成。 现在您已经可以使用了。 一切都已预先配置,无需进行著名的5分钟配置。 安装完成后,在浏览器中访问http://vagrant.local/并查看其是否有效。 您应该看到准备使用的WordPress网站,跳过安装过程。
You may have noticed that after installation there are two new files. The local-config-db.php file and local-config-extensions.php. Don’t edit these files. They’re generated using the config.yaml configuration. If you want to edit these files, you’ll need to edit config.yaml and then provision using vagrant provision.
您可能已经注意到,安装后有两个新文件。 local-config-db.php文件和local-config-extensions.php 。 不要编辑这些文件。 它们是使用config.yaml配置生成的。 如果要编辑这些文件,则需要编辑config.yaml ,然后使用vagrant provision 。
Chassis separates the WordPress folder from the content folder. By default, Chassis disables the auto-update so you’ll have to install any updates manually. Separating the folders is a good decision. Using this separate content folder doesn’t mean that you can’t work with the wp-content folder, but it’s better to stick with the content folder.
机箱将WordPress文件夹与内容文件夹分开。 默认情况下,机箱禁用自动更新,因此您必须手动安装所有更新。 分隔文件夹是一个不错的决定。 使用此单独的内容文件夹并不意味着您不能使用wp-content文件夹,但最好坚持使用content文件夹。
config.yaml has a hierarchy. config.local.yaml has the highest priority then config.yaml in the content folder. By default these configuration files don’t come with Supercharger. You can copy the existing file from the root folder of the project. config.yaml and config.local.yaml in the root folder of the project have the least priority. config.local.yaml always has the highest priority in the particular folder.
config.yaml具有层次结构。 在内容文件夹中, config.local.yaml具有最高优先级,然后是config.yaml 。 默认情况下,这些配置文件不随Supercharger一起提供。 您可以从项目的根文件夹复制现有文件。 项目根文件夹中的config.yaml和config.local.yaml优先级最低。 config.local.yaml在特定文件夹中始终具有最高优先级。
When you start with a fresh folder you’ll only have one config.yaml in the root folder. This is the lowest priority. Inside that file you can configure the PHP version (5.4 by default), the WordPress directory (/wp by default), the database configuration and WordPress credentials.
当从一个新文件夹开始时,根文件夹中将只有一个config.yaml 。 这是最低优先级。 在该文件中,您可以配置PHP版本(默认为5.4),WordPress目录(默认为/ wp),数据库配置和WordPress凭据。
Let’s experiment a little. First open vagrant.local/phpinfo.php to see what PHP version you’re using. By default you start with 5.4. Copy the config.yaml to the content folder. Edit the PHP version and set it to 5.5. Execute vagrant provision and after the provision navigate again to vagrant.local/phpinfo.php.
让我们尝试一下。 首先打开vagrant.local/phpinfo.php以查看您使用PHP版本。 默认情况下,您从5.4开始。 将config.yaml复制到内容文件夹。 编辑PHP版本并将其设置为5.5。 执行vagrant provision并在vagrant provision之后再次导航到vagrant.local/phpinfo.php 。
Copy the config.yaml from the content folder and rename the copy you just created to config.local.yaml. Again, edit the PHP version to 5.4 again. Execute vagrant provision and test it in your browser.
从内容文件夹复制config.yaml ,然后将刚创建的副本重命名为config.local.yaml 。 再次,将PHP版本再次编辑为5.4。 执行vagrant provision并在浏览器中对其进行测试。
Try the same thing with the admin configuration. On config.local.yaml edit the password to “thepassword”. Execute vagrant provision again and test it to login in with this password on the dashboard. The password is wrong. So why is that? You can’t change the password or the admin credentials via provision. However, if you vagrant destroy and vagrant up again, you will see that the password for the admin is now “thepassword”.
使用管理员配置尝试相同的操作。 在config.local.yaml将密码编辑为“ thepassword”。 再次执行vagrant provision并测试它以使用此密码在仪表板上登录。 密码错误。 那为什么呢? 您无法通过设置更改密码或管理员凭据。 不过,如果你vagrant destroy和vagrant up一遍,你会看到,管理员密码是现在“thepassword”。
Be careful with this configuration. Try to separate the local configuration from the deployment configuration.
使用此配置时要小心。 尝试将本地配置与部署配置分开。
Chassis supports extensions, I’ll cover a few of the popular ones.
机箱支持扩展,我将介绍一些受欢迎的扩展。
MailCatcher As you can see from the name and icon, this is a tool that catches emails that are sent to it and displays those in a web interface. This tool is used for testing purposes, when you don’t want emails sent to a real email provider, but you also need to see if it works. Installing this tool using Chassis is easy so you don’t have to worry about configuring anything.
MailCatcher从名称和图标可以看出,这是一个工具,可以捕获发送给它的电子邮件并在Web界面中显示这些电子邮件。 当您不希望将电子邮件发送给真实的电子邮件提供商时,该工具用于测试目的,但是您还需要查看它是否有效。 使用机箱安装此工具非常容易,因此您不必担心进行任何配置。
[shell] cd extensions git clone https://github.com/Chassis/mailcatcher.git mailcatcher cd mailcatcher git submodule update –init cd ../.. vagrant provision [/shell]
[shell] cd扩展git clone https://github.com/Chassis/mailcatcher.git mailcatcher cd mailcatcher git子模块更新–init cd ../ ..流浪汉提供[/ shell]
Copy the Mailcatcher repository on Chassis to the extensions folder and then vagrant provision. Now go and add a comment to a post. Navigate to http://vagrant.local:1080/ and you will see that mailcatcher has ‘caught’ the email.
将Chassis上的Mailcatcher存储库复制到extensions文件夹,然后进行vagrant provision 。 现在,在帖子中添加评论。 导航到http://vagrant.local:1080/ ,您将看到mailcatcher已“捕获”了该电子邮件。
phpMyAdmin I don’t think that this tool needs any introduction. This is one of the most popular tools when dealing with databases. Just like MailCatcher, this extension doesn’t need any configuration at your end. The installation is similar to MailCatcher.
phpMyAdmin我认为该工具不需要任何介绍。 这是处理数据库时最受欢迎的工具之一。 就像MailCatcher一样,此扩展不需要您进行任何配置。 安装类似于MailCatcher。
[shell] cd extensions git clone https://github.com/Chassis/phpMyAdmin.git phpmyadmin cd .. vagrant provision [/shell]
[shell] cd扩展git clone https://github.com/Chassis/phpMyAdmin.git phpmyadmin cd ..无业游民条款[/ shell]
Now navigate to vagrant.local/phpmyadmin and you’ll see that no login is required.
现在,导航至vagrant.local/phpmyadmin ,您将看到不需要登录。
Memcache When you’re developing a website with WordPress, you don’t know for sure how much traffic the website is going to get. High volumes of traffic is a nice thing, but have you thought about how you’re going to handle it? It’s possible that your server will crash from the huge amount of requests, or in the best case scenario your site will become slow. This is where caching comes in. This is the definition of Wikipedia for Memcached:
Memcache当您使用WordPress开发网站时,您不确定该网站将获得多少流量。 高流量是一件好事,但是您是否考虑过如何处理呢? 您的服务器可能会因大量请求而崩溃,或者在最佳情况下,您的站点会变慢。 这是缓存的来源。这是Wikipedia for Memcached的定义:
Memcached is a general-purpose distributed memory caching system. It is often used to speed up dynamic database-driven websites by caching data and objects in RAM to reduce the number of times an external data source (such as a database or API) must be read.
Memcached是通用分布式内存缓存系统。 它通常用于通过在RAM中缓存数据和对象来减少必须读取外部数据源(例如数据库或API)的次数,从而加快动态数据库驱动的网站的速度。
The Memcache extension installs Memcached properly, you can read the documentation for information on how to use this extension.
Memcache扩展正确安装了Memcached,您可以阅读文档以获取有关如何使用此扩展的信息。
Using Vagrant and Chassis is one of the easiest to use and fastest environments for WordPress development. It has a good workflow by separating the WordPress installation from the working folder. It’s also simple, yet powerful when it comes to extensions.
使用Vagrant and Chassis是WordPress开发最容易使用且最快的环境之一。 通过将WordPress安装与工作文件夹分开,它具有良好的工作流程。 在扩展方面,它也很简单,但功能强大。
翻译自: https://www.sitepoint.com/using-chassis-for-wordpress-development/
在机箱里 碰一下机箱就重启
相关资源:机箱::package:机箱是您的WordPress网站的虚拟服务器,使用Vagrant构建-源码