12
Jun

Install phpUnderControl on CentOS 5

A while back now I started setting up a server to use as a development machine. From a standard CentOS 5 installation I have installed SubVersion and Trac. Now I have finally got round to installing phpUnderControl for continuous integration and build management.

As usual, there are many great guides already on the net but getting everything to work usually requires a few of these references and a few additional changes. I will point out where I got the information from where applicable but the aim of this guide is to be complete and comprehensive.

If you follow this guide you should start with a basic CentOS 5 installation with Subversion setup correctly and end up with a working installation of phpUnderControl.

The Environment

I am aiming for the following:

  • CentOS 5 with SubVersion installed
  • PHP 5.2.X installed
  • CruiseControl binary installed, running on Sun JDK 6
  • phpUnderControl installed
  • A working build process for the example project

Here it is…

Upgrade CentOS 5 with PHP5.2

To get PHP5.2 installed on CentOS 5 (required for phpUC) we need to add an additional repository that has it. I am going to use the Yum Repository provided by Jason Litka. Detailed instructions can be found at his site. In summary, for CentOS 5 this consists of:

rpm --import http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka
vi /etc/yum.repos.d/utterramblings.repo

Add the following lines:

[utterramblings]
name=Jason's Utter Ramblings Repo
baseurl=http://www.jasonlitka.com/media/EL$releasever/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka

Now Yum can update PHP to 5.2. We also need a few other dependencies for phpUC:

yum install -y php php-pear php-xml

And the latest version of pear:

pear channel-update pear.php.net
pear upgrade pear

Get phpUnderControl

Using pear to install phpUC:

pear config-set preferred_state beta
pear channel-discover components.ez.no
pear channel-discover pear.phpunit.de
pear install --alldeps phpunit/phpUnderControl

This will install phpUC and all required dependencies. It’s a good idea to set pear back to only installing stable (i.e. non beta) packages:

pear config-set preferred_state stable

Sun Java JDK 6

phpUC needs CruiseControl and CruiseControl needs Sun JDK. Again, a full guide for getting this done can be found on the CentOS wiki. The steps I took are:

Set up rpmbuild:

vi ~/.rpmmacros

Make sure the file contents is:

%_topdir /home/<username>/rpmbuild
%_tmppath %{_topdir}/tmp

with <username> replaced with your logon name (if you are using root the path would be /root/rpmbuild).

mkdir -p ~/rpmbuild/{SOURCES,SRPMS,SPECS,RPMS,tmp,BUILD}
yum install -y rpm-build gcc gcc-c++ redhat-rpm-config jpackage-utils

Download JDK6 Update 6 (or the latest version) from java.sun.com. Get the .rpm.bin version. The file I got was called jdk-6u6-linux-i586-rpm.bin.

chmod +x jdk-6u6-linux-i586-rpm.bin
./jdk-6u6-linux-i586-rpm.bin
wget http://mirrors.dotsrc.org/jpackage/1.7/generic/non-free/RPMS/java-1.6.0-sun-compat-1.6.0.06-1jpp.i586.rpm
rpm -Uvh jdk-6u1-linux-i586.rpm java-1.6.0-sun-compat-1.6.0.01-1jpp.i586.rpm

With the JDK successfully installed (hopefully) we use Alternatives to select the Sun JDK:

/usr/sbin/alternatives –config java

Make sure the selected version is along the lines of /usr/lib/jvm/jre-1.6.0-sun/bin/java.

At this point java -version should give something like:

java version "1.6.0_06"
Java(TM) SE Runtime Environment (build 1.6.0_06-b02)
Java HotSpot(TM) Client VM (build 10.0-b22, mixed mode, sharing)

Now to add some environment variables:

vi /etc/profile.d/java.sh

Add the following:

export JAVA_HOME="/usr/java/jdk1.6.0_06"
export JAVA_PATH="$JAVA_HOME"
export PATH="$PATH:$JAVA_HOME"

Note that JAVA_HOME is not set to “/usr/java/jdk1.6.0_06/bin”. I don’t think this is the standard but it’s an easy way to get CruiseControl to work (see here).

You will also need to restart your session for these changes to take effect or just export the variables directly to the prompt.

Get CruiseControl

Download the latest 2.7.X CruiseControl binary. My version is cruisecontrol-bin-2.7.2.zip.

unzip cruisecontrol-bin-2.7.2.zip -d /opt
ln -s /opt/cruisecontrol-bin-2.7.2/ /opt/cruisecontrol

CruiseControl is bow installed in /opt/cruisecontrol-bin-2.7.2/ which is symlinked by /opt/cruisecontrol/

Setup phpUnderControl and CruiseControl

A more thorough guide can be found in the phpUnderControl Documentation.

To patch the CruiseControl installation you should be able to simply to:

phpuc install /opt/cruisecontrol

If not, try this:

cd /opt/
svn co svn://www.phpunit.de/browser/phpUnderControl/tags/0.4.2 phpundercontrol
phpundercontrol/bin/phpuc.php install /opt/cruisecontrol

And that’s pretty much it! I’ll just set up the example project so you can see it all in action:

phpuc example /opt/cruisecontrol

And to start cruisecontrol:

cd /opt/cruisecontrol/
./cruisecontrol.sh

Give it a while to setup. Once it’s all done you should be able to access the interface at:

http://localhost:8080/

By now you should have a working phpUC setup on your CentOS 5 machine and the example project failing the build process. Setting up your own projects is a bit more involved – follow the guide in the documentation for more details. As for the best way to make use of phpUC and optimal project layouts etc. I will have to get back to you as I haven’t yet played around much.

Please let me know if this helped you. If you come across any problems I will be happy to try and help.

Resources

  • http://blog.phpleo.com/ phpleo

    Hi, I have a problem in the step “Sun Java JDK 6”, because your download http://mirrors.dotsrc.org/jpackage/1.7/generic/non-free/RPMS/java-1.6.0-sun-compat-1.6.0.06-1jpp.i586.rpm
    but in the rpm nuild say: rpm -Uvh jdk-6u1-linux-i586.rpm java-1.6.0-sun-compat-1.6.0.01-1jpp.i586.rpm

    And this produce:

    warning: java-1.6.0-sun-compat-1.6.0.06-1jpp.i586.rpm: Header V3 DSA signature: NOKEY, key ID c431416d
    Preparing… ########################################### [100%]
    package jdk-1.6.0_06-fcs is already installed

    why?

    phpleos last blog post..BarCamp Lima 2008

  • http://www.destiny-denied.co.uk/ Daniel Skinner

    It looks like Java is already installed. What does `java -version` give?

  • http://www.rosenrod.com Rosenrod

    Thank you – I’ll be sure to check back later for more of your posts.

  • Jacob

    hey id like to talk with you about your blog. please email me – thanks.

  • Will

    Thanks for this guide. It was a huge help. I’m a novice with CentOS and was really struggling with installing phpUnderControl until I found this.

  • pierre-alain bourdil

    Hi, just a typo : the url is http://localhost:8080/cruiscontrol

  • Pingback: Installation phpUnderControl from scratch | Creative Developer Service()