Getting Started with Zend Server Deployment
For this tutorial, we'll be using a Zend Framework application, because of its convenient project structure: Zend Framework applications have an internal document root folder called "public" where the public files are stored, while the source code and configuration files are stored outside of the document root.
Step 1: Download Zend Server
Visit the download page »
Step 2: Create a Zend Framework project (if you don't have one handy)
Two easy ways to create a new Zend Framework project:
1. Use Zend Studio
2. Use the Zend Framework command line interface
Step 3: Create a deployment skeleton
From a command line interface, run the Zend Server's zdpack tool in your workspace (one level above the base project directory), replacing "ProjectName" with the name of your project:
zdpack create ProjectName
The "zdpack create" command creates a skeleton of project files and directories that allows the Zend Server deployment mechanism to understand how to deploy that application. After creating the deployment skeleton, your project should look something like the image on the right (red highlighted areas are files/directories created by the zdpack tool).
The skeleton files created include the "data" and "scripts" directories underneath the application's root directory. The "scripts" directory contains templates for individual PHP scripts designed to run deployment commands at various points in the deployment process.
Optional step: To illustrate using a deployment script to add functionality tied to a step in the deployment process, we may want to have the application send an email each time it's deployed. To do so, add the following code to /scripts/post_activate.php:
Notice the use of the variable $currentAppVersion – data or metadata about the deployment is available for use in these scripts via environment variables like this one.
Step 4: Modify the deployment XML file
Step 5: Create the deployment package
Returning to the command line interface, run zdpack pack, again replacing "<path>/ProjectName" with the path to and name of your project:
zdpack pack <path>/ProjectName
This command creates a ZPK file containing the entire application project complete with deployment descriptors.
Step 6: Deploy using Zend Server
From the Zend Server management console, click on the Applications tab, and click on the Deploy Application button in the top right. Follow the steps in the wizard, and Zend Server will do the rest!