WordPress on AWS: Debugging with Zend Server and Z-Ray

More and more PHP development is being done in the cloud and on virtual platforms nowadays. The workflow detailed in this brief tutorial is just one way to develop PHP in these environments, but it illustrates just how easy and productive this type of development can be.

More specifically, it demonstrates how to launch the newly available Zend Server 8.5 instance on AWS with a WordPress application already deployed, and then use Z-Ray to introspect and debug the code.

Prerequisites

To follow the steps in this tutorial, you’ll need the following:

  • An active Amazon account
  • A running and pre-configured AWS RDS

Step 1: Launching your Zend Server Instance

Our first step is to launch a Zend Server 8.5 instance. This step in the tutorial describes the steps for manually launching an instance, including how to insert user data in the launching process.

1. Go to the Amazon’s Web Services Marketplace.

2. In the search field at the top of the page, enter ‘Zend Server’.

AMIs_list

3. A list of all the available Zend Server AMIs is displayed.
Various Zend Server editions and versions are available, going back to Zend Server 6.3 with PHP 5.3 LTS support, but in this tutorial I’m going to select the latest and greatest – Zend Server 8.5 Developer edition with PHP 5.6 on Ubuntu.

4. After taking a brief look at the supplied information, click the Continue button.

1-click-launch

5. Our next step is to configure the instance launching configurations.
By default the 1-Click Launch option is selected, This is  the simplest way to get your Zend Server instance up and running, and all you have to do after tweaking the launch configurations is click the Launch with 1-Click button, and your Zend Server instance is launched.

But in this case, I’m going to select the Manual Launch option. This option enables us to use advanced launching features using the EC2 console, APIs or CLI.

manual_launch

6. Before we can continue on, we need to accept the AWS terms for this AMI.
Click the Accept Terms button, and go back to the launch configurations page – the Accept Terms button is no longer visible.

7. Click the Launch with EC2 Console button for one of the listed AMIs.
The EC2 Console opens with the manual launch wizard.

manual_launch_wizard

8. Select one of the available instance types.
Instances are basically virtual servers with varying hardware setups. Depending on your application, select which combination of CPU, memory, storage, etc. you think you need.
Please note that for the Zend Server Developer Edition, only the ‘t2.xxx’ and ‘m3.medium’ instance types can be used.

Once you’re done, select the Next: Configure Instance Details button.

manual_launch_wizard1

9. The next page allows me to configure various instance details, such as the number of instances you want to set up and networking configurations. The more interesting option is hidden in the Advanced Details section.

manual_launch_wizard2

Here, we can add user data with instructions for the instance to be processed during the launching process.
For example, I can define the admin user password for accessing the Zend Server UI.
Or – I can get my Zend Server instance up and running with a deployed application from GitHub.
In this tutorial, I’m going to add the following user data to set up my Zend Server instance with a deployed WordPress application:

In addition to setting the password for accessing the Zend Server UI, the JSON code above specifies all the info we need to set up our WordPress app, including the URL of the publicly available WordPress Zend application package (or .zpk), database and WordPress credentials and the WordPress site URL.

You can simply paste this code in the box or upload it as a file.

For a full breakdown of the parameters that you can pass on during the launch, check out the Zend Server Online Help.

10. Let’s continue.
Click the next buttons until you reach the Configure Security Group page. Here you will need to manually set up security rules to control the traffic to your instance.
Enter a name and description for your group, and then add the following rules:

security_rules

11. Once you’ve finished defining these rules, click Review and Launch.

12. Review the launch details, and if all looks OK, click Launch.
Before launching, Amazon requires we select or create a new SSH key for secure access.

select_keypaur

13. Select an existing keypair or create a new one, accept the note at the bottom of the dialog, and click Launch Instances.
Your Zend Server instance is launched! Click View Instances at the bottom-right corner, and you’ll see your instance is being initialized.

instance_being_launched

Step 2 : Accessing Zend Server

After a short while, your Zend Server instance is up and running. Our next step is to access the Zend Server UI so we can start our development work.

1. After your instance completes the initialization process (allow a few minutes for this process to complete), copy the public IP (displayed in the Description tab), and paste it in your browser with the port that the Zend Server UI uses: 10081.

2. On the Zend Server Login page, enter the password we entered in the user data (1234) to access the Zend Server UI.

zend_server_accessed

Congrats! You’ve successfully launched and accessed Zend Server 8.5 on AWS!

Step 3 : Inspecting WordPress on AWS with Z-Ray

Now that we’ve got our Zend Server instance up and running, let’s open the WordPress app we deployed and start debugging it using Z-Ray.

Before you start, set up a redirect rule in your operating system’s hosts file with the server’s IP leading to the site URL we defined in the user data (e.g. 54.88.119.49 wordpress.dev).

1. In the Zend Server UI, go to the Manage Apps page under Applications.
You’ll see that the Applications List already contains a deployed application – the WordPress app we included in the user data when launching the instance.

applications_list

2. Select the application from the list, and then click the application URL.
Your WordPress app is opened!

WordPress on AWS

3. At the bottom of the page, Z-Ray is displayed.
Because we are using the Zend Server Developer edition, Z-Ray is enabled and displayed by default for all requests sent to the server. In other editions, Z-Ray needs to be enabled. For more info on how to do this, see the Online Help.

4. Select the WordPress panel on the right.
The Z-Ray WordPress plugin is displayed.

wordpress_plugin

5. Z-Ray’s WordPress support allows you to take are real hard look under the hood of your WordPress app, displaying info on loaded plugins, used hooks, cached objects and more.
For more info on the WordPress plugin, take a look at this video.

Summary

In just a few clicks, you can get up and running with your PHP deployed on Zend Server and AWS, start using Z-Ray to identify issues and optimize your code.

For more information on available features supported by Zend Server on AWS, check out this blog post by one of the project’s developers.

Happy PHPing! (on the cloud)

 

The following two tabs change content below.

    Daniel Berman

    Product Evangelist at Zend Technologies. Passionate about PHP, Zend's products and family. Into running, Liverpool FC, and blogging.

    About Daniel Berman

    Product Evangelist at Zend Technologies. Passionate about PHP, Zend's products and family. Into running, Liverpool FC, and blogging.