Posts Tagged ‘PHPUnit on Centos5.1’

h1

Getting ZendDebugger to work on Centos5.1

October 21, 2008

Well I had to setup a Zend Studio for Eclipse on Centos today, me thinking that it would be a blissful journey, abruptly followed by the realization that Centos wasn’t going to play nice. First thing after a clean install I ran yum update to make sure the system was up to date.

I tried to install ZendFramework 1.7, ZendStudio6.1 & PHPUnit3 and installed as I have before but came against a brick wall, PHPUnit would not install, due to PHP-XML being missing.
yum install php-xml
Which installs php-xml5.1.6, okay, I know I need 5.2 at least but for now I want to make sure PHPUnit will install.
pear channel-discover pear.phpunit.de
pear install phpunit/PHPUnit

Once PHPUnit was installed I ran the test cases, ZS complains with the follow:
Error launching 'AllTests.php
The session counld not be startd.
In order to generate debug inormation, please make sure that the debugger is properly configured as a php.ini directive

I run phpunit from shell to get:
Failed loading /usr/lib/php/modules/ZendDebugger.so: /usr/lib/php/modules/ZendDebugger.so: undefined symbol: zend_memory_usage

Okay so ZendDebugger isn’t working, php -v shows me:
PHP 5.1.6 (cli) (built: Sep 20 2007 10:16:10)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies

So I need a new version of PHP, PHP5.2.6 will do, yum update php tells me that 5.1.6 is that latest version, so I need to find a repository that has one.

cd /etc/yum.repos.d
wget http://dev.centos.org/centos/5/CentOS-Testing.repo
vim
CentOS-Testing.repo

Edit the line below.
enabled=0

to
enabled=1

your file should now look like this:
[c5-testing]
name=CentOS-5 Testing
baseurl=http://dev.centos.org/centos/$releasever/testing/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://dev.centos.org/centos/RPM-GPG-KEY-CentOS-testing
# CentOS-Testing:
# !!!! CAUTION !!!!
# This repository is a proving grounds for packages on their way to CentOSPlus and CentOS Extras.
# They may or may not replace core CentOS packages, and are not guaranteed to function properly.
# These packages build and install, but are waiting for feedback from testers as to
# functionality and stability. Packages in this repository will come and go during the
# development period, so it should not be left enabled or used on production systems without due
# consideration.

Now run the following

yum install php

You should get something simular to this….
=============================================================================
Package Arch Version Repository Size
=============================================================================
Updating:
php i386 5.2.6-2.el5s2 c5-testing 1.2 M
php-cli i386 5.2.6-2.el5s2 c5-testing 2.4 M
php-common i386 5.2.6-2.el5s2 c5-testing 230 k
Updating for dependencies:
php-ldap i386 5.2.6-2.el5s2 c5-testing 31 k
php-xml i386 5.2.6-2.el5s2 c5-testing 97 k
Transaction Summary

Now I ran the test and got the following error.
Failed loading /usr/lib/php/modules/ZendDebugger.so: /usr/lib/php/modules/ZendDebugger.so: cannot restore segment prot after reloc: Permission denied

Okay, that was totally unexpected, so after a little searching with my best friend (google) I found the following command
/usr/sbin/setenforce 0
Ran the tests again….
phpunit AllTests.php
PHPUnit 3.3.2 by Sebastian Bergmann.
.......

Time: 0 seconds

OK (7 tests, 0 assertions)

Perfect & running within ZS gives me the below results, job done.

One thing to make note of; when I restarted the box, SELinux had been reactivated so I disabled SELinux by doing the following (this is not ideal, i’ll have to look allowing doing this a better way).

vimĀ  /etc/sysconfig/selinux
and changing
SELINUXTYPE=enforcing
to
SELINUXTYPE=disabled
Doing this disabled SELinux so that we I wouldn’t get the permissions error. Alternatively I could of placed the setenforce command in a startup script (bashrc or something simular).

Follow

Get every new post delivered to your Inbox.