zend guard 7_了解Zend Server 7

zend guard 7

Zend Technologies is the company which funds the development of the Zend Engine (the engine PHP is based on), as well as Zend Framework and some other projects like Apigility. They also build proprietary software of high professional caliber, designed for high intensity PHP work in large companies – software like Zend Studio and Zend Server – though both are excellent tools for solo devs as well. In this post, we’ll be taking a look at the latter.

Zend Technologies是为Zend Engine (基于PHP的引擎)以及Zend Framework和其他一些项目(如Apigility )的开发提供资金的公司。 他们还构建了具有高专业水准的专有软件,专为大型公司中的高强度PHP工作而设计,例如Zend StudioZend Server之类的软件,尽管它们对于单独开发人员也是出色的工具。 在这篇文章中,我们将看看后者。

什么是Zend Server? (What is Zend Server?)

Zend Server is, essentially, a locally-run web application which helps you run, deploy, debug and production-prepare other applications you write. It’s more than a developer helper, though – you can install it on your production servers and have it take care of hosting, clustering, file distribution and more.

本质上,Zend Server是本地运行的Web应用程序,可帮助您运行,部署,调试和生产准备编写的其他应用程序。 但是,它不仅仅是开发人员的帮助者–您可以将其安装在生产服务器上,并负责托管,群集,文件分发等工作。

It automatically installs Zend Framework (both version 1 and 2 for some reason) and Symfony 2, and supports GUI-based management of other libraries and projects for total ease of use. All operating systems and platforms are supported, and you can install it alongside Apache or Nginx – your choice. You can have it pull in PHP version 5.4 or 5.5, and it will do the rest on its own once you run the installation script.

它会自动安装Zend Framework(由于某种原因,版本为1和2)和Symfony 2,并支持基于GUI的其他库和项目的管理,以实现整体易用性。 支持所有操作系统和平台,您可以选择将其与Apache或Nginx一起安装。 您可以将其拉入PHP 5.4或5.5版本,一旦运行安装脚本,它将自行完成其余工作。

The latest version of ZS, version 7, comes in several licenses and flavors, so give those a read if you’d like to know about the differences.

ZS的最新版本(第7版)具有多个许可证和口味 ,因此,如果您想了解不同之处,请阅读一下。

The concept of Zend Server might be a bit too abstract to grasp right now if you’ve never encountered it before, so let’s just walk through it instead.

如果您以前从未遇到过,那么Zend Server的概念可能有点太抽象了,以至于现在无法掌握,所以让我们来看看它。

安装Zend服务器 (Installing Zend Server)

Installing is done with their installer, which varies depending on platform. To install it into an Ubuntu 14.04 box, see our quick tip. If you’d like to follow along as we walk through the features, please do this now. It shouldn’t take more than 10 minutes.

安装使用其安装程序完成,具体取决于平台。 要将其安装到Ubuntu 14.04盒子中,请参阅我们的快速提示 。 如果您想在我们逐步了解这些功能时继续进行,请立即执行此操作。 不应超过10分钟。

If you’re on a Linux OS and didn’t follow our Quick Tip, please remember to modify the log file permissions as described here. This is necessary for Zend Server to have log access, and for it to be able to spawn virtual hosts.

如果您使用的是Linux操作系统,但未遵循我们的快速提示,请记住按照此处所述修改日志文件权限。 这对于Zend Server拥有日志访问权限并使其能够生成虚拟主机是必需的。

特征 (Features)

Let’s take a deeper look at ZS now and examine its features.

现在让我们更深入地了解ZS并检查其功能。

图形用户界面 (GUI)

alt

The front end is extremely fast – surprisingly so. Even though full page reloads happen, the screens load so fast you could be forgiven for assuming it’s ajax. A fast dynamic menu adorns the top of the control panel, and though it could use upgrades in the design department, it conveys the available options clearly. I could name dozens of occasions on which I wished I didn’t have to log into a company’s back-end simply due to the slow loading times that await me. Having an interface working this smoothly really makes one want to use it.

前端非常快-令人惊讶的是。 即使发生整页重新加载,屏幕加载的速度仍然如此之快,以至于假设它是ajax可以原谅。 快速动态菜单装饰在控制面板的顶部,尽管它可以使用设计部门的升级功能,但可以清晰地传达可用选项。 我可以列举数十次我希望我不必因为等待加载时间太慢而不必登录公司后端的场合。 拥有一个如此顺畅地工作的界面确实使人们想要使用它。

As you can see in the figure above, the first screen that greets us is the guide page of the overview screen, with some helpful guides and videos. The lower half will give you hints on what to fine-tune next, regarding PHP configuration and the rest, and the app will notify you with a modal popup when a server restart is required (such as after enabling some PHP extensions, for example). After you scroll through the “What’s next” options, you’ll notice they’re commonly repeated and can all be accessed via the main menu, too. For example, you can access Virtual Host management through PHP & WEB SERVER, but also through Applications -> Virtual Hosts.

正如您在上图中所看到的,迎接我们的第一个屏幕是概述屏幕的指南页面,其中包含一些有用的指南和视频。 下半部分将为您提供有关PHP配置和其余内容的下一步建议,并且当需要重新启动服务器时(例如,启用某些PHP扩展后),应用程序将通过模式弹出窗口通知您。 。 滚动浏览“下一步是什么”选项后,您会发现它们通常是重复的,并且都可以通过主菜单进行访问。 例如,您可以通过PHP & WEB SERVER访问虚拟主机管理,也可以通过Applications -> Virtual Hosts

Look around in the top menu to get a glimpse of all the other options – there are certainly too many for us to take a look at in one post.

在顶部菜单中四处浏览,以了解所有其他选项-我们当然有太多内容无法在一篇文章中进行介绍。

图书馆管理 (Library Management)

One feature that mustn’t go unmentioned is Library Management. Reachable at Applications -> Libraries, this interface allows you to add new libraries to the Zend Server environment, update them as patches come out, and – perhaps best of all – makes them all available across the server(s) for all apps. They’re automatically added to the include path, and you can use them in your projects.

图书馆管理是一个不容忽视的功能。 可在Applications -> Libraries此界面,该界面允许您将新的库添加到Zend Server环境中,并在补丁发布时对其进行更新,并且(最重要的是)使它们在所有应用程序的服务器上均可用。 它们会自动添加到包含路径,您可以在项目中使用它们。

alt

You might think this would slow your application down due to having yet another huge include path to look through, but you’d be wrong. To actually use a deployed library in your project, you need to insert an API call as described here. Notice the “Library Path” value in the figure above – including it in your project automatically enables it.

您可能会认为,这将使您的应用程序变慢,因为还有另外一个巨大的include路径可供浏览,但是您会错的。 要在项目中实际使用已部署的库,您需要按此处所述插入API调用。 请注意上图中的“库路径”值-在项目中包含该值会自动启用它。

Obviously, this binds your application rather heavily to Zend Server – a subject ripe for another discussion as it has its pros and cons.

显然,这将您的应用程序与Zend Server紧密地绑定在一起-由于它有其优点和缺点,因此该话题值得再次讨论。

Z射线 (Z-Ray)

Z-Ray monitors requests made to the Web server, and displays relevant, live and detailed information on a Web page component in your browser. This information includes: request execution time, events, log entries, database queries, functions, and more. Using Z-Ray, developers get real insight into their PHP code, allowing them to inspect, debug and optimize their pages, resulting in fast and stable applications.

Z-Ray监视对Web服务器的请求,并在浏览器的Web组件上显示相关的实时信息和详细信息。 该信息包括:请求执行时间,事件,日志条目,数据库查询,函数等。 使用Z-Ray,开发人员可以真正了解其PHP代码,从而可以检查,调试和优化其页面,从而实现快速,稳定的应用程序。

Zend’s real-time debugger implementation, Z-Ray can hook into your requests as they happen and provide real time up to date insight on what’s going on internally. You’ll be able to easily identify the slowest parts of your app, you’ll see errors before even PHP logs them, and you’ll be able to fine tune your application like never before.

在Zend的实时调试器实现中,Z-Ray可以在您的请求发生时将其挂起,并提供有关内部正在发生的事情的实时最新信息。 您将能够轻松识别应用程序中最慢的部分,甚至在PHP记录错误之前就可以看到错误,并且可以前所未有地微调您的应用程序。

To read more about Z-Ray, see here or wait for our review to come out.

要了解有关Z射线的更多信息,请参见此处或等待我们的评论出来。

网络API (Web API)

It’s impressive that Zend Server is fully web API enabled. What this means is that you can write new interfaces for it in any language or style you see fit – even mobile apps to power it – and manage your Zend Server deployed applications from anywhere.

Zend Server完全启用了Web API,这一点令人印象深刻。 这意味着您可以使用任何您认为合适的语言或样式为其编写新界面,甚至可以使用移动应用程序为其提供支持,并可以在任何地方管理Zend Server部署的应用程序。

alt

This is a feature you don’t see often, if at all, in back end interfaces for applications and application management, so I was pleasantly surprised to encounter it.

在应用程序和应用程序管理的后端界面中,即使您根本看不到此功能,也很罕见,因此让我感到惊喜的是。

自定义PHP扩展 (Custom PHP Extensions)

What if I want to use a custom PHP extension, though? How do we pull that off? Is it even possible? Maybe I’d like to build my apps using Phalcon, but still continue to manage them with Zend Server, blending the best of two worlds.

但是,如果我想使用自定义PHP扩展怎么办? 我们如何做到这一点? 可能吗? 也许我想使用Phalcon构建我的应用程序,但仍然继续使用Zend Server来管理它们,融合了两个方面的优点。

The good news is – it’s possible. It’s a bit outside the scope of this post, however, so have a look at the Quick Tip we’ve written for that exact purpose.

好消息是–有可能。 但是,这超出了本文的讨论范围,因此,请看一下我们为此目的编写的快速提示

部署应用 (Deploying Applications)

Let’s see how easy it is to get started deploying apps with Zend Server 7.

让我们看看开始使用Zend Server 7部署应用程序有多么容易。

准备好的应用 (Prepared App)

There are several prepared apps ZS knows how to install. For example, to find out how you can install PhpMyAdmin, read the optional Step 5 of our Quick Tip – it’s about one minute of work to get it up and running.

ZS知道如何安装几个准备好的应用程序。 例如,要了解如何安装PhpMyAdmin,请阅读我们的“ 快速提示”中的可选步骤5,安装并运行它大约需要一分钟的时间。

演示应用 (Demo App)

Zend Server also offers the installation of a demo Zend Framework 2 application. To install it, we click the generic “Deploy Now” button and follow the steps.

Zend Server还提供了演示Zend Framework 2应用程序的安装。 要安装它,我们单击通用的“立即部署”按钮并按照步骤进行。

alt

For the host name, I picked test.app, a host I defined a while back for all VM experimentation purposes. I encourage you to add some experimentation hostnames to your host’s hosts file, so you can live a hosts-free life when playing around with Vagrant, and defining short-life apps.

对于主机名,我选择了test.app ,这是我为所有VM实验目的而定义的主机。 我鼓励您在主机的hosts文件中添加一些实验主机名,以便在与Vagrant一​​起玩耍并定义短命应用时可以过着无主机的生活。

alt

After deployment, you should be able to access the ZF2 demo application via host:8000, or in my case, like so:

部署后,您应该能够通过host:8000来访问ZF2演示应用程序,或者就我而言,如下所示:

alt
空白应用 (Blank App)

What if we want a blank app, though? Do we always need to use templates? Nope. There are two types of apps you can custom-add to the ZS management interface. We’ll cover them next, but first, go to Applications -> Apps in the GUI – you need to see the two options from the screenshot below.

但是,如果我们想要一个空白的应用程序怎么办? 我们是否总是需要使用模板? 不。 您可以自定义将两种类型的应用程序自定义添加到ZS管理界面。 接下来,我们将介绍它们,但首先,请转到GUI中的“ Applications -> Apps ” –您需要从下面的屏幕快照中看到两个选项。

alt
添加已安装的应用程序(定义) (Adding an installed application (Define))

Define Application will let you point ZS to an existing and working PHP application. The application can, but doesn’t have to be on this server – remote applications can be added, too. However, it’s important to note that defining an application does not put the app at the mercy of ZS, and so ZS cannot manage it (deploying, reading logs, reinstalling, debugging and more). It’s simply there as a “still alive” checker for another app (notice the health check URL – that URL is pinged and reports any problems encountered).

定义应用程序可让您将ZS指向现有且正常工作PHP应用程序。 该应用程序可以但不必位于此服务器上,也可以添加远程应用程序。 但是,请务必注意,定义应用程序不会使该应用程序受到ZS的支配,因此ZS无法对其进行管理(部署,读取日志,重新安装,调试等等)。 它只是作为另一个应用程序的“仍然存活”检查器存在(请注意运行状况检查URL –该URL被ping通并报告遇到的任何问题)。

Let’s add Google.

让我们添加Google。

alt
alt

This isn’t very fun though. Let’s have a look at deployment. If you’d like to know more about Defining, see here.

不过,这不是很有趣。 让我们看一下部署。 如果您想进一步了解“定义”,请参见此处

部署新应用程序(部署) (Deploying a new application (Deploy))

Deploying an application is a significantly more complex, exciting and useful endeavor. First, we need a sample application somewhere on the server. Let’s go with Laravel’s skeleton app.

部署应用程序是一项更加复杂,令人兴奋和有用的工作。 首先,我们需要服务器上某处的示例应用程序。 让我们来看一下Laravel的骨架应用程序。

To use the command line PHP that comes with ZS7, we need to add it to our path. In the VM, in the terminal, execute the following:

要使用ZS7随附的命令行PHP,我们需要将其添加到我们的路径中。 在VM的终端中,执行以下操作:

echo "PATH=\"/usr/local/zend/bin:\$PATH"\" >> ~/.profile
source ~/.profile 
php --version

If you got a good version output for PHP and not a “command not found” error, you’re all set. Now let’s install Composer globally and initiate the Laravel project.

如果您为PHP获得了良好的版本输出,而没有出现“找不到命令”错误,那么一切都准备就绪。 现在,让我们全局安装Composer并启动Laravel项目。

cd ~/Code
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
composer create-project laravel/laravel test2.app --prefer-dist

You can quickly check that it renders properly by executing php public/index.php.

您可以通过执行php public/index.php来快速检查它是否正确呈现。

In order to be able to deploy this application on Zend Server, we need to turn it into a deployable package.

为了能够在Zend Server上部署此应用程序,我们需要将其转换为可部署的程序包

cd ~/Code
zdpack create laravel-package

zdpack is the packager which, through the create command, creates the necessary package subfolders for us in the folder laravel-package. What we need to do now, is move the Laravel application code into the data subfolder:

zdpack是打包程序,它通过create命令在laravel-package文件夹中为我们创建必要的软件包子文件夹。 我们现在需要做的是将Laravel应用程序代码移到数据子文件夹中:

mv test2.app/* laravel-package/data/

Then, it’s recommended we edit the deployment.xml file. It contains data such as project name and description, database connection credentials, and other metadata. The only thing we need to modify is the docroot node – set it to data/public instead of data. See full list of available nodes here.

然后,建议我们编辑deployment.xml文件。 它包含诸如项目名称和描述,数据库连接凭据以及其他元数据之类的数据。 我们唯一需要修改的是docroot节点-将其设置为data/public而不是data在此处查看可用节点的完整列表。

Validate the changed XML file with zdpack validate deployment.xml, and if all goes well package it with

使用zdpack validate deployment.xml更改后的XML文件,如果一切顺利,则将其打包

cd ~/Code
zdpack pack laravel-package

This will create a laravel-package.zpk file which you can upload through the “Deploy” popup in the Zend Server GUI:

这将创建一个laravel-package.zpk文件,您可以通过Zend Server GUI中的“ Deploy”弹出窗口上传该文件:

alt

If you go through the wizard the app should successfully deploy, but running it through the browser still won’t work. What gives?

如果您通过向导进行操作,则该应用程序应该可以成功部署,但是通过浏览器运行该应用程序仍然无法正常工作。 是什么赋予了?

调试 (Debugging)

Let’s use this opportunity to debug the problem. By going into the Dashboard and selecting “laravel-package” or what ever you named your app, you should see it consists of 100% errors. It looks like it’s trying to do some file operations, but fails.

让我们利用这个机会来调试问题。 通过进入仪表板并选择“ laravel-package”或您命名的应用程序名称,您应该看到它包含100%错误。 看起来它正在尝试执行一些文件操作,但失败了。

alt

Obviously, we’re dealing with some file permission errors. In fact, if we look at the stack trace, we can see exactly which file the app is trying to create:

显然,我们正在处理一些文件权限错误。 实际上,如果我们查看堆栈跟踪,就可以确切地看到应用程序尝试创建的文件:

alt

To alleviate this, we’ll need to perform some permission fixes. In the “Virtual Hosts” section of ZS, you can easily find out where each app resides on the filesystem. Armed with this knowledge, we can execute the command:

为了减轻这种情况,我们需要执行一些权限修复。 在ZS的“虚拟主机”部分,您可以轻松地找到每个应用程序在文件系统上的位置。 有了这些知识,我们可以执行以下命令:

sudo chmod 777 -R /usr/local/zend/var/apps/http/test2.app/80/0.1_7/app/storage

Note that full permission (777) is probably not the optimal way to go here, security-wise, so keep it 777 in development only. In production, you would make sure the user that Zend runs PHP as is the owner of the app/storage folder. Reload the URL of our Laravel test app now, and notice it works like a charm:

请注意,出于安全考虑,完全许可(777)可能不是到达此处的最佳方式,因此,仅将其保留在开发中是777。 在生产中,应确保Zend用户以app/storage文件夹的所有者身份运行PHP。 现在重新加载我们的Laravel测试应用程序的URL,注意它的工作原理像一个超级按钮:

alt

结论 (Conclusion)

Zend Server 7 is a feature rich suite for managing, deploying, distributing and debugging of PHP applications. In a way, it binds your application to itself, so once you go ZS, you don’t go back – similar to HHVM. Whether or not the additional features are worth it, however, is up to you to decide. Do you favor ease of deployment and debugging, or would you rather keep your app 100% instant-portable?

Zend Server 7是功能丰富的套件,用于管理,部署,分发和调试PHP应用程序。 在某种程度上,它将您的应用程序绑定到自身,因此,一旦您进入ZS,就不会再回头了-类似于HHVM。 但是,附加功能是否值得决定。 您是否赞成简化部署和调试,还是想让您的应用程序100%即时可移植?

Either way, ZS is a godsend for any administrator in charge of several projects, and I’ll definitely be testing its features more in the coming months. Will you join me? Care to give it a shot and report back with potential troubles and/or important features we missed? Looking forward to your comments!

无论哪种方式,ZS都是负责多个项目的任何管理员的天赐之物,并且我肯定会在未来几个月内对其功能进行更多测试。 你会和我一起么? 愿意试一试并向我们报告潜在的问题和/或我们错过的重要功能吗? 期待您的评论!

翻译自: https://www.sitepoint.com/getting-know-zend-server-7/

zend guard 7

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值