Setting up Jenkins in Ubuntu Precise 12.04 for PHP projects

This howto tries to clarify all the steps for setting up a Ubuntu Precise box as Continuous Integration server for PHP projects by using Jenkins.  In the next days I’ll write another post about how to configure a PHP project inside Jenkins. So let’s go. ## Installing Jenkins server Ubuntu Precise now has inside its repository the Jenkins server packaged for an easy installation. So installing jenkins now is as simple as running the next command:

sudo apt-get install jenkins

after the installation jenkins will be running in the 8080 port. For accessing it you must go to http://localhost:8080

1 jenkins ready

If you want to allow Jenkins to send mails after the builds, for informing of build reports to your team, you have to install a MTA:

sudo apt-get install postfix

Installing required Jenkins Plugins

For building PHP projects you need some Jenkins plugins. These are the needed:

You can install these plugins using the web frontend at http://localhost:8080/pluginManager/available Just check them all and click the «Install» button. You will see the plugin installation progress:

2 installing plugins

If you can’t find the Jenkins plugin from the Jenkins interface you can install them from command line. Go to and copy the hpi file URL of your desired plugin and execute the next commands from your jenkins server commandline:

cd /var/lib/jenkins/plugins
sudo wget
sudo chown -R jenkins:nogroup /var/lib/jenkins/
sudo service jenkins restart

Take a look at the last line, if you want to install additional plugins you have to restart your Jenkins server for making it available. ## Installing the PHP Quality Assurance Toolchain The most common required PHP tools should be installed using the PEAR Installer, the backbone of the PHP Extension and Application Repository that provides a distribution system for PHP packages. Now this point could differ depending in tools you use in your build script. For example if you use Behat you have to install it with PEAR before build the project, and so on. The following commands are all that is required to install the required PHP tools using the PEAR Installer:

sudo apt-get install php-pear php5-mysql php5-memcache php5-imagick php5-curl php-apc php5-sqlite php5-xsl php5-xdebug

sudo pear config-set auto_discover 1
sudo pear install
sudo pear install theseer/Autoload
sudo pear install channel://
sudo pear install

You have to install some other tools required to execute the builds in PHP projects.

sudo apt-get install git-core

And that’s all, hope this little howto was useful and helps you to make easy to install and configure Jenkins CI server for building PHP projects.