Vous êtes sur la page 1sur 308

1

Published PDF: June 20, 2018


Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals

Zend Server Fundamentals


2
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals

Course Introduction
3
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Course Introduction
Course Content

This module covers:

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:

Install and configure Zend Server


Maintain PHP and its extensions
Deploy and manage applications
Spot potential problem areas within your applications
Perform analysis of problems and run code traces
Optimize your environment via caching and OpCache
Schedule jobs
Use Z-Ray and URL insight features
6
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Course Details
Course Approach

Includes:

A combination of lecture and hands on exercises


Lots of interaction between all participants and instructor
Includes a number of exercises, some of which are accomplished in session, some as homework.
7
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals

Web Conferencing Tool


The course uses Cisco Webex web conferencing and includes:

Zend training recordings


Participant and chat panels

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

Zend Training Recordings


In order to access the recordings, you will need:

A session password. Provided in your participant email package.


Your name.
9
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Web Conferencing Tool
Panels

Examples of the participant and chat panels


10
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals

Course Virtual Machine


The course uses a virtual machine (VM). A virtual machine is a separate operating system running inside a window of your main
computer.

The VM is called a guest, your main computer, a host.

The VM provides a working environment for the student without the need to setup an environment themselves.

The VM installs software necessary to complete the course requirements, including:

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

Applications are located in:

BASEPATH/home/vagrant/Zend/workspaces/DefaultWorkspace.

Application folders are:

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

Thank you for your participation ...

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

Introduction to Zend Server


This module covers:

Zend Server
Zend Server editions
15
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals

Zend Server
About

Zend Server (ZS) is a complete, secured, enterprise-


ready web application server that:

is simple to install, configure and use


has tech support, periodical updates, security hot
fixes
runs on Windows, Linux, IBMi & Mac
helps in problem resolution
16
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Zend Server
Targeted Audience

Architects, IT managers, developers, & system admins who want to maintain a high quality of service for their web sites by:

Boosting application performance and throughput


Maintaining application reliability and security
Improving application management
17
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Zend Server
Key Benefits

Enhances reliability, improves staff productivity

Maintaining dozens of PHP libraries is a huge time drain.


Rapid updates of third party libraries makes it difficult to maintain a reliable and secure environment.

Increases rate of successful deployments

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.

Improves the problem resolution process

Monitoring allows you to swiftly pinpoint issues in development and production.


Powerful tools including Z-Ray Live and Code Tracing reveal exact details of problems.
18
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Zend Server
Deployment Options

Supports application and API frameworks to varied environmental targets.


19
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Zend Server
Performance and Uptime

Comprehensive capabilities include:


20
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Zend Server
Optimized PHP Distribution

Includes:

the latest PHP 5.x and PHP 7.x versions.


a complete, pre-integrated, tested, and certified PHP version.
access to Zend Technical Support, hot fixes, security patches and online software updates.
a large number of the most popular PHP extensions, including Zend Framework, Symfony, and the Zend Server SDK, etc.
a user interface that provides set up tools and application environment optimization.
consistency across operating systems including Linux, Windows, IBMi and Mac
21
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Zend Server
Continuous Delivery

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

Zend Server Editions


Differences

Production

Small Business
Professional
Enterprise
Production Editions Comparison

Developer

Standard
Enterprise
Developer Editions Comparison

Zend Server Plus

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

Zend Server Installation


This module covers:

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

Install Apache or NGINX?

Zend Server supports both versions


To install one or the other, specify the appropriate installation option
27
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Installation Resources
Automatic or Manual Installation

Installation resources for the following platforms:

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

The IBMi Zend Server installation special procedures includes:

Logging into the IBMi as a *SECOFR user, and downloading the installation package.
Creating a SAVF in QGPL under the name ZENDPHP7

CRTSAVF FILE(QGPL/ZENDPHP7) TEXT(Zend Server 9.1 product save file)

Doing an FTP binary transfer to the SAVF ZENDPHP7 in QGPL.


Transferring the saved file to the IBMi withput zendphp7.savf. When the SAVF is loaded into the IBM i QGPL library, return to your
5250 session.
29
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Installation Resources
IBMi

Silent or Interactive Installation Details

Silent

SBMJOB CMD(RSTLICPGM LICPGM(ZENDPHP7) DEV(*SAVF) SAVF(QGPL/ZendPHP7))

Silent Mode Installation Details.

Interactive

RSTLICPGM LICPGM(6ZSVRPI) DEV(*SAVF) SAVF(QGPL/ZSVRSAVF6)

Fill in the requested information and follow the prompts

Interactive Mode Installation Details


30
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals

First Run Expectations

The first time Zend Server runs, a License page is


displayed that looks like this.
31
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
First Run Expectations
Profile Options

The Profile Options displays allowing selection for the


install environment (can be changed later from the
gui):

Development: Used to develop an application.

Production (Single Server): Intended to host a live


application.

Production (Clustered): Contributes to a server


cluster that together host a live application.
32
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
First Run Expectations
User Passwords

A password is required to log in to the main user


interface as different user roles:

Administrator: Full privilege on the server.


Developer: Partial privilege to monitor applications on
the server.

Passwords must be 4-20 characters long


33
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
First Run Expectations
Summary

Summarizes the initial configuration settings.

Zend Server is installed by default with a trial


Enterprise edition license, allowing access to a full
feature set for 30 days.

Upgrade installs use the pre-existing license.

After the trial period ends, Zend Server functionality


ends. Please contact a Zend sales representative to
obtain a full license.
34
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
First Run Expectations
Getting Started

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

Virtual Machine (VM) Installation


Default installation path: /usr/local/zend

Default scripts path: /usr/local/zend/bin

Default server config path: /user/local/zend/etc/php.ini

In a browser, open the Zend Server web interface at:

http://localhost:10081
36
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals

Lab: Zend Server Manual Installation


Setup the Zend Server environment with Apache and PHP using a terminal. Follow each command pressing Enter:

1. Open a terminal window: Ctrl+Alt+T.


2. Access the root user, respond with the password 'vagrant'.

root@server-training:~# su

3. Add the Zend Server repository reference to the end of file:/etc/apt/sources.list

root@server-training:~# echo 'deb http://repos.zend.com/zend-server/<zend server version>/


deb_apache2.4 server non-free' >> /etc/apt/sources.list

4. Add the repository key.

root@server-training:~# wget http://repos.zend.com/zend.key -O- | sudo apt-key add -

...
37
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals

Lab: Zend Server Manual Installation


...

5. Update the repository. This is necessary to tell Ubuntu about the new repository.

root@server-training:~# apt update

6. Install Zend Server:

root@server-training:~# apt install zend-server-php-<PHP version>

7. Access the web interface:

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:

/etc/init.d/zend-server start: Starts the server daemon.


/etc/init.d/zend-server restart: Restarts the server daemon.
/etc/init.d/zend-server stop: Stops the server daemon.
/etc/init.d/zend-server start-apache: Starts the Apache web server, if installed.
/etc/init.d/zend-server start-lighttpd: Starts the Lighttpd web server.
/etc/init.d/zend-server start-nginx: Starts the NGINX web server, if installed.
/etc/init.d/zend-server status: Provides a process run status for a number of the Zend Server processes.
39
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Control Script
Status Output

Output of the /etc/init.d/zend-server status command, looks like this:

root@server-training:~# /etc/init.d/zend-server status

[20.06.2018 14:41:28 SYSTEM] watchdog for monitor is running.


[20.06.2018 14:41:28 SYSTEM] monitor is running.
â—​ apache2.service - LSB: Apache2 web server
Loaded: loaded (/etc/init.d/apache2; bad; vendor preset: enabled)
Drop-In: /lib/systemd/system/apache2.service.d
└─apache2-systemd.conf
Active: active (running) since Wed 2018-06-20 14:28:43 PDT; 12min ago
Docs: man:systemd-sysv-generator(8)
Process: 10104 ExecStop=/etc/init.d/apache2 stop (code=exited, status=0/SUCCESS)
Process: 10230 ExecStart=/etc/init.d/apache2 start (code=exited, status=0/SUCCESS)
CGroup: /system.slice/apache2.service
├─10245 /usr/sbin/apache2 -k start
...
40
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals

Module Summary
This module included:

How to install Zend Server manually or via an automated installer.


How to perform installations on CentOS/RHEL/Fedora, Debian/Ubuntu, Mac OS, Windows, and IBMi.
What to expect when first installing Zend Server.
41
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals

Module 3
Zend Server Setup
42
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals

Zend Server Setup


This module covers:

Zend server components


Logs
Port and services
PHP Extensions
Command line utilities
43
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals

Zend Server Components


Zend Server is comprised of an array of components (or feature set) that facilitate the development process and improve performance

These components can be enabled or disabled as appropriate for the environment we are using

Components are:

Zend Code Tracing Zend Data Cache Zend Debugger


Zend Deployment Zend Java Bridge Zend Job Queue
Zend Monitor Zend OPcache Zend Page Cache
Zend Server Z-Ray Zend Statistics Zend URL Insight
44
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Zend Server Components
Administration | Components
45
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Zend Server Components
PHP | phpinfo()

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:

PHP compilation options and extensions


PHP version
Server information
OS version information
Paths, master and local values of config options
HTTP headers
PHP License
46
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Zend Server Components
Components

Lab: Component Installation & Configuration

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

Lab: Component Installation & Configuration (cont.)

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

To control the user interface's dedicated lighttpd server run:

/usr/local/zend/bin/lighttpdctl.sh stop|start|restart

To set the Administration Interface's password run:

/usr/local/zend/bin/gui_passwd.php

To setup the Java Bridge run:

/usr/local/zend/bin/setup_jb.sh

To control (start/stop) the Java Bridge daemon run:

/usr/local/zend/bin/java_bridge.sh stop|start|restart

The path for IBMi is /usr/local/zendphp7/*


49
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals

Logs
Log Rotation

Prevents unnecessary disk consumption due to bloated log files

To override the native Zend Server log rotation mechanism use the Apache logrotate directive

Login as root or use sudo to do the following:

Create a file /etc/logrotate.d/zendserver


Add the content shown at right to the new file
NOTE: applies to Linux and Mac OSX only

/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

size 5M: file size to rotate


missingok: if the file is not found do not generate an error
rotate 10: keep up to 10 backup files
compress: compress archive log files using gzip
delaycompress: do not compress the newest file created
copytruncate: rotation method - in this case, copy the content to a new file, and truncate the active log
51
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Logs
Log Rotation

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

Ports and Services


Ports and service definition allows for Zend Server customization for:

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:

Component Port Notes


Using DEB or RPM this is user-defined. If Apache installed, default is port 80. To change this setting we must modify it in the Apache configuration file (see
80
Apache below).
443 Secure port for http (i.e. https)
10081 Administration Interface server over HTTP
Lighttpd
10082 Administration Interface server over HTTPS
Java Bridge 10001 The Java Bridge daemon; to change this setting, go to Administration | Components and enable the Extension named "Zend Java Bridge"
54
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Ports and Services
Windows

After installation, Zend Server's components use the following ports on Windows:

Server Port Notes


World Wide Web Publishing Service (w3svc)
IIS 80 Command Line: net [stop|start|restart] w3svc
Using Zend Server UI: My Computer | Manage | Services
Apache2.4-Zend
80 Command Line: <install_path>\Apache2\bin\httpd.exe –k [stop|start|restart] –n Apache2.4-Zend
Apache
Using Zend Server UI: Start | Control Panel | Administrative Tools | Services
443 Secure port for http (i.e. https)
Zend Java Bridge
Java 10001 Command Line: n/a (managed from Windows control panel)
Using Zend Server UI: Start | Control Panel | Administrative Tools | Services
55
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Ports and Services
Mac and IBMi

Mac listens by default to Zend Server web requests on port 10088

IBMi listens by default to Zend Server web requests on port 10090


56
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals

PHP Extensions
Definition

PHP Extensions are sets of instructions that add


functionality to code

The php.ini file contains primary Extensions and


Directives configuration

To see a list of all the *.ini files used by Zend Server,


from the command line: ls -l
/usr/local/zend/etc/conf.d/*.ini
57
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
PHP Extensions
The PHP Extensions UI

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

Extensions display one of three statuses:

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

Examples of common Zend extensions:

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

Directives are common in programming languages

They are the programming code used to convey an instruction to a compiler

Some extensions need directives to change the extension's default behavior

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

Error Handling Examples


61
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
PHP Extensions
Directives

Lab: Monitor Settings for Directives

From PHP | Extensions complete the following:

1. Turn error display OFF


2. Go to this URL: http://blogapp.local/, enter something in the search box, and click the "Search" button, noting the results.
3. Turn error display ON
4. Try another search from http://blogapp.local/, note the results
5. Set display_errors to OFF, saving the change.
6. Enter this URL: http://blogapp.local/ from a new browser tab
7. Enter something in the search box and click the "Search" button, note errors are NOT displayed
8. Turn error display ON again, saving the change
9. Do another search and note errors are displayed
62
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals

Command Line Utilities


Command Line Access

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

Generate a Web API Key: Administration | Web API Keys |


Add Key

Record the key name and hash generated

Double click on the hash, and copy using either right-


click or CTRL+C

In your command use the -N option to identify the key


name and -K option for the key you just generated
64
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Command Line Utilities
Command Line Operation Example

/usr/local/zend/bin/zs-manage extensions-list -N admin \


-K bb4ee9ebac9a0ac338a2308d254344cfa650efb8d88a73a2475910d8ae19a16a
name status restartRequired installed
apache Off false false
apache2handler Loaded false false
apc Off false false
//******** some lines omitted ********//
Core Loaded false false
cpdf Off false false
crack Off false false
ctype Loaded false true
curl Loaded false true
cvsclient Off false false
Data Handling Off false false
etc.
65
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Command Line Utilities
Lab: Zend Server Command Line

Generate a new web API key

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

Can be used for packaging PHP application(s) for deployment


Makes integration with 3rd party tools easy, and does not require programming knowledge
Works on Mac or Linux
Can perform Web API operations using command line or automated scripts

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

The list of available commands can be viewed by running the command:

/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:

/usr/local/zend/bin/zs-client.sh getSystemInfo --help

Sample request (Adding a new server to the cluster):

zs-client.sh cluster-add-server -N kika -K 012345678901..3 \


-n deb62 -u http://10.1.9.24:10081/ZendServer -p 1234
68
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Command Line Utilities>CLI Tool
Help Output

Help output from the command line:

ZendServerWebApi Client version 1.2


Zend Server Client v1.0
-------------------------------------------------------------------------------
ZendServerWebApi
-------------------------------------------------------------------------------
The following group of command are available:
command:configuration Configuration
command:server Server
command:codetracing Codetracing
command:deployment Deployment
command:monitor Monitor
//***** some output removed to conserve space *****//
command:manual Manual
command:all For all available commands
Below is an example how to get the list of commands in a group
Example: /usr/local/zend/var/libraries/ZendServerSDK/1.1.1a/library/
zs-client.phar command:manual
If you want to see all commands in all groups type:
/usr/local/zend/var/libraries/ZendServerSDK/1.1.1a/library/
zs-client.phar command:all
69
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Command Line Utilities>CLI Tool
Lab: zs-client

Find one of the Web API Keys generated in the last exercise

Issue a console line command to obtain server information in JSON format

To get help on using the command:

/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:

View and manage Zend Server components


Get Information on the Server
Configure Log Rotation
View ports and services
Manage PHP and its extensions
Use different command line utilities such as zs-manage and zs-client
71
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals

Module 4
Virtual Hosts / Zend Deployment
72
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals

Virtual Hosts / Zend Deployment


This module covers:

Virtual Host Management


Managing Applications
Zend deployment
73
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals

Virtual Host Management


Zend Server allows virtual host creation and management for Apache and nginx web servers.

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

SSL-enabled virtual hosts are available

Editing the virtual host template defines the virtual web server's configuration

Proceed with extreme caution as you can alter security settings


75
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Virtual Host Management
Properties
76
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Virtual Host Management
SSL
77
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Virtual Host Management
Template
78
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Virtual Host Management
Server Restart

When returned to the virtual host listing, the status is Pending

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

Host Port Path


blogapp.local 80 BASEPATH/blogapp/public
jobs.local 80 BASEPATH/jobs
sandbox.local 80 BASEPATH/sandbox/public
wikiapp.local 80 BASEPATH/wikiapp/public
wikiapp.cache 80 BASEPATH/wikiapp_cache/public
wikiapp.monitor 80 BASEPATH/wikiapp_monitor/public
BASEPATH/api
api.test 8888
NOTE: you need to add a directive Listen 8888 before <VirtualHost *:${port}>

Define BASEPATH/wikiapp_monitor as a managed application


80
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Virtual Host Management
Lab: Setting Up Virtual Hosts (cont.)

Virtual Host Name: wikiapp.monitor


Listen on Port: 80
SSL Configuration: This host does not use SSL
Configuration Template: Edit the virtual host configuration template (see next slide). Replace "${docroot}" with the appropriate directory for this app. Finish
and restart Zend Server
81
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Virtual Host Management
Lab: Setting Up Virtual Hosts (cont.)

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>

Do the same for the other vhost definitions


82
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals

Managed Applications

You can add any existing application to the overall


Application Management by selecting
Applications | Manage Apps | Define Application

Enter application details including URL, name,


version, file to use for health check, and even a logo
image

The new application appears on the list, and can now


be monitored
83
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Managed Applications
List View
84
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals

Zend Deployment
Available for Zend Server running on Apache or Nginx, either stand-alone or in a cluster. IIS is not supported.

Zend Deployment provides deployment tools to:

Prepare a deployment package


Deploy a new application on the server to a new base URL
Redeploy the same application (using the same package) after a failed deployment occurs.
Update an existing application, using the same base URL, using a new package
Rollback the current version to a version previously deployed
Remove an application from the server
85
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Zend Deployment
Application Deployment Policy

You can configure Zend Server for either Hot Deployment or Cold Deployment

Hot Deployment: Requires server restart. Any users


still using the previous version when the deployment
takes place are not "switched" over to the new
version. New users will be directed to the new
version.

Cold Deployment: Requires a full server restart. Any


user sessions will be abruptly ended. The advantage,
however, is that if there is a major version change, a
"clean break" is ensured.
86
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Zend Deployment
Deploy on to Zend Server

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

Dialog includes the following:

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 need to confirm the EULA (license agreement, if any)

If dependencies are specified, a validation screen will display

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

Deploy the demo package

The demo package is located here:

/usr/local/zend/gui/data/demo.zpk

Do not set up a virtual host: use default server

Enter demo for the path

Note the URL which will be used to access the app


89
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Zend Deployment
Preparing a Custom Deployment Package

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:

Skeleton files created include the "data" and "scripts"


directories underneath the application's root directory

The data directory contains static files like the logo of


the application or the license file

The scripts directory contains PHP scripts designed to


run deployment commands at various points in the
deployment process (hooks)
91
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Zend Deployment
Creating the Deployment Package

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:

zs-client.sh packZpk --folder=<path-to-source> --destination=<zpk-file-folder>

Here are some other options:

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

Allows you to customize the actions according to your needs

Zend Server deployment consists of five phases:

# 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

Here is a partial list available to deployment hook scripts:

ZS_APPLICATION_BASE_DIR: Directory to which the application is deployed


ZS_PHP_VERSION: PHP version used by Zend Server
ZS_WEBSERVER_TYPE: Code representing the web server type (i.e.APACHE)
ZS_BASE_URL: Contains the base URL set for deployment

For a complete list see: http://files.zend.com/help/Zend-


Server/content/understanding_the_application_package_structure.htm#Hook_Script_Constants
96
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Zend Deployment
Deployment XML File

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:

Tag Required Notes


name yes Application's name
summary no Application's short description
description no Application's long description
version yes Application's version #
eula no Path to the EULA text file
appdir yes Applications directory; by default, this is the package data folder
docroot no Alias will point to the specified directory
97
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Zend Deployment
Deployment XML File Example

<?xml version="1.0" encoding="utf-8"?>


<package version="2.0" xmlns="http://www.zend.com/server/deployment-descriptor/1.0">
<type>application</type>
<name>sampleApp</name>
<version><release>1.0</release></version>
<appdir>data</appdir>
<docroot>data</docroot>
<dependencies>
<required>
<php><min>7.0</min></php>
<extension><name>pdo_mysql</name></extension>
</required>
</dependencies>
</package>
98
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Zend Deployment
Deployment XML File:
Non-Required Tags

Tags and notes:

scriptsdir: Directory in which the hook scripts are located


healthcheck: Add the relative URL for Zend Server to check against (looks for 200 response or error)
dependencies: Dependencies that must be met (and will be validated) during the deployment process
parameters: Parameters for deployment process
variables: Define environment variables for the deployment scripts
persistent resources: Any files or directories to remain on the server after removing or upgrading the application
99
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Zend Deployment
Deployment XML File: Dependencies

Describe requirements for:

PHP versions (minimum or maximum) that must be present


PHP modules must be present during the deployment
PHP libraries and versions that must be present
PHP directives and allowed values
Zend Server modules and versions that must be present

If dependencies are not met, the application will not be deployed.


100
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Zend Deployment
Deployment XML File: Parameters

Gives you the ability to enter information available for


use in deployment scripts

Parameters in deployment scripts appear as


constants in this form: ZS_<PARAM_ID>

Parameters can be text, numbers, passwords, email


addresses, or a drop down list

Any parameters defined will cause an extra dialog box


to appear during deployment
101
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Zend Deployment
Deployment XML File: Parameters Example

<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

Other deployment tasks include:

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

Application configuration files are located in the following locations:

/usr/local/zend/etc/sites.d
/usr/local/zend/etc/sites.d/http/__default__<vhost name>

Application Data on Linux:

/usr/local/zend/var/apps/http/__default__<vhost name>/0/<application name>/<version>

Application Data on Windows:

C:\Program Files\Zend\ZendServer\var\data\http\__default__<vhost name> \\


\0\<application name>/<version>

Application Data on IBMi:

/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

Zend Server installation inserts an include in two places:

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

Each virtual host is defined in:

/usr/local/zend/etc/sites.d/vhost_<host>_<port>.conf

Each virtual host definition includes aliases from the directory:

/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

Deployment package parameters include:

Application Name: WikiApp


Release Version: 0.0.1
Minimum PHP Version: 7.1
Document Root: public
107
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals

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:

Deep and live insight into their code


The ability to identify, debug and optimize issues early on in the development cycle
Information tracked and displayed by Z-Ray includes:
Page requests
Time and memory consumption
PHP functions
SQL queries
Errors and warnings, exceptions
Zend Server monitoring events
Application-specific info using plugins
Z-Ray Live! can track non-browser based requests (API, mobile, CLI)
111
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Z-Ray
Live Toolbar
112
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Z-Ray
Page Requests

Displays a list of all the requests sent by the page to the web server, included sub-requests e.g. AJAX calls.

Includes execution time, URL and HTTP response code.

Includes number of SQL queries, if any.


113
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Z-Ray
Execution Time and Memory Peak

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.

* available defined PHP process memory.


114
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Z-Ray
Monitor Events

Displays monitored events triggered during the URL request currently selected and displayed in the Page Requests panel.

When minimized, Z-Ray displays the number of triggered events.


115
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Z-Ray
Error and Warnings

Displays errors and exceptions triggered by the URL request currently selected and displayed in the Page Requests panel.

When minimized, Z-Ray displays the number of triggered errors.


116
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Z-Ray
Database Queries

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.).

When minimized, Z-Ray displays the number of PHP functions called.


118
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Z-Ray
Request Info

Displays variables used in the URL request currently selected and displayed in the Page Requests panel.

Highlights the changed variables or new entries during the request.

Displays detailed information on the request and the response.


119
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals

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).

Can easily deploy new plugins from the Gallery.


120
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Z-Ray Plugins
Z-Ray Enable / Disable

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.

Can also be disabled using any of the following:

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

Allows secured access to Z-Ray for specific IPs and


URLs, and for a specific time duration. In production,
perfect for remote debugging of client requests. To
enable Selective Mode:

Go to Z-Ray | Access Mode


Select Selective, save and restart Zend Server.
Select the Selective Access tab, and at the top of the
Access Tokens list, click the Allow Selective Access
button
Follow the wizard, as shown on the next screen shot
123
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Z-Ray Modes
Selective Mode: Configuration

Name the access configuration.

Select whether to require an access token or not.

Set the expiration period.

Set the IP restriction.

Set the URL restriction.

Check box to display in browser, otherwise will only


be in Z-Ray Live!

Note: Step 4 - 6 not shown.


124
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Z-Ray Modes
Selective Mode: Security
125
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Z-Ray Modes
Selective Mode: Actions
126
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Z-Ray Modes
Selective Access Token

Selective access can also include an access token.

Once created, we are supplied with a URL.

The URL can be given to the person who wants to use Z-Ray.

It only needs to be opened once in the browser.


127
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals

Lab: Z-Ray Selective Mode

Modify the VM network from NAT to Bridged:

1. Right click on the network icon (bottom right of VM


window)
2. Click Network Settings
3. Change network adapter from NAT to Bridged
4. Restart the VM to make the changes effective
128
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals

Lab: Z-Ray Selective Mode: 2


Open a terminal window on your VM.

Type this command to find out your IP address:

ifconfig

Configure selective access for this IP address.


129
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals

Lab: Z-Ray Selective Mode


Complete the following:

1. Open the Zend Server UI in the browserhttp://localhost:10081/ZendServer


2. Login as admin user with the password already specified for this user.
3. In the Zend Server UI, go to the Z-Ray | Access Mode page.
4. In the Mode tab (displayed by default when opening the page), select Selective.
5. Click Save and Restart Zend Server.
6. Select the Z-Ray | Access Mode | Selective Access tab.
7. At the top of the Access Tokens list, clickAllow Selective Access button.
8. The Allow Selective Access dialog is displayed.
9. Configure selective access for the IP address of your VM.
130
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals

Z-Ray Settings
Zend Server Menu Configuration

Configure Z-Ray from the Zend Server UI at: Z-Ray | Settings.

Settings and notes:

Data Collection: configure how Z-Ray collects and


stores data
Privacy: configure how Z-Ray hides sensitive data
using masking of key attributes
Advanced: various other settings including: iFrame
behavior, keyboard shortcuts and function groups for
filtering
131
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals

Z-Ray History

New feature added in Zend Server 9

Search by last day, week or month + custom time


ranges.

Filter by HTTP methods:

GET
POST
CLI

Filter by HTTP status codes:

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

Complete the following:

1. Click on the "Open" icon under "Action"


2. Opens a new Z-Ray window.
3. Click options on bottom bar for more information on this event.
133
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Z-Ray History
Lab: History | Actions | Open (cont.)

Results:
134
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals

Z-Ray Command Line


A PHP CLI Request Example:

// 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

Z-Ray Mobile Access


Definition

Z-Ray is accessible from a mobile device.

Following is a lab that does just that.


136
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Z-Ray Mobile Access
Lab: Mobile Access

Note the IP address ( ip.address.from.lab1) discovered after running ifconfig

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.

Note the IP address ( ip.address.from.lab1) discovered in M5Ex1 after running ifconfig

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

5. Open the Zend Server UI in the browserhttp://localhost:10081/ZendServer


6. Login as admin user with the password already specified for this user.
137
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Z-Ray Mobile Access
Lab: Mobile Access (cont.)

7. In the Zend Server UI, go toDashboard | Mobile Usage


8. Make a note of the number of mobile requests.
9. Next, select Z-Ray | Live!
10. Enter http://ip.address.from.lab1/demo from the mobile device.
11. Note any details on the request.
138
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals

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

Most problem resolution time is spent on identifying


root cause. Problem reproduction is often difficult and
time-consuming.

There are too many possible sources:

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

Zend Server monitors PHP applications for:

Slow functions or request executions


PHP Errors, failing functions or queries
High memory consumption
Custom events, which define what we are interested in seeing

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

The dashboard includes application and system


monitoring metrics.

Information displayed is divided into three categories:

Installed / defined applications.


Application statistics.
Latest events.
144
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Dashboard
Overview

Actual live screenshots from http://zend.com/


145
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Dashboard
System Health
146
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Dashboard
System Utilization
147
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Dashboard
Usage Statistics
148
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Dashboard
Mobile Usage
149
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Dashboard
Mobile Statistics
150
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals

Monitoring
Events

Definition

An event indicates something has happened in the


environment that exceeds the definitions and
standards set for how the PHP code should run.

Three major functions from this page:

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

Issues vs. 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:

Stored Filters: Errors, performance or resources issues


Time Range: Show events that first happened before, after, or between a set of dates
Search: Free text filter that scans across most stored information for an event (ex: id, URL, source file)
Severity: Filter to display Severe, Warning or Notice events
Event Type / Rule Name: Function performance, high memory, PHP errors, etc.
Application: Show events that occurred on the selected deployed app from the drop-down list
153
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Monitoring
Events Filtering

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

Access by clicking on the More Details link in an expanded event.

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

Grouping is an additional aggregation layer applied to an issue.

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

Here are the 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:

Central management area to define the


conditions for generating Zend Server events
Monitoring runs "out-of-the-box" upon Zend
Server installation
The global pre-defined rules should be
modified to fit the application environment
Application specific rules can be defined for
deployed applications and/or defined URLs
161
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Monitoring
Editing Event Global Rule
162
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Monitoring
Event Email Address

Details:

Events can also send an email.


A specific email address can be set per event rule.
Select Monitoring | Event Rules | specific rule
163
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Monitoring
Event Email Address

An email address can also be set for all


events.

Select Monitoring | Settings | Triggered


Action Settings
164
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Monitoring
Administration | Mail Server Settings

Overall mail server settings affect how


emails are sent.

These can be found in the


Administration | Settings tab.
165
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Monitoring
Logs

Definition

Logs provide critical insight into errors and unwanted application behavior within the system environment.

Log info can be viewed directly from the Administration Interface.

Possible to switch between nodes of a clustered environment.

Additional logs can be added to the page by updating the DB.

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

Information available is partially related to the web server.

Apache:
PHP Error Log *
Zend Server error logs
Apache Error & Access Logs
Windows IIS:
PHP Error Log *
Zend Server error logs

* (references the error_log directive)


167
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Monitoring
Logs

PHP
168
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Monitoring
Logs Other

Environment-specific logs are added in the Monitoring | Logs page.

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.

For safety: make a backup of /usr/local/zend/var/db/gui.db and restore it in case of


errors.

NOTE: the path is /usr/local/zendphp7/var/db for the database on the IBMi


169
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Monitoring
Lab: Add a New Log

1. From a terminal, execute the c mand:

sudo sqlite3 /usr/local/zend/var/db/gui.db

2. At the sqlite> prompt, note the highest ID from the table after entering this SQL statement:

SELECT * FROM Zend Server UI_AVAILABLE_LOGS;

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

5. Name the log Wikiapp Monitor Log

INSERT INTO Zend Server UI_AVAILABLE_LOGS


VALUES (<ID>, "<log_description>", "<path_to_log_file>", NULL, 1);
170
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Monitoring
URL Insight

Definition

Displays detailed reports on critical page requests,


examples include:

Most time consuming URLs


Most frequently visited URLs
Requests with the slowest response time
171
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Monitoring
Settings

Events

The Events tab allows you to:

enable / disable monitoring


aggregate events by route, URL, or not at all
enable / disable code tracing for events
define cleanup settings
define email and callback URLs for triggered actions
172
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Monitoring
Settings

URL Insight

(cont.)

enable / disable URL insight


enable / disable Z-Ray snapshots
define Z-Ray snapshot intervals
173
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Monitoring
Events Labs

The instructor will first demonstrate and guide you through two types of events, for which there are already set rules:

Slow Request Execution


Function Error
Analyze these on your own as an exercise:
PHP Error
High Memory Usage
Custom Event

Base URL for exercises: http://wikiapp.monitor/

File system root for exercises: /home/vagrant/Zend/workspaces/DefaultWorkspace/wikiapp_monitor


174
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Monitoring
Lab: Slow Request Execution

This event is generated when script execution time


exceeds defined limits. These are used to maintain
script runtime performance standards

Open a browser to http://wikiapp.monitor/


175
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Monitoring
Lab: Monitoring Function Errors

This rule contains a list of monitored functions. These


monitored functions when returning FALSE will trigger
this event.

1. Add the function MyWiki_Model_Users::loginUser


(remember to click the Add Function button). What
happens?
2. Open a browser to http://wikiapp.monitor/login
176
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Monitoring
Lab: Monitoring PHP Errors

When a specific PHP error is reported, it generates


this event. This Rule contains a list of monitored PHP
error types.

1. Click on Edit under the Warning section and check


E_NOTICE.
2. Restart Zend Server if Notices not showing up
3. Open a browser to http://wikiapp.monitor/. Why is this
appropriate for the Wiki application?
177
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Monitoring
Lab: Monitoring Events High Memory Usage

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.

Files should be cached when their content is relatively static.

Not recommended for files whose output changes on every request.

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.

Handles caching in shared memory or on disk.

Supports putting cached items into namespaces for easier management.


184
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Page Caching
Page Cache Rules

Central configuration area for rules to cache content


by URL.

Application-specific rules can be made as additions to


(or instead of) any global rules.
185
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Page Caching
Lab: Apache Bench Test

Using Apache Bench we can see the difference page caching can play.

1. Install Apache Bench as follows:

sudo apt-get install apache2-utils

2. Using Apache Bench, execute the following command in the terminal:

ab -t 10 http://wikiapp.cache/article/view/title/Greek+shipping

3. View the results and take note.


186
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Page Caching
Lab: Create a Caching Rule

In the "Caching" menu:

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

4. Compare the difference with the previous result


187
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals

Data Caching
Definition

The Data Cache API is used by inserting its functions into the PHP code.

The API caches partial PHP outputs using Memory or Disk.

It features:

Storing variables to the cache


Fetching variables from the cache
Deleting variables from the cache
Clearing the cache
Disk/Memory (SHM) storage
Caching using namespaces
Cache folder depth configuration
188
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Data Caching
Disk vs. Shared-Memory

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.

Options available on where to store cached variables.

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.

if (zend_disk_cache_store("hello1", 1) === false){


echo "error2\n"; exit();
}

Shared memory:

if (zend_shm_cache_store("hello1", 1) === false){


echo "error2\n"; exit();
}

Store with namespace on disk:

if (zend_disk_cache_store("ns1::hello1", 1) === false){


echo "error2\n"; exit();
}
190
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Data Caching
SHM/Disk Storage Implementation (cont.)

Shared memory:

if (zend_shm_cache_store("ns1::hello1", 1) === false){


echo "error2\n"; exit();
}

Store with namespace on disk with limited lifetime (3):

if (zend_disk_cache_store("ns3::test_ttl", 2, 3) === false){


echo "error12\n"; exit();
}

Shared memory:

if (zend_shm_cache_store("ns3::test_ttl", 2, 3) === false){


echo "error12\n"; exit();
}
191
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Data Caching
Namespace Support

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.

The namespace is used only to clear selected items.

To clear the entire cache, use zend_shm_cache_clear or zend_disk_cache_clear


192
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Data Caching
Namespace Support (cont.)

Set the cache namespace by adding it as a prefix to the cache with ' :: ' as a separator.

zend_disk_cache_store("my_namespace::my_key",$data) is fetched with zend_disk_cache_fetch("my_namespace::my_key");

zend_shm_cache_clear("my_namespace") clears keys starting with "my_namespace::"


193
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Data Caching
Folder Depth Configuration

Defining the Cache folder depth is intended for environments that use a large number of keys.

This option is available only with Disk Caching.

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.)

Cache folder depth is defined by directive: zend_datacache.disk.dir_level

The accepted values represent the levels that the cached files are stored.

0: One directory containing all the Cache files


1: A separate directory under the Cache directory
2: An additional sub-directory for cached content under the cache directory
195
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Data Caching
Lab: Cache Clear by Namespace

Why does the program clear all the namespace items?

public function insertListing($article){


$title = $article['title'];
$content = $article['content'];
$data = ['title'=>$title, 'content'=>$content, 'modified'=>time()];
try{
MyWiki_Data::getAdapter()->insert('listings', $data);
$lastEntryId = MyWiki_Data::getAdapter()->lastInsertId();
if(function_exists('zend_disk_cache_clear'))zend_disk_cache_clear('listing');
} catch(Exception $e){
MyWiki_logger::getInstance()->writeLog($e->getMessage());
}
return $lastEntryId;
}
196
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals

OPCache
Definition

OPCache allows a performance boost by reducing code compilation time.

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

What is the fundamental difference between these two methods?

OPCache saves the ??? in server memory.

Caching saves the ??? in server memory.


198
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
OPCache
Resource Allocation

Increasing resource allocations may solve issues with large files.

OPCache settings can be changed to increase:

1. allocated memory and


2. the maximum quantity of files

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.

Recommended files for Blacklisting:

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 ?)

1. Issue the following command, taking note of the request count:

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 and Code Tracing


This module covers:

Debugging
Debug Sessions
Debug Tunneling
Code Tracing
205
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals

Debugging

Zend Server can be configured for debugging using


either Zend Debugger or Xdebug

Debuggers can be selected, configured or entirely


disabled from the Zend Server UI

The Debugger feature enables PHP code analysis


(debugging and profiling) and code repair on remote
servers
206
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Debugging
Considerations

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

An IDE sends a request (with Debugger enabled) on


port 80 (HTTP) or port 443 (HTTPS), containing
special values in the query string to trigger a debug
session.

ZS receives the request, interprets the query string


parameters, and starts a debugging session. It will try
connecting to the IDE on the IP address sent by the
client over port 10137 (by default).
208
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Debugging
Debugging Flow Diagram (cont.)

The IDE receives debug information through the


debug connection and the server executes the script.

Debug Response Timeout - The Debugger's timeout


period in milliseconds for waiting for a response from
ZS.

Broadcast Port - The Broadcast Port (set in the IDE)


allows the Z-Ray Toolbar or ZS to detect the IDE
debugging preferences. The IDE Broadcast Port
number entered here must match.
209
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Debugging
Zend Debugger

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.

To define allowed hosts for debugging:

1. In the UI, go to Debugging | Debugger .


2. Enter a single valid IP address or range of Ips.
3. From the drop-down list, select an option according to the type of IP address (Exact for a single IP; other options for a range of hosts).
4. Click + Add to add the Host.
5. Click Save and Restart to restart Zend Server to apply changes.
210
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Debugging
Setup

To use the debugger the Zend Debugger component


must be enabled.

From the Zend Server UI go to


Adminstration | Components

Click Enable if not already done


211
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Debugging
Setup (cont.)

Next, from the UI select Debugging | Debugger

Choose either Zend Debugger or Xdebug as


appropriate
212
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Debugging
Setup (cont.)

From the Debugging | Debugger dialog, you can configure debugger security

Allow from all: Any computer can access the debugger


Allowed hosts: Whitelist of computers which can access the debugger
Denied hosts: Blacklist of computers which cannot access the debugger
213
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Debugging
Setup (cont.): IDE Settings

Finally, still in the Debugging | Debugger dialog, you


can configure how the Zend Server debugger
interacts with your IDE (Integrated Development
Environment

When finished with the Debugger configuration, click


Save and Restart Zend Server
214
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Debugging
Lab: Configure Zend Server for Debugging

1. Enable the debug component if not already done


2. Configure the server for Zend Debugger
3. Locate the external IP address assigned to your VM

ifconfig

4. Add the above IP address as an "allowed" host


215
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals

Debug Sessions
Launching a Debug Session

A debugging session can be launched in any of the


following ways:

Directly from within an IDE


From a browser using the Zend Debugger Toolbar
From Z-Ray

Your IDE will then display the appropriate debugging


page
216
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Debug Sessions
Debugging from Z-Ray

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

Installing the Toolbar

The Zend Debugger Toolbar is available for most


major browsers.

To install the toolbar, use your browser's normal


procedure for installing an extension or add-on.
218
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Debug Sessions
Debugging from Toolbar (cont.)

Once you have the Zend Debugger Toolbar installed,


browse to the offending web page

Click on the toolbar icon to initiate the debugging session


219
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Debug Sessions
Lab: Launch a Debugging Session

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

Each server can have its own tunneling configuration

Provides a secure debugging channel behind a


firewall, NAT (Network Address Translation), or
private network

IDEs provides their own private listener. which


responds to server debugging info coming in over the
tunnel
221
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals

Code Tracing
Definition

Records live code execution in production

Can be activated automatically through event monitoring rules, or manually for


specific URLs

Can browse a recorded code execution trace to quickly pinpoint root cause of
functional and performance problems

Reduces time to resolution by ~ 50%

If the Profile Data trace is selected, is generated faster and gives a more readable
view

Also referred to as "Code Trace Lite"


222
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Code Tracing
Code Trace Access

Access a Code Trace in one of two ways:

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

This module covers job queues


229
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals

Job Queues
Definition

Job Queue allows for asynchronous execution of PHP scripts (jobs)

Streamlines offline processing and improves application performance

Examples:

Run a time-consuming report generation script on a different server, or at night


Index a site for the Search feature
Send emails for new posts
Update RSS feeds
Specify times for the execution of scripts (ex: periodic database cleanup)
230
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Job Queues
Example
231
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Job Queues
In a Cluster

Web Servers: Servers in the cluster running Zend


Job Queue

Job Queue Extensions: Pass the jobs to the Job


Queue Daemons

Job Queue Daemons: Manage scheduling, queing


and executing tasks

MySQL: Stores the jobs created throughout the


cluster
232
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Job Queues
Job Queue Pulse

Use Job Queue | Pulse to get a quick overview of the


status of jobs in the queue

You can filter by application, queue or time period

The Refresh setting allows you to control how often


this page is updated
233
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Job Queues
Job Management

Under the Job Queue tab:

Jobs: List and manage jobs


Recurring Jobs: List and manage jobs which are repeated
Queues: A group of jobs grouped together to ensure easier and more efficient management and prioritization
Settings: General: job output, load and maintenance
Events: job execution delay, error and logical error configuration
234
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Job Queues
Jobs
235
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Job Queues
Add / Modify Queue

From the Zend Server UI select Job Queue | Queues

To create a new queue click Add Queue

To modify an existing queue, select the desired queue

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

Recurring jobs are PHP programs running on a


certain URL

These jobs can be scheduled to run hourly, daily,


weekly or monthly

Alternatively, you can select every NN number of


days, hours or minutes
237
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Job Queues
Settings

Settings are broken down into General and Events categories

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

Create a job queue called Test

Configure the following settings for the new queue:

Queue Name Test Connection Timeout 30


Priority High Job Timeout 120
Max Concurrent Jobs 20 Job Retry Count 10
Max Job Wait Time 1 Job Retry Timeout 5
239
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Job Queues
Lab: Add a Recurring Job

Add a recurring job as follows:

Name Access Scan


URL http://jobs.local/scan_access_logs.php
Queue Test
Priority High
Execute Job Every 5 minutes
240
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Job Queues
Lab: Add a Recurring Job (cont.)

1. Configure "other" read permissions for BASEPATH/logs/*access*


2. Configure read/write permissions for the user www-data in BASEPATH/jobs/scan_access_logs.html
3. Access the server demo app using the actual IP address (typically 192.168.some.thing): i.e. http://192.168.3.22/demo
4. Back to the Zend Server Zend Server UI: execute the job immediately
5. Review the success in Job Queue | Pulse
6. View output: http://jobs.local/scan_access_logs.html
241
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Job Queues
Lab: Job Queue API

1. In wikiapp/application/models/Articles.php comment out the line below. This will disable the default behavior of sending out an inline email.

return $this->sendEmail($mailParams['from'], $mailParams['to'], $mailParams['title'], $mailParams['realName'], $mailParams['log']);

2. Uncomment these lines:

$jobQueue = new ZendJobQueue();


$jobId = $jobQueue->createHttpJob($notificationUrl, $mailParams);

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 (JB)


Installations
Linux Installation
Testing the Connection
246
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals

Java Bridge
Definition

Allows you to instantiate new Java classes inside a


PHP script

The Java Bridge executes the script and returns the


results to the Zend Engine.

Offers significant performance and scalability


advantages over equivalent solutions

Memory consumption is constant, regardless of the


number of PHP sessions
247
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Java Bridge
Before We Start

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:

// If a Java method is called that looks like this:


public void doSomething(int i);
// Use what we would expect to work in PHP:
$var = "1";
$javaObject->doSomething($var);
// The Java Bridge throws an exception... To avoid this, use the
// following line of code to convert the parameter from a string
// to a numeric value before the Java Bridge passes it:
$javaObject->doSomething($var + 0);
248
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals

Installations
Windows Installation

Download and install the latest Java Runtime


Environment (JRE) above

Run Zend Server installer in Modify mode:

Control Panel | Add/Remove programs | Zend Server


| Change

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)

From command line issue the following command:

sudo apt-get install php-<php version>-java-bridge-zend-server

Restart Zend Server via the gui

You are now ready to use Java Bridge


251
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Installations
Installation Confirmation

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

Type conversion must be done in the PHP code


253
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Installations
PHP Test Script

Create a new PHP script to create a Java object

<?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";
?>

See: /path/to/source/wikiapp/application/controller/JavaController.php or /path/to/source/wikiapp/application/models/java.php


254
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Installations
Test Output

If the Java Bridge is correctly installed and running, we should receive the following output from the test code:

Friday, June 13, 2017 at 8:45:57 PM U.S Daylight Time


class java.lang.System Java version=1.6.0_06 Java vendor=Sun Microsystems Inc.
OS= inux 2.6.25.3-18.fc9.i686 on i386

If an error message is generated, check to see if Java Bridge is installed

Check Configurations | Components see if Java Bridge Extensions are not running or the Bridge Server needs to be restarted

Also, make sure the requested file is in the environment's classpath


255
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Installations
Lab: Java Bridge Installation

1. Open a terminal window and determine if a JRE (Java Runtime Environment) has been installed

java -version

2. If not, install the default JRE:

sudo apt-get install default-jre

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

The BASEPATH for this lab is /home/vagrant/Zend/workspaces/DefaultWorkspace

1. Add to the include path BASEPATH/sandbox/public/java/demo.jar


2. In the /usr/local/zend/etc/watchdog-jb.ini file edit the zend_wd.env.java_daemon directive
3. Add the path BASEPATH/sandbox/public/java/demo.jar followed by the path separator colon (":")
4. Restart 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.

Zend Server UI Plugins


Enhance Zend Server administrative functionality
262
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals

Installation and configuration


Zend Gallery

The Plugin Gallery is a marketplace for Zend Server


plugins developed for, and by, Zend Server users.
This allows us to browse for available plugins and
decide which functionality we may wish to add to
Zend Server.

Contains all the information we need on the available


plugins, including descriptions, downloads stats,
screen shots, videos, package details, licensing
information and a change log.
263
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals

Installation and configuration


Lab: Install a plugin

Browse to the Gallery and install one of the available plugins.


264
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals

Deploying
Plugins

Deployment from Gallery

1. From the Zend Server UI select Plugins | Gallery


2. Choose the desired plugin
3. Click on Install

Deployment from Manage Plugins

1. From the Zend Server UI select Plugins | Manage


Plugins
2. Click on Deploy Plugin
3. Choose the desired plugin
4. Click on Install
265
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals

Plugin Management
From the ZS UI:

Plugins | Manage Plugins

Available plugin update notification is automatically


visible in the Zend Server UI

New plugins can be deployed via the Gallery or


manually via the Manage Plugins page

Extension API for developing new plugins and


documentation available on GitHub
266
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals

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

Zend Server Web API


This module covers:

Zend server web API


Requests and responses
API versioning
Server and Cluster Methods
269
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals

Zend Server Web API


The Zend Server Web API allows:

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

Adding/removing server nodes from a Zend Server Cluster


Deployment of new version of an application
Integration with other Zend or third party software
Integration with IDEs
Integration with cloud service providers like Amazon or Right Scale
270
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Zend Server Web API
Overview

Zend Server's Web API includes:

Generating API keys


Generic Requests
Authentication and Message Verification
Generic Response Format
API Versioning
Available API Methods
CLI Tools
271
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals

Requests and Responses


Generic Request

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.

Request URL is different for each action, as follows:

http://localhost:10081/ZendServer/Api/<ACTION >

where <ACTION> is the action to perform (ex: disableServer )

Secure HTTP requests can be made using:

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:

X-Zend-Signature: <key name> ; <signature>

where <key name> is replaced with the key name, and <signature> is replaced with calculated request signature

64-digit hexadecimal number with digits a-f in lower case


274
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Requests and Responses
Calculating a 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

Exact value of the User-Agent request header

Exact value of the Date request header

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

Passing parameters to API methods varies by request type:

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

GET /ZendServer/Api/getPizzaStatus?pizzaId=53 HTTP/1.1


Host: zscm.local|
Date: Sun, 11 Jul 2010 13:16:10 GMT
User-agent: Zend_Http_Client/1.10
Accept: application/vnd.zend.serverapi+xml;version=1.0
X-Zend-Signature: bob.at.example.com;
02dcbf4cb338a0a8b807c83a84a7888929f5c06491105d6752f290da47a24619
277
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Requests and Responses
POST Request Example

This sample request is for the makePizza() method, with the following parameters: style, extraCheese, extras

POST /ZendServer/Api/makePizza HTTP/1.1


Host: zscm.local
Date: Sun, 11 Jul 2010 13:16:10 GMT
User-agent: Zend_Http_Client/1.10
Accept: application/vnd.zend.serverapi+xml;version=1.0
X-Zend-Signature: bob.at.example.com;
7f0db29a3d82a81ec6f5387f5aae96e295530b4c8acf2074488185902dc900f4
Content-type: application/x-www-form-urlencoded
Content-length: 100
Style=thinCrust&extraCheese=TRUE&extras%5B0%5D=pepperoni&extras%5B1%5D=onion&
extras%5B2%5D=pineapple
278
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Requests and Responses
Generic Response Format

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:

200 OK The operation has completed successfully


202 Accepted The operation was accepted and is being processed, but is not yet complete
4xx HTTP status codes between 400 - 499 are used to designate a client-side error (Ex: a missing request parameter or an authentication error)
5xx HTTP status codes between 500 and 599 are used to designate a server-side error (ex: a temporary locking issue or an unexpected error in the server operation)
279
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Requests and Responses
Response Body Format

The Web API HTTP response body will almost always contain an XML document of the following format:

<?xml version="1.0 encoding="UTF-8"?>


<zendServerAPIResponse xmlns="http://www.zend.com/server/api/1.0">
<requestData>
<apiKeyName>angel.eyes</apiKeyName>
<method>clusterGetServerStatus</method>
</requestData>
<responseData>
[response data here ...]
</responseData>
</zendServerAPIResponse>
280
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Requests and Responses
Error Response Body

In a response representing an error, the <responseData> XML section is replaced with the <errorData> XML section, which has the
following format:

where:

<errorCode> is a short alphanumeric constant string representing the specific error

<errorMessage> is a readable, native language explanation of the error

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.

Full list of available methods is available here


283
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals

Server and Cluster Methods


List of Available Methods

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

The following is a list of methods available for the deployment feature:

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:

Zend Framework (ZF)


Advanced diagnostics
Deploying PHP on Zend Server
Performance tuning
Security considerations
Troubleshooting
289
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals

Zend Framework (ZF)


Integration

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:

Be sure to use Code Tracing


Determine if the issue is genuine
Is it due to the Monitor Rule parameters (thresholds, functions list), or is it real?
Can the Monitor API be used to solve it?
Is the behavior acceptable for a certain set of circumstances
Don't forget to clean up the event database by deleting resolved events

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

Deploying PHP on Zend Server


Apache / nginx is a dependency of Zend Server and is used to run your PHP code

This option may vary depending on your operating system

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

Only install components that will be used

Turn off components when not needed

Debugger loaded in development phase of Software Lifecycle; Off in production

Keep Monitor running, except during performance testing

Page Cache Off if not using URL-based caching (similarly for Data Cache)

Keep OPcache running (fine tune, as needed)


294
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Performance Tuning
General Recommendations for PHP

It is possible to edit some directives to enhance performance

PHP | Extensions (see manual)

Tuning FastCGI Configuration (Windows only)

FastCGI available for IIS, to help handle heavy web traffic

Increase PHP instances beyond 10 for large traffic loads

Control the number of requests handled by a PHP instance before recycling


295
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals

Security Considerations
Server Security

Debugger Access Control (Allowed Hosts):

Create a list of Allowed Hosts to limit access to Debugger sessions


The default value only permits localhost access

Audit Trail

Access from the Zend Server UI: Administration | Audit Trail


Each administration action performed on the server is logged
296
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Security Considerations
Recommendations

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

Password protection provides a level of security

An IP address-based access control list for the Administrative Interface on the web server running Server is an added level of security

Linux and Mac OS X: Edit the lighttpd configuration file

If you can't login or lose your Zend Server UI password, run the following (as root or administrator):

/usr/local/zend/bin/php /usr/local/zend/bin/gui_password.php <new password>

Access the web server's configuration and define the IP addresses

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

Access from the Zend Server UI: Security | Privacy

Causes Zend Server to mask sensitive data, values,


function names and identifiers or keys (i.e.
"username", "password" etc.)

When somebody views Zend Server logs, things like


credit card numbers will not appear
299
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Security Considerations
PHP Security

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:

The Web server (Apache) is listening on port 80

The Zend Server Administration Interface is listening on 10081,10082

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

Resolve it with an Allowed Exception

This is not a security issue


301
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Troubleshooting
Windows / IIS 8 - 10:
Zend Server isn't running "out of the box"

After installing Zend Server, clicking on shortcut opens the browser with an error

Possible cause : It could be that your Web site is not running

Solution : Turn on your Web site

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

Possible Cause: (when running diagnostics on an alternate server)

The Debugger is not running on the alternate server

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 :

Check the settings in Zend Studio


303
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Troubleshooting
Zend Server fails to
communicate with Zend Studio

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

Run the installer file or go to

Start | Settings| Control Panel | Add or Remove Programs | Zend Server and select Modify to run the installer

Click Next to complete the repair process

Click Finish to close the installer


305
Published PDF: June 20, 2018
Rogue Wave Software. © 2018 All rights reserved
Zend Server Fundamentals
Troubleshooting
Web Server URL Rewrite Setup

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:

Loss of, or damage to, data;


Direct, special, incidental, or indirect damages, or for any economic consequential damages; or
Lost profits, business, revenue, goodwill, or anticipated savings.
Accuracy or completeness of the Rogue Wave Software courses' materials.

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.

Vous aimerez peut-être aussi