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:
VAGRANTFILE_API_VERSION = "2" Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.box = "ubuntu/trusty64" config.vm.hostname = "zend.magento2.dev" config.vm.network :private_network, ip: "192.168.50.107" 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"] end end
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:
192.168.50.107 zend.magento2.dev magento2.dev
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:
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:
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.
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:
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
sudo apt-get install mysql-server-5.6
Creating Magento2 Database
mysql -uroot -proot
CREATE database magento2; exit;
curl -sS https://getcomposer.org/installer | php sudo mv composer.phar /usr/local/bin/composer
sudo apt-get install git
Now go to
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.
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.
The last step is to install ZRay extension for Magento2. Go to
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:
And that’s it! Clear the cache and visit Magento2 homepage.