The latest Zend Server 8 on Amazon Web Services Marketplace (8.0.1) introduces some exciting new features tailored for Amazon Web Services users. We received a lot of feedback from users over the past few months, and many of the new features are a direct result of this feedback. Please keep sending us anything you’ve got via all the available channels. We promise to take your feedback into consideration.
Here’s a list of notable new features:
- A new Amazon Web Services Z-Ray extension included in the AMI.
- A totally new user data format based on JSON.
- Automatic Deployment – now you can deploy code directly from ZPKs, S3 buckets or git.
- Custom script execution upon finishing instance startup.
- Cluster settings that allow you to manually control whether Zend Server should join a cluster during startup.
- Ability to define Amazon Web Services Access Key and Secret Key
This article describes these features and other changes. Enjoy the ride!
Zend Server 8 on Amazon Z-Ray Extension
Zend Server Z-Ray is an innovative new technology that gives developers valuable insight into all the PHP elements constructing their code, allowing them to identify issues and troubleshoot them early on in the development cycle. Z-Ray tracks requests made to the web server, and displays live and detailed information right in front of you, in your browser. There is no need to make any changes to your code or extra configurations – simply open your app in a browser.
Zend Server 8 on Amazon features Z-Ray extensions for popular PHP applications and frameworks, including WordPress, Drupal, Magento, Zend Framework, Symfony, and more. Zend Server 8 AMIs also come bundled with a special Z-Ray extension for Amazon Web Services. This extension displays an ” Amazon Web Services” tab in Z-Ray, which includes detailed information about the Amazon instance serving the request on top of which Zend Server is running.
This extension is available out of the box for all instances when Z-Ray is enabled (Z-Ray is enabled by default on the Zend Server Developer Edition AMIs).
New User Data Format
When you launch an instance in Amazon EC2, you have the option of passing user data to the instance that can be used to perform common automated configuration tasks and even run scripts after the instance starts. Prior to Zend Server 8, the format for Zend Server AMI user data was “shell script like”. We used user data internally, when using CloudFormation templates to initialize Zend Server and connect it to a cluster. But the format of the previous user data was never described anywhere in our documentation. We have now improved user data, by changing it to simple JSON and publishing full documentation on what parameters are recognized, and their purpose. Keep reading for detailed examples and use cases.
User data is expected to be a JSON object with the following fields (all fields are optional of course):
|ZEND_ADMIN_PASSWORD||string||Password for the admin user of Zend Server. If it is set without ZEND_CLUSTER_* parameters, it will bootstrap Zend Server and setup an admin password.|
|ZEND_GIT_REPO||string||URL of a git repository which is deployed to the default virtual host document root.|
|ZEND_S3_BUCKET||string||Name of S3 bucket from which files are downloaded to default virtual host document root.|
|ZEND_S3_PREFIX||string||If set, then only files with that prefix will be downloaded to the default virtual host document root (take into account that the prefix will be present in any files downloaded, so if you restrict it to a folder, the folder will be downloaded to document root).|
|ZEND_ZPK||array||Optional information about ZPK that should be deployed during startup. Note that for this to work you must specify ZEND_ADMIN_PASSWORD. For structure of this array see table of ZPK parameters.|
|ZEND_DOCUMENT_ROOT||string||Document root relative to the system default document root. Should be used with git or S3 deployment (just set it to path relative to your git repository or S3 folder).|
|ZEND_SCRIPT_URL||string||URL from which custom script should be downloaded and executed.|
|ZEND_SCRIPT_PATH||string||Absolute path including filename where custom script must be placed. After a reboot, this file will be overwritten by re-downloaded script.|
|ZEND_CLUSTER_DB_HOST||string||MySQL DB hostname for Zend Cluster.|
|ZEND_CLUSTER_DB_USER||string||MySQL DB user for Zend Cluster.|
|ZEND_CLUSTER_DB_PASSWORD||string||MySQL DB password for Zend Cluster.|
|AWS_ACCESS_KEY||string||Access key to use for all AWS S3 operations.|
|AWS_SECRET_KEY||string||Secret key to use for all AWS S3 operations.|
|ZEND_DEBUG||bool||Set to true to start Zend Server in debug mode with maximum log verbosity (WARNING: do not use this on production systems!).|
|url||string||URL from which ZPK will be downloaded.|
|name||string||Name of application that will appear in Zend Server UI after deployment.|
|params||array||Array of additional parameters that is passed to Zend Server during ZPK deployment. Keys of this array are names of parameters and respective values are values of parameters.|
A simple example of user data JSON
An example of user data that will bootstrap Zend Server, and set the UI admin password to 1234:
Automatic Deployment Options
Zend Server 8 AMIs have three new options for automatically deploying code from either git, AWS S3 or a .ZPK file (see below). The first two options deploy into the default virtual host directory, overwriting all files in it (except ‘dummy.php’ which is required by the Zend Debugger). Since the document root and repository usually differ, you can specify the document root relatively to the default document root (ZEND_DOCUMENT_ROOT option), and the document root of the virtual host will be adjusted accordingly.
Deployment from a .ZPK is done to the default virtual host, but using Zend Deployment. A .ZPK (Zend Application Package) is basically a compressed file which contains all your application code, including it’s data, scripts, and an XML descriptor file.
For more information on .ZPKs and Zend Deployment read the Deployment section of the Zend Server online help.
ZPK files deployment
Starting from Zend Server 8 on Amazon, you can automatically deploy .ZPKs
To do this, you have to specify ZEND_ZPK and ZEND_ADMIN_PASSWORD (the latter must be specified because deployment of a .ZPK requires Zend Server to be launched). When deploying a .ZPK using user data, the default virtual host is used in Zend Server. This is mainly because this is the only virtual host existing after Zend Server is launched. For a detailed description of the ZEND_ZPK parameter see ZEND_ZPK structure.
Here is an example of user data JSON that sets the Zend Server admin password to 1234 and deploys a WordPress .ZPK:
"blog_name": "AWS Wordpress demo",
Note: you can specify a .ZPK stored on AWS S3 using url like s3://<bucket-name>/<filename>
Git repository deployment
You can set ZEND_GIT_REPO to any URL recognized by git. Then, during start up, the git repository will be cloned from the specified URL to the document root of the default virtual host. If the ZEND_DOCUMENT_ROOT variable is specified, then after cloning is done, the document root will be adjusted accordingly.
Here is an example of user data JSON that sets the Zend Server admin password to 1234, deploys the ZF2 skeleton application from github and adjusts the document root:
Note: If your repository is password protected, you will have to specify the username and password in the URL, using the format username:password@url.
AWS S3 bucket deployment
You can set ZEND_S3_BUCKET to the name of a bucket that will be downloaded to your document root. If ZEND_S3_PREFIX is set, then only objects with ZEND_S3_PREFIX prefix will be downloaded. If ZEND_DOCUMENT_ROOT variable is specified, then after cloning is done, the document root will be adjusted accordingly.
Here is an example of user data JSON that sets theZend Server admin password to 1234 and deploys the ZF2 skeleton application from S3 bucket and adjusts the document root:
When using Zend Server 8 on Amazon Web Services, there is an option to specify a custom script, that will be downloaded and executed locally on the instance, after a successful startup (including the deployment step). For this, there are two variables that must be set: ZEND_SCRIPT_URL and ZEND_SCRIPT_PATH.
ZEND_SCRIPT_URL – specifies from where the script should be downloaded.
ZEND_SCRIPT_PATH – specifies where the script should be saved locally (if you do not know where to put it, just put it in /tmp).
Once the script is downloaded, it will be executed by user root. So if you need to customize your system somehow (for example setup MySQL DB), this script is exactly what you are looking for.
Custom scripts are great – but not limited – for:
- Implementing custom deployment option (for example deployment from SVN or your own deployment method).
- Post deployment configuration (for example if you have a few environments you can use this script to download appropriate configuration file).
- Post boot installations and downloads.
- Setting up environment variables
Note: the script can be downloaded from S3. To do this, specify the URL as follows: s3://<bucket-name>/<filename>.
If you specify ZEND_CLUSTER_DB_HOST, ZEND_CLUSTER_DB_USER and ZEND_CLUSTER_DB_PASSWORD, Zend Server will join a cluster using that database upon startup. These settings were primarily used by our CloudFormation template (you can find our CloudFormation template generator at http://www.zend.com/en/products/server/cloudformation), but you can of course use them to create your own Zend Server cluster management system.
AWS Access Key and Secret Key
You can specify an AWS access key and secret key to use when communicating with AWS S3. To do this, set the AWS_ACCESS_KEY and AWS_SECRET_KEY parameters. If they are not set, then the startup script will use the IAM profile associated with the instance (for more information, read AWS IAM documentation).
If AWS_ACCESS_KEY and AWS_SECRET_KEY are not set, and there is no IAM profile for the instance, then S3 deployment won’t work and custom scripts on S3 won’t be available.
We’re continuously improving our Zend Server 8 on Amazon Web Services support. If you have any questions or feedback, please leave us a comment or contact us @phpcloud