How to install Zend Debugger on CentOS

Zend Debugger provides step-by-step debugging and lets monitor the current values of variables in scope. It can save hours for complex applications instead of using echo after each line to see what is going on.

The installation is relatively simple, but not very well documented and could get tricky if you don’t know what to look for.

First download Studio Web Debugger and follow the instructions in the README.txt file on how to set it up. You will need to extract a ZendDebugger.so file and add couple of lines to your /etc/php.ini file.

Once this is done, restart apache and test if ZendDebugger.so loads correctly

service httpd restart
php -v

You should see a message similar to the one bellow:

PHP 5.3.3 (cli) (built: May  7 2012 20:13:47)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
with Zend Debugger v5.3, Copyright (c) 1999-2010, by Zend Technologies

but you may get one of the following two errors:

Failed loading /usr/lib64/php/ZendDebugger.so:  libssl.so.0.9.8: cannot open shared object file: No such file or directory

or

Failed loading /usr/lib64/php/ZendDebugger.so:  libcrypto.so.0.9.8: cannot open shared object file: No such file or directory

CentOS includes those libraries version 10 or 1.0.0. Type locate libssl.so to find their location, which should be in /usr/lib64/ directory. If those libraries are not found you will need to install openssl

Yum install openssl

Once you located libssl.so.1.0.0 and libcrypto.so.1.0.0, create a symbolic link like so:

ln -s /usr/lib64/libssl.so.1.0.0 /usr/lib64/libssl.so.0.9.8
ln -s /usr/lib64/libcrypto.so.1.0.0 /usr/lib64/libcrypto.so.0.9.8

Run php -v again to make sure it is working. At this point you can start debugging unless you have SELinux enabled.

Troubleshooting SELinux related errors

If you run CentOS with SELinux enabled you will get one of the following two error messages if you search /var/log/httpd/error_log for ZendDebugger.so. ie

grep ZendDebugger.so /var/log/httpd/error_log
Failed loading /usr/lib64/php/ZendDebugger.so:  /usr/lib64/php/ZendDebugger.so: cannot enable executable stack as shared object requires: Permission denied

or

Failed loading /usr/lib64/php/ZendDebugger.so:  /usr/lib64/php/ZendDebugger.so: cannot restore segment prot after reloc: Permission denied

Run the following two commands to solve the above errors in respective order:

setsebool -P httpd_execmem on

The above flag enables the webserver to access and execute code in memory, which required by ZendDebugger, but blocked by SELinux as in production environment this behaviour is normally of malicious nature.

The next command will fix the second error caused by incorrect context labelling.

chcon -t textrel_shlib_t /usr/lib64/php/ZendDebugger.so

The last thing we need to do is to run the following command which will allow the webserver (httpd) to communicate with external services over the network.

setsebool -P httpd_can_network_connect on

You are all done. Happy debugging!

Notes on installing Zend Debugger on cPanel/WHM Server

The installation process if the same as installing the debugger on CentOS with exception to different file locations.

Location of php.ini file:

/usr/local/lib/php.ini

cPanel server will already have openssl with libssl.so.0.9.8 and libcrypto.so.0.9.8 libraries, so you can link those instead

ln -s /usr/lib/vmware-tools/lib64/libssl.so.0.9.8/libssl.so.0.9.8 /usr/lib64/libssl.so.0.9.8
ln -s /usr/lib/vmware-tools/lib64/libcrypto.so.0.9.8/libcrypto.so.0.9.8 /usr/lib64/libcrypto.so.0.9.8

You may also want to change

zend_debugger.expose_remotely=always

to

zend_debugger.expose_remotely=allowed_hosts

This directive allows Zend Debugger to expose itself upon request (this is used in some service functionality). The possible options are:
never . do not expose (default)
always . expose to whoever wants to know
allowed_hosts . expose only if the request comes from an IP listed above

Comments   

gab
# gab 2013-08-24 06:45
Thanks a lot, you saved me hours
stephen
# stephen 2014-03-26 01:27
Thanks , it is helpful .

 

Would you like to contribute?



Free business joomla templates