Zend Server PDF
Zend Server PDF
Zend Server PDF
Course Introduction
3
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Course Introduction
Course Content
Introductions
Course details
Web conferencing tool
Course virtual machine
Course applications
4
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Introductions
Student and instructor introductions. Please offer a little information about yourself. Here are some ideas:
Your location
The time of day where you are located
Your programming background
Other languages in your toolkit
Something about yourself unknown to the everyone
5
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Course Details
In this course, you will learn about Zend Server. By the time you are finished, you will learn how to:
Includes:
Microphones are muted on entry to reduce ambient noise, and video of participants is disabled.
8
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
The VM provides a working environment for the student without the need to setup an environment themselves.
An operating system
A database server
The Docker container system
The Gedit text editor
Course applications
Other software as required
11
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Course Applications
BASEPATH/home/vagrant/Zend/workspaces/DefaultWorkspace.
etc: Contains entries which will be made to /etc/hosts as well as virtual host definitions
blogapp: Sample app ... lots of errors
jobs: Contains a script used to demonstrate the use of Job Queue
sandbox: Area set aside for experimentation
wikiapp: Sample app to deploy
wikiapp_cache: Used to demo caching
wikiapp_monitor: Contains deliberately slow and error ridden code for the Monitoring course module
12
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Lets Go!
13
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Module 1
Introduction to Zend Server
14
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Zend Server
Zend Server editions
15
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Zend Server
About
Architects, IT managers, developers, & system admins who want to maintain a high quality of service for their web sites by:
Many problems occur because different PHP versions are used in development, testing and production.
Zend Server deployment maintains reliability and consistency.
The unattended installer facilitates remote customer deployment.
Includes:
Zend Server is designed to fit into the bigger picture of Continuous Delivery, providing deployment capabilities.
Think of it a tool which helps you automate the process of efficiently getting an app from development to production.
Integrates well with delivery components which include Bamboo, Chef, docker, Jenkins and Nagios.
22
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Production
Small Business
Professional
Enterprise
Production Editions Comparison
Developer
Standard
Enterprise
Developer Editions Comparison
Support for CentOS or Ubuntu, MySQL, MariaDB, PostgreSQL, Mongo DB and PHP
More Info
23
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Module Summary
This module included:
Zend Server
Zend Server editions
24
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Module 2
Zend Server Installation
25
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Installation resources
First run expectations
Virtual machine installation
Lab: Zend server installation
Control Script
26
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Installation Resources
Upgrading from Earlier Versions
Important considerations:
Export settings
Remove the earlier version
Install the latest version of Zend Server
CentOS/RHEL/Fedora
Debian/Ubuntu
Mac OS
Windows
IBMi
28
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Installation Resources
IBMi
Logging into the IBMi as a *SECOFR user, and downloading the installation package.
Creating a SAVF in QGPL under the name ZENDPHP7
Silent
Interactive
The "Getting Started" screen is an excellent first landing page, containing a menu of links about the various menu options available.
35
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
http://localhost:10081
36
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
root@server-training:~# su
...
37
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
5. Update the repository. This is necessary to tell Ubuntu about the new repository.
http://localhost:10081
38
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Control Script
The Zend Server control script is a collection of commands used to control, and gain status of, Zend Server and installed web server
daemons.
The most common control commands, most of which have a start|restart|stop variant, include:
Module Summary
This module included:
Module 3
Zend Server Setup
42
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
These components can be enabled or disabled as appropriate for the environment we are using
Components are:
The PHP menu provides a phpinfo() screen that outputs Server and PHP configuration. This provides easy access to the information
contained in the php.ini file, including:
Go to Administration | Components and verify the following Zend Components are On:
Code Tracing
Data Cache
Debugger
Deployment
Job Queue Monitor
OPcache
Page Cache
Statistics
47
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Zend Server Components
Components
To change a component's status, select the checkbox beside a component and click the Disable button at the top of the screen.
After changing status, a message appears prompting us to restart Zend Server. Click the highlighted Restart Server button at the top
right of the screen.
More than one component can be loaded or unloaded before we click Restart Server.
All changes made prior to restarting Zend Server are applied when it restarts, or if we restart our web server. Even if we navigate to
other tabs, the changes are kept and are not applied until Zend Server restarts.
Changes are updated in the Components page and in the php.ini file.
48
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Zend Server Components
Setup and Control Scripts
/usr/local/zend/bin/lighttpdctl.sh stop|start|restart
/usr/local/zend/bin/gui_passwd.php
/usr/local/zend/bin/setup_jb.sh
/usr/local/zend/bin/java_bridge.sh stop|start|restart
Logs
Log Rotation
To override the native Zend Server log rotation mechanism use the Apache logrotate directive
/usr/local/zend/var/log/*.log
{
size 5M
missingok
rotate 10
compress
delaycompress
copytruncate
}
50
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Logs
Log Rotation
Settings Summary
Additional Notes
A configuration file for all the files located in /usr/local/zend/var/log/ that are picked-up by logrotate
logrotate checks the file size of each log every time it is executed (through a daily cron job on most systems)
If the file size exceeds 5MB, the log file is archived by moving the content to a new file and truncating the log file
The new file's name is the same name with an additional number added to the file name
After exceeding 10 files the oldest is deleted and replaced with new content
52
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Linux
Windows
IBMI and Mac
53
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Ports and Services
Linux
After installation, Zend Server's components use the following ports on Windows:
PHP Extensions
Definition
Use the user interface ( PHP | Extensions ) to view and configure commonly used directives. Available directives are grouped by PHP
module in expandable lists.
Click on the row for the desired module to expand the list / options. Where relevant, input fields are available to change a directive's
value
Search for particular directives using the free text search field. Type in part or all of the directive name. Alternatively, search using part
of the directive description
58
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
PHP Extensions
Display Status
Off: the extension is not running on the machine (code that attempts to use the extension's functions won't work)
Loaded: the extension is running on the machine
Built-in: only for extensions that have dependencies on, or were compiled with, PHP - this status cannot be altered
Built-In Loaded
date intl
PDO pdo_mysql
session tidy
59
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
PHP Extensions
Directives
Definition
These directives should not be added to the php.ini file manually, especially when working in a clustered environment.
For modules or directives not handled by the Zend Server Zend Server UI, create a new file /usr/local/zend/etc/conf.d and add directives to
that file if required, then manually copy this file to all nodes in the cluster.
There is no way to predict which directives third party extensions add. Check the project's site to check directives related to third party
extensions.
60
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
PHP Extensions
Directives
From the command line you can manage applications, libraries, virtual hosts, clusters, extensions, and API keys
You can also, of course, restart PHP and/or the server itself
To see a list of options, type the following (not all options displayed):
/usr/local/zend/bin/zs-manage --help
zs-manage: Manage Zend Server using the Web API
usage: zs-manage <command> [ arguments... ]
available commands:
app-get-status show status of app(s) on a server/cluster|
app-deploy deploy an application
app-remove remove an application
app-update update an application
app-rollback rollback an application
library-deploy deploy a Library
library-remove Remove a Library with all its versions
library-get-status Get the librarie(s) status
vhost-add add a new vhost to Zend Server's web server
etc.
63
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Command Line Utilities
Command Line Operations
Use the command line and API key to get the status of currently deployed libraries
66
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Command Line Utilities
CLI Tool
zs-client
CLI Tool zs-client.sh is a utility that allows easy automation for Zend Server and Zend Server Clusters:
Location: /usr/local/zend/bin
The CLI Tools code is written in PHP and is located in the directory: /usr/local/zend/share/sdk/
67
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Command Line Utilities>CLI Tool
zs-client Help
/usr/local/zend/bin/zs-client.sh --help
The commands are organized in groups. For example this lists all server management commands:
/usr/local/zend/bin/zs-client.sh command:server
To get help for only one command, append the --help flag to it. For example:
Find one of the Web API Keys generated in the last exercise
/usr/local/zend/bin/zs-client.sh --help
This prints Help information about all commands. The command we are interested in is in the command:server category
70
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Module Summary
Module included:
Module 4
Virtual Hosts / Zend Deployment
72
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Virtual hosts are managed via the Zend Server UI at: Applications | Virtual Hosts
Deploying applications can only be done on virtual hosts managed by Zend Server.
Zend Server identifies virtual hosts already defined in your system (aka: "System-defined"). These can be "converted" to enable
deployment.
74
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Virtual Host Management
Adding/Editing Virtual Hosts
Virtual hosts can be added and later edited using the deployment wizard on Applications | Virtual Hosts page
Editing the virtual host template defines the virtual web server's configuration
Click on the circle top right to restart. NOTE: not only does the Apache server restart, but the PHP module is reloaded which could
potentially disrupt existing website visitors!
79
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Virtual Host Management
Lab: Setting Up Virtual Hosts
Create virtual hosts for each of the following applications. These virtual hosts are used in later exercises. BASEPATH is
/home/vagrant/Zend/workspaces/DefaultWorkspace
Configuration Template
<VirtualHost *:${port}>
DocumentRoot "/home/vagrant/Zend/workspaces/DefaultWorkspace/
wikiapp_monitor/public"
<Directory "/home/vagrant/Zend/workspaces/DefaultWorkspace/
wikiapp_monitor/public">
Options +Indexes +FollowSymLinks
DirectoryIndex index.php
Order allow,deny
Allow from all
AllowOverride All
Require all granted
</Directory>
ServerName ${vhost}:${port}
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
IncludeOptional "${aliasdir}/*.conf"
</VirtualHost>
Managed Applications
Zend Deployment
Available for Zend Server running on Apache or Nginx, either stand-alone or in a cluster. IIS is not supported.
You can configure Zend Server for either Hot Deployment or Cold Deployment
Deploying an application is the process of copying , configuring and enabling a specific application to a specific base URL on Zend
Server or Zend Server Cluster Manager node(s)
Once the deployment process has finished, the application becomes publicly accessible on the base URL
The server carries out this two step process by first staging the application, and then activating it after successful staging
IMPORTANT: the size of the deployment package must be less than the post_max_size and upload_max_filesize php.ini directives
87
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Zend Deployment
Application Deployment
To reach the "Deploy Application" wizard select Applications | Manage Apps | Deploy Application Browse to and .zpk application package, select
and click Next
Display Name: The name Zend Server will display for this application
Virtual Host: Select the default server (uses default virtual host on your server) or add a new virtual host (click Add New and enter new
name)
Path: Second part of your base URL; can only be a directory - specifying a file causes the app to deploy with errors; leaving this field
empty will deploy the app on the virtual host's root
You will also be presented with a dialog box of custom parameters, if any were specified in deployment.xml
88
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Zend Deployment
Lab: Deploy Demo Package
/usr/local/zend/gui/data/demo.zpk
Zend's deployment tools can create a skeleton package in a .zpk package file. Run the help command from the bin directory to see
usage options.
OS Notes
Tool Location
Linux/OSX /usr/local/zend/bin/zs-client.sh
Windows C:Program Files\Zend\ZendServer\bin\zs-client.bat
Usage
Linux/OSX /usr/local/zend/ bin/zs-client.sh command:packaging
Windows zs-client.bat command:packaging
Note: In the following slides we will use zs-client.sh or just zs-client as a tool name. These should be changed to zs-client.bat if using
Windows.
90
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Zend Deployment
Deployment Package Skeleton
zs-client.sh initZpk
To create a deployment skeleton:
zs-client.sh command:packaging
To see the available packaging options:
The Deployment package is a file with extension *.zpk, containing the entire application project complete with deployment descriptors.
To create a package ready for deployment run:
name: The name of the package. If not provided the name will be constructed from the name of the application and its versio
version: The version release of the package. The version release will be replace in deployment.xml before creating ZPK package
composer: Enables experimental composer support
composer-options: Adds composer options when running composer
composer-dist-files: Comma separated list of YAML .dist files containing user parameters
92
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Zend Deployment
Deployment Scripts
pre_* and post_* hook scripts are provided for each phase
# Stage Notes
1 Stage Place the contents of the .zpk application package on the server or on the cluster nodes
2 Activate Perform the final steps necessary to make a staged application public
3 Rollback Rolls back the application to the previous version
4 Deactivate Deactivates the application on the server
5 Un-stage Cleans up the server and deletes any files that were relevant only to the now deactivated application
93
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Zend Deployment
Deployment Script Examples
The following list provides examples of operations that are commonly performed by various hook scripts:
Pre-stage: Validate and applying user customized parameter values, verify the existence of generic prerequisites, ...
Post-stage: Create a new database schema, modify a file or directory permissions on staged source files, ...
Pre-activate:
Post-activate: Remove a temporary banner ("Down for Maintenance"), reset a cache, ...
Pre-rollback: Return configuration files or the database to their previous version, ...
94
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Zend Deployment
Deployment Script Examples (cont.)
Post-rollback: Take the site out of maintenance mode, return the load balancer settings, ...
Pre-deactivate: Put up a banner ("Down for Maintenance") for the previous version, ...
Post-deactivate: Modify external configuration files, ...
Pre-unstage: Back up specific applications files such as audit logs and other data files, ...
Post-unstage: Clean up external files referencing the application (which are no longer needed)
95
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Zend Deployment
Deployment Script Constants
The deployment.xml file in the application's main directory contains the meta information required to get an application up and running,
it consists of the following:
<parameters>
<parameter display="Log File Name" id="logFilename" identical="logFilename"
readonly="false" required="true" type="string">
<defaultvalue>deployment.log</defaultvalue>
<description>Name of the log file</description>
</parameter>
<parameter display="Default Locale" id="locale" identical="locale"
readonly="false" required="false" type="choice">
<validation>
<enums>
<enum>fr_FR</enum>
<enum>de_DE</enum>
<enum>es_ES</enum>
</enums>
</validation>
<defaultvalue>en_GB</defaultvalue>
</parameter>
</parameters>
102
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Zend Deployment
Other Deployment Tasks
Synchronizing / Redeploying an Application: An application might be redeployed whenever there is a failure during deployment. If
any changes in the package (even if the .zpk file remains the same), the application must be updated
Updating an Application: Upload a new application package for an existing application and base URL. We can also change the values
of the application's parameters during this process
Rolling Back an Application: Allows for replacing the current version of an application with the previous version deployed on the
server.
Removing an Application: Deactivates the application, cleans up any related web server configuration, removes all associated files.
As with all deployment operations, removing your application from the cluster will affect all of the cluster's nodes
103
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Zend Deployment
Location of the Deployed Applications
/usr/local/zend/etc/sites.d
/usr/local/zend/etc/sites.d/http/__default__<vhost name>
/usr/local/zendphp7/var/data/__default__/0
104
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Zend Deployment
Changes to Apache During Deployment
When performing a deployment action, such as deploying, synchronizing / redeploying, updating, rolling back or removing an
application, Zend Server restarts and performs certain changes to your Apache
The web server configuration is modified to create virtual hosts and aliases for deployed applications
Inside the default virtual host section (the first defined virtual host is assumed to be the default)
At the end of the Apache configuration
105
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Zend Deployment
Changes to Apache During Deployment
For each deployed application, Zend Server creates the following files:
The globals file holds definitions such as NameVirtualHost *:<port> for each port that actually has virtual hosts
/usr/local/zend/etc/sites.d/vhost_<host>_<port>.conf
/usr/local/zend/etc/sites.d/http/<host>/port/
106
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Zend Deployment
Lab: Zend Server Deployment
Create a deployment package of the wikiapp application which is located under /home/vagrant/Zend/workspaces/DefaultWorkspace/wikiapp using
either the command line tool or Zend Studio (or a combination of both)
Change to this directory and use the command line tool to initialize deployment structure
Create a scripts directory and two PHP scripts for pre-activate and post-unstage which log the script filename and current date/time
Module Summary
Create and manage virtual hosts
Manage applications
Create and deploy packages
Develop pre-* and post-* deployment scripts
Define configuration options in the deployment.xml file
108
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Module 5
Z-Ray
109
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Z-Ray
This module covers:
Z-Ray
Z-Ray plugins
Z-Ray modes
Z-Ray settings
Z-Ray history
Z-Ray command line
Z-Ray mobile access
110
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Z-Ray
Definition
Z-Ray is a debugging and productivity tool that provides PHP developers with:
Displays a list of all the requests sent by the page to the web server, included sub-requests e.g. AJAX calls.
A breakdown of how server time was split between PHP, database, I/O and Network.
A comparison between consumed vs. free * memory at the point where memory consumption for the request peaked.
When minimized, Z-Ray displays the total amount of processing time (ms) and the peak amount of server memory (Mb) consumed for
the URL request.
Displays monitored events triggered during the URL request currently selected and displayed in the Page Requests panel.
Displays errors and exceptions triggered by the URL request currently selected and displayed in the Page Requests panel.
Displays database queries executed by the URL request currently selected and displayed in the Page Requests panel.
Includes time it took to execute, fetched rows and whether it was successful.
Supported database extensions: All PDO extensions, OCI, MySQL , MySQLi , DB2, SQLite3, PostgreSQL .
117
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Z-Ray
Functions
Displays the PHP functions called during the URL request currently selected and displayed in the Page Requests panel.
Statistics include the number of times a function is called, duration and average time.
Allows filtering by namespace and function groups (i.e. native PHP, Composer, etc.).
Displays variables used in the URL request currently selected and displayed in the Page Requests panel.
Z-Ray Plugins
Definition
Z-Ray plugins extend Z-Ray and add additional panels with information specific to the application/framework/platform used.
Z-Ray comes bundled with a number of built-in plugins for Z-Ray ( Apigility, Composer, Drupal, Laravel, Magento, Symfony, WordPress,
ZF1, ZF2).
Z-Ray can be enabled / disabled at any point after Zend Server is launched. Z-Ray is displayed and activated when Zend Server is in
Development mode (selected during ZS launch). It can manually be enabled at any time, or during any mode, via the Zend Server UI Z-
Ray | Access Mode.
API zray_disable (true); API call from within your application code
GET parameter ZRayDisable =1 Part of the URI
Request header ZRAY-DISABLE=1 HTTP header
The above options only work if Z-Ray is Enabled. If Z-Ray is Disabled, or in running in Selective mode (next slide), these options won't
work.
If Z-Ray is enabled for a PHP application, we see the following bar injected in the footer.
121
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Z-Ray Modes
Mode and notes:
Enabled: The default mode when launching Zend Server with the development profile. In this mode, Z-Ray collects data for all requests
made to the web server
Selective: This mode allows secured access to Z-Ray for specific IPs and URLs, and for a specific time duration, and is ideal for
production environments
Disabled: The default mode when launching Zend Server with on of the two production profiles (Single/Cluster). This mode disables Z-
Ray data collection for every page located on the web server. Z-Ray Snapshots for URL Insight however, will not be affected
122
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Z-Ray Modes
Selective Mode
The URL can be given to the person who wants to use Z-Ray.
ifconfig
Z-Ray Settings
Zend Server Menu Configuration
Z-Ray History
GET
POST
CLI
2xx
3xx
4xx
132
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Z-Ray History
Lab: History | Actions | Open
Results:
134
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
// Contents
$ cat sample_client.php
<?php
$url = 'http://api.test:8888/api/widget/test';
echo file_get_contents($url);
echo PHP_EOL . date('Y-m-d H:i:s') . PHP_EOL;
// CLI command
$ php sample_client.php
{"widget":"test","price":"111.11","date":"2016-12-28 11:11:11"}
2016-12-26 07:37:31
Z-Ray Live.
135
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
1. From a mobile device on your local area network, enter this URL:http://ip.address.from.lab1/demo
2. View current statistics on mobile access.
3. Use Z-Ray Live! to monitor access from the mobile device.
4. Using a smart phone or tablet which is on your own local area network (LAN), enter this URL:
http://ip.address.from.lab1/demo
Module Summary
Use Z-Ray Live
Get detailed information on running applications
Install and manage Z-Ray plugins
Configure Z-Ray modes
View Z-Ray history
139
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Module 6
Monitoring
140
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Monitoring
This module covers:
Resolving problems
The dashboard
Monitoring
Events
Rules
Logs
URL insight
Settings
141
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Resolving Problems
The Problem with Problem Resolution
server load
input data
database state
etc. etc. etc.
142
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Resolving Problems
Root Cause Analysis
Automatic notification of issues via optional email alerts and/or URL callbacks.
Code Tracing pinpoints the request execution that triggered the issue for fast resolution.
Three categories of API functions allow access to Code Tracing and Event Monitoring.
143
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Dashboard
Definition
Monitoring
Events
Definition
Filter Events
View Event Details
Delete Events
151
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Monitoring
Events
Each issue is an aggregation of one or more events with shared, pre-defined characteristics.
These shared characteristics help to identify the source of the event and the surrounding circumstances.
The rules for event generation are set in Monitoring | Event Rules
152
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Monitoring
Events
Filtering Options
Include:
Use the filter option to reduce the number of events displayed. Create custom filters by selecting and saving a set of criteria.
154
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Monitoring
Events Details Page
Basic tasks include simple tasks, like reviewing the event details (ex: rule name), URL, script name, request parameters and server
environment.
155
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Monitoring
Events More Details Page
Lets you drill down to identify and investigate the problem, and sometimes display the solution.
156
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Monitoring
Events Characterizations
Details are characterized as Basic, General, and Group. Here are the Basic and General characterizations:
Basic:
ID and Rule Name
Occurrence Info
Severity
General:
URL and Source File
Function Name
Error String and Type
157
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Monitoring
Group Characterization
Inside a single issue, events are divided into groups according to the time they occurred.
A new group is created only if there is no activity for at least five minutes.
If a new event occurs after five minutes, a new group is added to the issue.
158
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Monitoring
Events Group Operations
Drilldown: Click on a specific group to display details collected for that group
Diagnose: Available options are: Debug, Profile, and Open File. Note: the server specified in Settings (default is originating server)
Export: Generate an XML file with the basic and general details of a particular group
159
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Monitoring
Event Details
160
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Monitoring
Event Rules
Details:
Details:
Definition
Logs provide critical insight into errors and unwanted application behavior within the system environment.
Requires accessing Zend Server's central DB, which usually should not be changed.
Should only be executed by someone who completely understands the concept and procedure; preferable to leave this operation to
Zend consultants to avoid data loss.
166
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Monitoring
Logs
Server Specific
Apache:
PHP Error Log *
Zend Server error logs
Apache Error & Access Logs
Windows IIS:
PHP Error Log *
Zend Server error logs
PHP
168
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Monitoring
Logs Other
Ensure proper file system permissions are set for the user zend (username for
the Zend Server UI)
To add other logs, access and update Zend Servers database tables which,
under normal circumstances, should not be changed.
2. At the sqlite> prompt, note the highest ID from the table after entering this SQL statement:
3. Enter the following SQL statement at the prompt (as one line) and be sure to:
Swap the id from above for placeholder
Edit the description and file path placeholders
4. Add the Wiki Monitor application log to Server's Logs located at:
/home/vagrant/Zend/workspaces/wikiapp_monitor/data/logs/wiki_monitor.log
Definition
Events
URL Insight
(cont.)
The instructor will first demonstrate and guide you through two types of events, for which there are already set rules:
When a specific PHP request consumes more than the specified amount of memory it generates this event
1. Set the High Memory Usage (Notice) to 1024 KB. Why is this appropriate for the Wiki application?
2. Open browser to http://lorem-ipsum.perbang.dk/
3. Generate 20 paragraphs of Lorem Ipsum
4. Open browser to http://wikiapp.monitor/article/edit/title/Live+from+Oscon Paste in text and save
178
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Monitoring
Lab: Monitoring a Custom Event
This unique event rule is used to initiate events by a PHP script. Used to generate events when the API function
zend_monitor_custom_event() is called from within a PHP script.
1. Specify for custom events to be considered as "notice" events when triggered. Generated from within code using the API function
zend_monitor_custom_event (). Such as in the LoginController line 33 of the wikiapp_monitor application.
2. Open a browser to http://wikiapp.monitor/login
179
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Module Summary
Using the Dashboard
Viewing details on events
By establishing Monitoring Rules
Through its logs
Gaining insight into usage by URL
180
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Module 7
Caching
181
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Caching
This module covers:
Application Optimization
Page Caching
Data Caching
OpCache
OPCache and Blacklists
182
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Application Optimization
Zend Server gives us several ways to optimize applications:
Page Caching: Cache entire HTTP response based on highly customizable parameters
Data Caching: API to cache data items (DB query results, web service calls, etc.)
OpCode Optimization and Caching: Reduces disk access by caching compiled bytecode
183
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Page Caching
Definition
Process of running code once & saving output on the server for re-use.
Improves performance.
Server supports URL-based full-page caching for Zend Framework and other MVC architectures.
Also includes a set of data caching APIs (Data Cache) to improve performance from within the code.
Using Apache Bench we can see the difference page caching can play.
ab -t 10 http://wikiapp.cache/article/view/title/Greek+shipping
1. Create a caching rule for viewing a static, online article entitled, "Greek Shipping." The URL is:
http://wikiapp.cache/article/view/title/Greek+shipping . The view of the article 'Greek Shipping' can be cached for a reasonably long period. The
output for each viewing request is a large, pure HTML output.
2. Decide what values to set for: Cache Conditions and Cache Duration
3. Now try the following command in the terminal to have the page cache used:
ab -t 10 http://wikiapp.cache/article/view/title/Greek+shipping?cache=1
Data Caching
Definition
The Data Cache API is used by inserting its functions into the PHP code.
It features:
Memory caching improves server responsiveness primarily in environments that are running high-traffic applications.
Off-load activity directed towards the hard disk in order to help increase performance and responsiveness.
Disk caching is more suitable for smaller applications and ensures cached content is available after restarting the machine.
189
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Data Caching
SHM/Disk Storage Implementation
SHM/Disk storage is implemented by using the appropriate API functions and configuring the Data Cache directives.
Shared memory:
Shared memory:
Shared memory:
Using namespaces for caching allows us to define a key as an identifier to delete select items from the cache rather than unnecessarily
removing shared instances.
Namespace support is intended for environments running large applications separated into modules.
Applying a namespace to each module provides the identification necessary to pinpoint all cached items belonging to that module.
Set the cache namespace by adding it as a prefix to the cache with ' :: ' as a separator.
Defining the Cache folder depth is intended for environments that use a large number of keys.
Increase the cache folder depth according to the quantity of content that requires caching (small amount = 0, large quantities = 2)
NOTE: A single directory may include several keys, depending upon the quantity of cached content.
194
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Data Caching
Folder Depth Configuration (cont.)
The accepted values represent the levels that the cached files are stored.
OPCache
Definition
Once PHP code is compiled for the first time, it is saved in the server's memory.
Each time the code is called, the pre-compiled version is used instead of waiting for the code to compile causing a delay each time the
code is used.
197
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
OPCache
Check Understanding
This alternative depends on the amount of memory available for allocation to the Accelerator.
199
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
OPCache
OPCache and Blacklists
Creating a Blacklist provides an alternative, effective way to exclude code storage for particular PHP files (selectively disabling
OPcache)
"Blacklist" in this context is not security related: it's a list of files which are excluded from caching.
Directories containing files larger than the allocated memory defined in opcache.memory_consumption
Directories containing more files than the allocated quantity defined in opcache.max_accelerated_files
Large files that have high memory consumption
If allocated memory is exhausted, select scripts that are known to be the largest and slowest to execute and blacklist them
Files that have long execution time (makes the compilation saving irrelevant)
Code that is modified on-the-fly (for example, auto-generated template files)
200
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
OPCache
Lab: OPcache
We are going to conduct a limited benchmark test that will provide us a comparison of performance before and after using the
Optimizer. Note: This is only a limited test because the tool we will use will not keep track of state in any way.
To create a baseline, we have to have all Server performance enhancement tools disabled. If the application has been altered by
experimenting with blacklists, those have to be removed as well. (Do you remember where to disable OPcache ?)
ab -t 10 -k http://wikiapp.cache/
2. Re-enable the OPcache feature and run the benchmark test again. Did you observe a performance gain?
201
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
OPCache
Lab: Blacklisting
1. Create a text file /usr/local/zend/etc/optimizer_blacklist. Make sure it is readable by Apache user www-data.
2. In Administration | Configurations | Components make sure the component Zend OPcache is Loaded
3. Expand the OPcache line in the table to display its directives
4. Locate the directive : opcache.blacklist_filename and specify the full path to the blacklist file e.g. /usr/local/zend/etc/optimizer_blacklist
(separate multiple paths with a new line)
5. Click "Save" to save changes, and "Restart" to restart Zend Server. Note: if a folder is black listed, all the scripts contained within it will
be automatically blacklisted
202
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Module Summary
What is OpCode Cache and how to implement it
How to set up and use Page Cache
How to set up and use Data Cache
How to blacklist usng OpCode Cache
203
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Module 8
Debugging and Code Tracing
204
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Debugging
Debug Sessions
Debug Tunneling
Code Tracing
205
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Debugging
The Security configuration lets you allow or deny permission to initiate debugging and profiling sessions
Oversight functions of the IDE are seamlessly joined with the monitoring functions of Zend Server; automatic detection can be
overridden here
Debugging / profiling sessions can be directly initiated from and IDE, the Zend Server UI or Z-Ray
207
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Debugging
Debugging Flow Diagram
The Debugger API included in Zend Server is a remote debugging tool designed for developers working with an IDE.
Within Zend Server, the only related function is to define "allowed" or "denied" hosts.
Users define allowed hosts by creating a list of IP addresses (computers running an IDE) permitted to debug PHP code running on this
server.
From the Debugging | Debugger dialog, you can configure debugger security
ifconfig
Debug Sessions
Launching a Debug Session
Debugging and profiling session is initiated in an IDE directly from Z-Ray. Click
the bug icon and select the debugging action desired:
Debug current page - debugs the page currently open in the browser
Debug next page - a debugging session is launched when the next link is clicked,
a form is posted, or an AJAX request is executed).
Debug all forms (POST) - a debugging session will be launched every time a link
is clicked, a form is posted or an AJAX request is executed using the POST
method.
Debug all pages - debugs all pages from the current page.
217
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Debug Sessions
Debugging from Toolbar
1. If not already done, create a virtual host forwikiapp.local which maps to /home/vagrant/Zend/workspaces/DefaultWorkspace/wikiapp/public
2. Install the Zend Debugging Toolbar
3. Browse to http://wikiapp.local/
4. Launch a debug session from the Zend Debugging Toolbar
5. Make sure Z-Ray is enabled on Zend Server
6. Browse to http://wikiapp.local/
7. Launch a debug session from Z-Ray
220
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Debug Tunneling
Definition
Code Tracing
Definition
Can browse a recorded code execution trace to quickly pinpoint root cause of
functional and performance problems
If the Profile Data trace is selected, is generated faster and gives a more readable
view
From the list of code traces at Code Tracing | Traces, Click the code trace number under the ID column.
or
From the Dashboard: If an event was configured to generate a code trace, click the show link under the Code Trace Column
223
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Code Tracing
Code Trace Example
224
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Code Tracing
Profile Data Code Trace Example
225
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Code Tracing
Lab: Code Tracing
1. Edit the rules that were set up for "Function Error", "High Memory Usage", and "PHP Error and Slow Request Execution"
2. Check the "Trace code" and "Always activate Code Tracing for triggered events" checkboxes for each of them (we will need to click into
each event to do so)
3. Generate an event for each of the rules:
php error: create an error in one of the php scripts, and run the page.
function error: try to login with invalid credentials
high memory usage: Access http://wikiapp.monitor.local/recentchanges?throw_events from the browser.
slow request execution: navigate through the site.
226
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Module Summary
How debugging works
How to set up Zend Server for debugging
How to launch a debugging session directly, from the Zend Toolbar, or from Z-Ray
How to configure debug tunneling
What code tracing is and how it works
227
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Module 9
Job Queue
228
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Job Queue
Job Queues
Definition
Examples:
From this dialog you can set the name of the queue,
priority, how many concurrent jobs etc.
236
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Job Queues
Recurring Jobs
General settings include how to handle output, job load, and job history management
Event settings allow you to configure job execution delay, job execution error and job logical error handling
238
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Job Queues
Lab: Create a Job Queue
1. In wikiapp/application/models/Articles.php comment out the line below. This will disable the default behavior of sending out an inline email.
if($jobId) {
return array(true, '');
} else {
return array(false, 'Failed to add to job queue.');
}
This instantiates the ZendJobQueue class and calls the createHttpJob method with the parameters $notificationUrl and $mailParams
242
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Job Queues
Lab: Job Queue API (cont.)
1. Edit an article and save it again. Notice that the FAKEMAIL-* file still gets created in wikiapp/data/logs/. NOTE: Credentials are
User=administrator with password=password
2. Go to the Zend Server Zend Server UI console, Job Queue | Jobs . Ensure that All Jobs is selected in the filter drop down. Notice that a job
appears with a status OK (if the jobs list is empty.
3. Look over the method processqueueAction() in the wikiapp/application/controllers/ArticleController.php. Here the logic to send an email is called,
which results in sending email.
4. A rudimentary security check was used in this implementation, using a shared secret, to ensure the call comes from the application (not
from an unauthorized user).
243
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Module Summary
Managing Job Queues
Scheduling Recurring Jobs
Jobs "Pulse"
244
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Module 10
Java Bridge
245
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Java Bridge
This module covers:
Java Bridge
Definition
When calling Java objects from PHP, use Java coding standards because the Java Bridge does not perform dynamic data conversion
Type conversion must be executed within PHP code before the call
Example:
Installations
Windows Installation
Choose Modify
Click Next
249
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Installations
Windows Installation (cont.)
250
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Installations
Installation on Debian-based Linux (Ubuntu)
To confirm that Java Bridge is running, log in to the Zend Server console and go to Administration | Components
Confirm Zend Java Bridge should read " Loaded". If not, restart Zend Server
252
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Installations
Testing the Connection
As an initial step in utilizing the Bridge, test the connection to ensure the Java Bridge is defined properly and communicating with Java.
The sample code (on following slide) demonstrates the interaction between a PHP application and Java objects that occur in the Java
Bridge implementation.
RECALL:
When calling Java from PHP, Java coding standards must be used to call the correct objects as the Java Bridge does not convert data
dynamically
<?php
// create Java object
$formatter = new Java("java.text.SimpleDateFormat",
"EEEE, MMMM dd, yyyy 'at' h:mm:ss a zzzz");
// Print date through the object
print $formatter->format(new Java("java.util.Date"))."\n";
// We can also access Java system classes
$system = new Java("java.lang.System");
print $system."\n";
// will use toString in PHP5
print "Java version=".$system->getProperty("java.version")." <br>\n";
print "Java vendor=".$system->getProperty("java.vendor")." <p>\n\n";
print "OS=".$system->getProperty("os.name")." ".
$system->getProperty("os.version")." on ".
$system->getProperty("os.arch")." <br>\n";
?>
If the Java Bridge is correctly installed and running, we should receive the following output from the test code:
Check Configurations | Components see if Java Bridge Extensions are not running or the Bridge Server needs to be restarted
1. Open a terminal window and determine if a JRE (Java Runtime Environment) has been installed
java -version
3. From the Zend Server Zend Server UI determine the version of PHP running
4. Install the Java Bridge and accept the proposed set of packages to install. Check that Java Bridge is active in Zend Server. NOTE: you
will need to run most commands as root (i.e. use sudo <command>)
256
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Installations
Lab: Testing Java Bridge
/usr/local/zend/bin/java_bridge.sh restart
257
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Installations
Lab: Testing Java Bridge (cont.)
5. In Zend Studio open the sample php script demojb.php in the sandbox/public folder
6. Add the following code:
<php
$threadTest = new Java('com.zend.demo.ThreadTest');
$thread = $threadTest->getThread();
echo $thread->val;
?>
7. Access http://sandbox/demojb.php from a browser. Note the initial value that is displayed. Refresh the page, highlight the number change.
Repeat a couple of times, varying the response time.
8. Also try this URL: http://wikiapp/java
258
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Module Summary
What is Java Bridge
How to install the Java Bridge on:
Windows
Ubuntu Linux Installation
How to test the connection
259
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Module 11
Plugins
260
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Plugins
This Module Covers:
Plugins
Installation and configuration
Deploying
Plugin Management
261
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Plugins
Definition
Enables us to extend Zend Server's functionality by installing plugins developed and shared by the Zend Server community. Zend
Server plugins extend Zend Server in one, or both, of the following ways:
Z-Ray Plugins
Enable us to display additional information in Z-Ray that we think is important for our development workflow.
Route Plugins
Help Zend Server understand the specific routing system of our application. Using this application awareness, Zend Server can better
aggregate monitoring events to prevent event propagation, and analyze the URLs displayed by the URL Insight feature.
Deploying
Plugins
Plugin Management
From the ZS UI:
Module Summary
How to install, configure and manage plugins for:
Plugins
Installation and configuration
Deploying
Plugin Management
267
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Module 12
Zend Server Web API
268
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Automation of the management and deployment of a stand alone Zend Server or a cluster along with access to most other features
offered by the Zend Server UI
The request format defines the required format for each request sent to Zend Server
Web API HTTP requests use HTTP GET for read-only API calls, and HTTP POST for all state changing API calls.
http://localhost:10081/ZendServer/Api/<ACTION >
https://localhost:10082/ZendServer/Api/<Action >
272
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Requests and Responses
Generic Request (cont.)
All HTTP requests must include the following headers:
Header Notes
Date contains current date and time in GMT time zone, in format specified by the HTTP RFC for date fields. (ex: "Wed, 07 Jul 2010 17:10:55 GMT")
User-agent user agent string is logged by the server and used for message authenticity verification
Host HTTP host header is expected to be present and is used for message authenticity verification
X-Zend-Signature API key name and calculated request signature used to authenticate and validate the request
273
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Requests and Responses
Authentication and Message Verification
Authenticated API requests require the X-Zend-Signature HTTP header to be sent with each request, in the following format:
where <key name> is replaced with the key name, and <signature> is replaced with calculated request signature
Calculate request signatures using the following method. Concatenate the values in order, separated by a colon (:) into a single string
Exact value of the Host HTTP header In most cases, this will be a string in the form <host>:<port>
Request URI, which is the path part of the full request URL without the query string or host name
Hash the generated string with the HMAC/SHA-256 function using the secret API key to obtain the request signature
275
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Requests and Responses
Passing Request Parameters
GET
Parameters are passed in the URL query part (following the ‘ ? ') in a URL-encoded format
requests
POST Parameters should be passed in the Request body, encoded using either the application/x-www-form-urlencoded or multipart/form-data encoding methods. For methods
requests that potentially will transfer large amounts of binary data, the multipart/form-data encoding method must be used.
276
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Requests and Responses
GET Request Example
This sample request is for the getPizzaStatus method, with the following parameters: pizzaId
This sample request is for the makePizza() method, with the following parameters: style, extraCheese, extras
Zend Web API response messages use standard HTTP response codes to designate high-level status (success, failure, ...) and simple
XML payload in the response body to provide additional method specific data or specific error messages
Response Codes:
The Web API HTTP response body will almost always contain an XML document of the following format:
In a response representing an error, the <responseData> XML section is replaced with the <errorData> XML section, which has the
following format:
where:
Some error responses may include additional elements in the <errorData> container
<errordata>
<errorCode>serverDoesNotExist</errorCode>
<errorMessage>A server with the specified ID does not exist in the cluster
</errorMessage>
</errordata>
281
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
API Versioning
API version is specified in the Accept HTTP header.
Ex: Sending a request using API version 1.3 should include the following Accept header in the request:
Accept: application/vnd.zend.serverapi+xml;version=1.3
If the server supports the specified API version, it will handle the request and the response in the appropriate format, matching the
specified API version
The response format and API version will be specified using the Content-type response header:
Content-type: application/vnd.zend.serverapi+xml;version=1.3
If the server is not compatible with the API version being used, the server will return an HTTP 406 "Not Acceptable" response.
282
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
API Versioning
Available API Methods
Each method carries a different operation or is designed to retrieve specific information from Zend Server.
Virtually all Zend Server UI functionality is now also available via the Web API.
The following is a list of the available methods used to manage your server and/or cluster:
tasksComplete clusterForceRemoveServer
getServerInfo clusterDisableServer
getSystemInfo clusterEnableServer
clusterGetServersCount clusterReconfigureServer
clusterGetServerStatus restartPHP
serverAddToCluster restartDaemon
changeServerNameById logsReadLines
clusterAddServer logsGetLogFile
clusterRemoveServer
284
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Server and Cluster Methods
Configuration Management Methods
The following is a list of the available methods used to manage your Zend Server or Zend Server Cluster configuration:
emailSend configurationDirectivesList
configurationExtensionsOn configurationExport
configurationExtensionsOff configurationImport
configurationValidateDirectives configurationComponentsList
configurationStoreDirectives configurationsRevertChanges
configurationSearch configurationsApplyChanges
configurationExtensionsList configurationReset
285
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Server and Cluster Methods
Deployment Methods
applicationGetDetails applicationRemove
redeployAllApplications applicationSynchronize
applicationGetStatus applicationRollback
applicationDeploy defineApplication
applicationUpdate
286
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Module Summary
Zend Server Web API
Handling Signatures, Authentication and Verification
Request and Response Formats
Methods Available For
Server/Cluster
Configuration Management
Deployment
287
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Module 13
Best Practices
288
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Best Practices
This module covers best practices for:
The integration of ZF with Server provides a pre-configured stack, including all system components
These locations should be used with caution since the version of Zend Framework will change with each new version of Zend Server
ZF2.5 and above (including ZF3) are not bundled with Zend Server as they are "componentized"
You can take advantage of Zend Server's support for Composer when using "componentized" libraries
290
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Zend Framework (ZF)
Location of Files
OS Location of ZF Files
<install_path>\share\ZendFramework (or)
Windows
<install_path>\share\ZendFramework2
RPM, DEB /usr/local/zend/var/libraries/Zend_Framework*
Mac /usr/local/zend/var/libraries/Zend_Framework*
IBMi /usr/local/zendphp7/var/libraries/Zend_Framework*
291
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Advanced Diagnostics
Using Zend Server
We have already covered the concept of Events, generated by rules set in Rules Management, tracked and analyzed using Monitor
Here are some guidelines for utilizing more advanced diagnostic techniques:
If the issue is genuine, the Reference Manual provides insight around rules, to help diagnose these problems
292
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
MS Windows also supports an existing IIS installation so we can choose to use the Apache server distributed by Zend
For Linux and Mac, Zend Server uses the distribution's Apache / nginx
Apache <install_dir>\Apache2\htdocs
Windows
IIS C:\inetpub\wwwroot
Mac Apache <install_dir>/Apache2/htdocs
IBM i /www/zendphp7/htdocs
DEB Apache /var/www/html
RPM Apache /var/www/html
293
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Performance Tuning
Best Practices
Page Cache Off if not using URL-based caching (similarly for Data Cache)
Security Considerations
Server Security
Audit Trail
Limit access and create a secure environment by only using specific hosts (full IP address) we are sure we want to permit to connect,
via Debugging | Debugger
Allowed Hosts may change with Software Lifecycle phase (Development vs. Production)
Depending upon whether we are working on a development or production environment, we may want to consider different defaults
In development environments, all the machines that require access to debug should be allowed
In production environments, it is safer to limit access or even allocate only a single machine for access
May also help limit and prevent unnecessary traffic on your production server
297
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Security Considerations
Making Zend Server UI More Secure
An IP address-based access control list for the Administrative Interface on the web server running Server is an added level of security
If you can't login or lose your Zend Server UI password, run the following (as root or administrator):
Apache: http://httpd.apache.org/docs/2.4/howto/access.html
IIS: use the IIS Manager
298
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Security Considerations
Data Masking
Proper configuration of the PHP runtime environment can provide added security to PHP applications
As with performance considerations, directives can be adjusted to enhance security Ex: open_basedir, allow_url_include , etc.
300
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Troubleshooting
Zend Server Exception Caught
Installing Zend Server with a bundled Apache assumes that the following port settings are used:
If a "Zend Server Exception Caught" error message is received when trying to access the Administration Interface, make sure that
Apache is up and running
Linux and Mac: When using https, the port is set by default to 10082, and an "invalid certificate" error will display across all browsers
After installing Zend Server, clicking on shortcut opens the browser with an error
Note: earlier versions of IIS will only have one Web site, but later versions support multiple Web sites
When activating a Web site, make sure to activate the appropriate Web site (the site selected in the installation process)
302
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Troubleshooting
Zend Server fails to
communicate with Zend Studio
Solution: Ensure Debugger is running and available on the alternate server via Administration | Components ; check that the Debugger
is loaded
Possible Cause:
The connection parameters in Debugging | Debugger do not match the settings in Zend Studio's Debugger preferences (IP, Port, and
SSL)
Solution :
Possible Cause:
The Zend Studio IP address is not allowed to debug on the alternate server; may be issue with Firewall settings
Solution:
Go to the administration interface and ensure the Zend Studio IP address appearing in Debugging | Debugger is an allowed host to
debug
304
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Troubleshooting
Windows: Zend Server is not loading
If Zend Server cannot be loaded, or one of the Zend Server related processes causes a crash or unexpected system behavior, use the
installer in Repair mode
Start | Settings| Control Panel | Add or Remove Programs | Zend Server and select Modify to run the installer
If you see a standard Apache 404 error, ensure that mod_rewrite (or an equivalent, i.e. mod_alias) is active. Also, check your rewriting
rules, which could potentially reside in an override file .htaccess. See:mod_rewrite docs
A rewrite engine does not come standard with older versions of IIS. There are several online resources that can set this up. For
Microsoft's URL rewrite module, see reference: https://www.iis.net/downloads/microsoft/url-rewrite
Zend Framework applications need to have the document root set to public. Also, for "SEO" friendly URLs, activate URL rewriting: See:
Zend Framework Skeleton App reference
306
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Module Summary
How to best use Zend Server for Zend Framework apps
Suggesions on performing advanced diagnostics
Recommendations on performance tuning for the server and PHP
Important security considerations
Suggesions on how to secure the Zend Server UI
Various troubleshooting scenarios for Windows, Linux/Mac OSX and Zend Framework
307
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
308
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Acceptance of and
Conditions for Code Use
Rogue Wave Software grants you a nonexclusive copyright license to use all programming code examples from which you can generate similar function tailored to your own specific needs.
The Rogue Wave Software courses' materials are provided "as is" and subject to any statutory warranties which cannot be excluded, Rogue Wave Software, its officers, directors, employees, program developers and
training partners make no warranties or conditions either express or implied, including but not limited to, the implied warranties or conditions of merchantability, fitness for a particular purpose, and non-infringement,
regarding the courses, Rogue Wave Software courses' materials or programs provided, if any.
Under no circumstances is Rogue Wave Software, its officers, directors, employees, program developers or training partners liable for any of the following, even if informed of their possibility:
Some jurisdictions do not allow the exclusion or limitation of direct, incidental, or consequential damages, so some or all of the above limitations or exclusions may not apply to you.