Innovate faster and cut risk with PHP experts from Zend Services.
See How Zend Helps Leading Hosting Providers Keep Their Managed Sites on Secure PHP
Learn PHP from PHP experts with free, on-demand, and instructor led courses.
Submit support requests and browse self-service resources.
Using an AWS CloudFormation template and Zend Server can help you automatically scale Magento. This is important for many reasons. When you use Magento to support an online store, it's important to ensure maximum scalability. That's because any interruptions to high availability and fast performance can negatively impact your revenue.
For this walkthrough, we'll focus on how to complete this set up on AWS, but you can use the same basic steps for other deployment options.
To achieve our goal, here are the steps we'll take:
This is the final step after which we will have Magento running on high available and auto scaled cluster.
Since we are going to run cluster on AWS you will need AWS account. Additionally it is expected that you know basic AWS terms like VPC, EC2 Instance, RDS Instance, etc. Additionally you have to be familiar with basic CloudFormation terms. Additionally I expect you to have a VPC for deployment (you can use default VPC if you want) and EC2 key pair ready for use.
You can use an AWS CloudFormation template generator to get started. Zend has a CloudFormation template generator that has some additional functionality like adding additional RDS server or ElastiCache service to template.
CloudFormation allows allocation of AWS resources as described by template files which utilize JSON format. CloudFormation operates with stacks of resources where each stack is created using a template.
AWS Marketplace has basic template that can be used to spin cluster.
Since we are going to deploy sample Magento web application, we'll use same RDS instance that Zend Server uses for storing cluster information. However, I strongly recommend to setup separate RDS instance for Magento database when deploying real production environment (either by adding another RDS in CloudFormation template or by setting it up manually).
You can find list of Zend Server products on AWS Marketplace. Zend Server is available on Ubuntu Server 14.04 LTS or RHEL 7 Operating System. Additionally there are three Zend Server editions - Developer, Professional, and Enterprise (note that Developer Edition does not have clustering capabilities and is intended for development and testing use only). There are also two versions of PHP supported - 5.6 and 7.0. For the purpose of our demonstration we will use PHP 7.0 - Zend Server Professional Edition (Ubuntu).
Here are the steps to deploy Zend Server Cluster on AWS:
Click yellow “Continue” button in the right column.
Click yellow button “Accept Software Terms” on the right column. If you do not have such button, then you already have subscription to Zend Server product and should skip to step 7.
You will be presented “Thank you” page with information and next steps. Read them and click blue button “Return to Product Page”. You will be taken back to launch page (reminder – ensure that “Manual Launch” tab is selected).
Click yellow “Launch with CloudFormation Console” button. If the button is grey and you see a message “Subscription is not ready. You will be able to launch in a few minutes.” just wait a few minutes (from what I know it takes something like 5 minutes until subscription is ready).
You will be taken to CloudFormation Create Stack wizard on AWS Console. URL for template is already prefilled, so all you need to do at this step is click “Next”.
Once all parameters are filled, click “Next”.
Final step is “Review”. Here you will be presented with summary. One important note here is to ensure that checkbox “I acknowledge that AWS CloudFormation might create IAM resources” is checked. Then click “Create” button.
All that is left now is to wait till CloudFormation sets up Zend Server Cluster for you. It will take a few minutes.
Once cluster is ready, click on stack and open “Outputs” tab. There you will find DB credentials, URL of Load Balancer, and URL of Zend Server UI – you will need those to deploy Magento in next section.
We are going to deploy Magento 2.1.2 which is the latest version of Magento available as of writing of this blog. We are going to deploy Magento using Zend Deployment which simplifies deployment of PHP applications on Zend Server and provides additional features like customizable hooks for different stages of deployment and rollbacks.
Zend Deployment deploys Zend Deployment Package files, which is basically a zip archives with some predefined structure. You can read more about Zend Deployment here.
Zend Server ships with a few demo ZPK (Zend Application Package) applications including Magento. Unfortunately Magento ZPK that is shipped with Zend Server 9.0 is Magento 188.8.131.52. Although next version of Zend Server will have new Magento version, it is not ready yet. So for this article I developed my own Magento ZPK which utilizes Magento CLI in hook scripts to automate deployment. ZPK is available freely here. Please feel free to use this package as starting point for your customizations as needed.
Steps to deploy Magento on Zend Server Cluster:
Click on "Deploy application" button on top of the page. Application deployment wizard will be shown.
Click "Choose File" button and select Magento ZPK you downloaded.
Next step is "Application Details" where you can customize path under which application is deployed and Virtual Host. Deploying Magento to root of Virtual Host on AWS can lead to unwanted result because ELB expects our nodes to return HTTP 200 when request is made to / on server, while Magento will return 302. This will lead to a situation where ELB will consider all nodes of cluster unavailable and return error. This can be avoided by adding health check file to Magento ZPK and modifying ELB configuration to check against this file. But this is outside of scope of this article. Instead we will simply deploy Magento under "magento" path. For this just enter "magento" in path and click "Next" to continue. all values at this step at their defaults and just click "Next".
Last step before deployment shows you everything for a review before starting deployment. Click "Next" to start deploying Magento application.
Zend Server Cloud Solutions