Setting up Jenkins for a PHP projects on CentOS 7

Philippe Lafrance
Sep 22, 2015 · 4 min read

Setup a Virtual Private Server

Set yourself up for your PHP project

yum install php php-pear
yum install php-intl php-mbstring php-xml php-fileinfo
memory_limit = 1024M
curl -sS | php
mv composer.phar /usr/bin/composer
yum install php-devel
yum groupinstall "Development tools"
pecl install xdebug
echo "zend_extension=\"/usr/lib64/php/modules/\"" > /etc/php.d/xdebug.ini

Install Jenkins

yum install java-1.7.0-openjdk
yum install wget
wget -O /etc/yum.repos.d/jenkins.repo
rpm --import
yum install jenkins
firewall-cmd --zone=public --add-port=8080/tcp --permanent
firewall-cmd --reload
yum install ant
sudo /etc/init.d/jenkins restart
systemctl restart jenkins.service

Install PHP Tools (optional)

# PhpUnit
chmod +x phpunit.phar
mv phpunit.phar /usr/bin/phpunit
# Php CodeSniffer
pear install PHP_CodeSniffer-2.3.4
chmod +x phploc.phar
mv phploc.phar /usr/bin/phploc
# PDepend
chmod +x pdepend.phar
mv pdepend.phar /usr/bin/pdepend
chmod +x phpmd.phar
mv phpmd.phar /usr/bin/phpmd
chmod +x phpcpd.phar
mv phpcpd.phar /usr/bin/phpcpd
# phpDox
chmod +x phpdox.phar
mv phpdox.phar /usr/bin/phpdox

Setup Jenkins

User permissions


Create a project

cp /my/favorite/path/build.xml ./
<?xml version="1.0" encoding="UTF-8"?>
<project name="requirejs" default="default">
<target name="default" depends="composer,phpunit" /> <target name="composer">
<exec executable="composer">
<arg value="update"/>
<target name="phpunit" depends="composer">
<exec executable="phpunit">
<arg path="${basedir}/phpunit.xml.dist"/>

Philippe Lafrance

Written by

Programmer, Bassist, and social crack smoker.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade