Up And Running With Z-Ray For Magento2

In this article, we’ll guide you through the whole process of installing Z-Ray-Magento2 Plugin.

What Is Z-Ray-Magento2 Plugin?

The Z-Ray tool from Zend Server adds to your Magento instance a toolbar with powerful features for profiling your PHP files. Using the Magento2 Z-Ray plugin you can track heavy constructors, blocks rendering calls, behavior extension by plugins, number of observers listening to specific event and time on their execution.

Note: Zend Server is an enterprise solution and requires licence. However, 30 days trial is available, which is just enough to help you understand how Magento2 works behind the scenes.

Got It. Let’s Start!

First, create a new folder magento2 somewhere in your file system. Then, create a file Vagrantfile and copy the following content:

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "ubuntu/trusty64"
  config.vm.hostname = "zend.magento2.dev"
  config.vm.network :private_network, ip: ""
  config.vm.synced_folder ".", "/vagrant", type: "nfs"

config.vm.provider :virtualbox do |vb|
  vb.customize ["modifyvm", :id, "--memory", "2048"]
  vb.customize ["modifyvm", :id, "--ioapic", "on"]
  vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]

Next, download ZendServer installation. You’ll need to create an account if you don’t have one. Once downloaded (make sure that you downloaded Linux edition since we’re working on Ubuntu VM), extract it to magento2 folder, next to Vagrantfile. It should be inside of ZendServer-RepositoryInstaller-linux/ folder.

We want to make sure that the hosts file is updated. For Mac/Linux users, it’s located under /etc/hosts, and on Windows, it is C:\Windows\system32\drivers\etc\hosts. Add this line: zend.magento2.dev magento2.dev

This will allow us to access Zend Server admin panel on zend.magento2.dev, and Magento2 installation on magento2.dev.

Installing ZendServer

Now, let’s install and login to our Virtual Machine. Make sure that you are in magento2 folder that we created and run:

vagrant up
vagrant ssh

Then go to ZendServer installation folder:

cd /vagrant/ZendServer-RepositoryInstaller-linux/

And run installer:

sudo ./install_zs.sh 5.5

If you are wondering, 5.5 refers to PHP version that is going to be installed. Another option is 5.6. The process will ask you to install some additional packages, confirm it by pressing Y.

Completing ZendServer Installation In Browser

As soon as you notice that the installation is completed, go to http://zend.magento2.dev:10081/ZendServer/ and follow instructions from the screenshots:

Zend Server Instalation - Step 1

Zend Server Instalation – Step 1


Zend Server Instalation – Step 2


Zend Server Instalation – Step 3


Zend Server Instalation – Step 4


Zend Server Instalation – Step 5

When you hit Launch button, it will take a couple of seconds to finalize the process and redirect you to the admin panel.

Creating A New Virtual Host

Once you’re in, the only thing we want to do here is to create a virtual host for Magento. To do that, go to Applications-> Virtual Hosts from the sidebar.

Available Virtual Hosts

Available Virtual Hosts


Adding a New Virtual Host – Step 1


Adding a New Virtual Host – Step 2


Adding a New Virtual Host – Step 3


Adding a New Virtual Host – Step 4

At this point, virtual host will be added. However, in order for change to take effect, we need to restart ZendServer. To do that, click on Reload icon available on the right side of top navigation. The confirm box will popup. Hit Restart and wait a couple of seconds. If you managed to do it correctly, the Virtual Hosts screen should look like this:


New Virtual Host. Document Root.

Back To Terminal

We are done with all settings in the UI. Now we should finish a couple more things:

  • install MySQL
  • install git, composer
  • pull Magento2 code, pull dependencies
  • install Magento2

But, before everything, we need to create a symlink for /usr/local/zend/bin/php into /usr/bin/php.

sudo ln -s  /usr/local/zend/bin/php /usr/bin/php

Installing MySQL
sudo apt-get install mysql-server-5.6

MySQL Installation - Step 1

MySQL Installation – Step 1


MySQL Installation – Step 2

Creating Magento2 Database

mysql -uroot -proot

CREATE database magento2;

Installing Composer
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer

Installing Git
sudo apt-get install git

Installing Magento

Now go to

cd /usr/local/zend/var/apps/http/magento2.dev/80/

and add full permissions to _docroot_. This is where we’re going to place Magento2 source files.

sudo chmod 777 _docroot_/ && cd _docroot_/

We can pull Magento2 from Github.

git clone https://github.com/magento/magento2.git .

And run composer to install dependencies.

composer install

Some folders need to be writeable, so we’ll add the following permissions.

sudo chmod -R 777 var
sudo chmod -R 777 app/etc
sudo chmod -R 777 pub

Important: This is not best practice. This is an experimental development project so I am not concerned to put 777. To learn better approach, read Overview of ownership and permissions and Set file system permissions and ownership from official documentation.

Now you are ready to go to magento2.dev and complete the installation using Setup wizard. This article doesn’t cover installing sample data. If you are interested in doing that, we already covered it in Let’s start with Magento 2 article. There’s also a dedicated section on DevDocs on how to enable sample data.

Installing ZRay

The last step is to install ZRay extension for Magento2. Go to

cd /usr/local/zend/var/plugins/

create magento2 folder and cd into it.

sudo mkdir magento2 && cd magento2

Now we’ll clone Z-Ray-Magento repository.

sudo git clone https://github.com/magento/magento2-zray.git .

The final step is to edit  magento2-zray/zray/zray.php in nano and replace the Magento2 path to correspond to our filesystem:

define('MAGENTO_PATH', 'C:\web\Zend\Apache2\htdocs\magento2');
define('MAGENTO_PATH', '/usr/local/zend/var/apps/http/magento2.dev/80/_docroot_/');

And that’s it! Clear the cache and visit Magento2 homepage.

Installation Complete

Installation Complete

Milan Stojanov is a certified Magento developer and Tuts+ author on Magento Fundamentals premium course. He likes to read and write about web development.

  • Milena Dunic

    Great article, thanks!

  • Hello Milan Stojanov,

    I can not access the Magento 2 folder in file system Ubuntu or Text Editor.


    How to access the Magento 2 folder with any text editor or IDE?

    Thanks for this great article!!!

  • Hello Milan,

    The apache is work and run normally phpinfo.php in http://magento2.dev/phpinfo.php

    In the browser does not finish loading content in http://magento2.dev/magento2beta02/

    Any tips?


    • Milan Stojanov


      Are you sure that you cloned Magento2 code into


      Source files should be placed directly inside of this folder, not in a subfolder.

      Please double check that.


  • Odom Chorn

    Hello Milan,

    After I install all done but it show the an other message
    Fatal error: Cannot redeclare class MagentoFrameworkAppFrontController in /usr/local/zend/var/apps/http/magento2.dev/80/_docroot_/lib/internal/Magento/Framework/App/FrontController.php on line 10

    🙂 thanks,

    • Odom Chorn

      This Bug produce when I remove the cache in var directory, rm -rf var/*

      • Milan Stojanov

        Did you use the latest code? I will re-test this, but I am pretty sure
        everything works as expected. Will get back on Saturday with updates as
        soon as I’m done.

        • Odom Chorn

          yes, I clone from github develop branch. I found that it not generate 1 file in /var/generate/framework/app/FontController/Interpeter.php? this file always missing when I (run php bin/magento setup:upgrade or rm -rf var/*). I just copy past this file it’s work. So I think my environment not yet correct. I will re-install with vagrant.
          Thanks so much.. I really appreciate you work. 😉

  • Milan Stojanov

    Hi All,

    I dedicated 30 minutes now to re-test everything and I confirm everything works as expected just by following the tutorial. No other tweaks needed. Please double check that you didn’t miss some step.


  • Magento Developer

    Can Z-Ray be used without Zend Server?