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

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:

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.

  • Guest

    Thank you very much for your guide.  I just installed fresh Ubuntu 12.04 and was so happy find your article.

  • you’re welcome. This weekend I will write an article about how to integrate a PHP project in this installation.

  • Pingback: Jenkins | Kerek egy ég alatt()

  • Poidet

    I’m so waiting it :)

  • Martin Hlaváč

    Great article… helped me with installing php5-xsl ;-)

  • lattimore

    How can I install Jenkins by jenkins.war but not apt-get install?

  • Sorry for the delay,

    There is an official repository available for Ubuntu that contain the latest version of Jenkins.

    Take a look at the next link: