Note: You may want to see my Teamcity server guide as well:

Getting Started.

I started with

svcadm disable tomcat #we won't use this

Install php and other needed stuff (some of this may not be nessisary, but why not).

pkgin in php55-pear php55-dom nano gmake gcc47 autoconf php-5.5 php55-mysqli php55-mcrypt php55-mbstring unzip php55-zlib php55-gd php55-zip php55-curl php55-imap php55-json php55-mysql php55-pdo_mysql php55-bcmath php55-fpm nano php55-dom php55-xmlrpc php55-posix php55-pcntl php55-iconv  

Xdebug is a installed with pecl pecl install xdebug

Add the stuff below to the bottom of nano /opt/local/etc/php.ini:  

Install a bunch of stuff we can use later with Teamcity (I don't know if you need this on the build agent server, or the teamcity server, I have this on both):

pear channel-discover  
pear channel-discover  
pear channel-discover  
pear channel-discover  
pear channel-discover  
pear channel-discover  
pear channel-discover

pear install  
pear install bartlett/PHP_CompatInfo  
pear install --alldeps PHP_Codesniffer  
pear install pdepend/PHP_Depend-beta  
pear install phpmd/PHP_PMD  
pear install phpunit/phpcpd  
pear install phpunit/phpdcd-beta  
pear install phpdoc/phpDocumentor-alpha  
pear install [--alldeps] phing/phing  
pear install phpunit/PHPUnit_Story  

Note: Pear is not the supported method anymore. Teamcity will just download the phar by default.

If you want a webserver (optional)

If your doing a webserver, see my helpers here:

Install nginx: pkgin in nginx

Disable and remove apache, we don't need it.

svcadm disable apache  
pkgin remove apache  

Enable nginx and php-fpm:

svcadm enable nginx  
svcadm enable php-fpm  
sudo mkdir -p /opt/local/etc/nginx/sites-enabled  
sudo mkdir -p /opt/local/etc/nginx/sites-available  

On Your Teamcity Server

Back on your teamcity server
install meta-runner-power-pack(

  • go to root home
  • clone repo
  • copy php metaRunners to _Root project (so it can be used on all projects)
cd ~ # go to root home  
git clone  
mkdir /opt/teamcity/teamcity_data/config/projects/_Root/pluginData/metaRunners  
cd /opt/teamcity/teamcity_data/config/projects/_Root/pluginData/metaRunners  
cp ~/meta-runner-power-pack/php/* ./  

Create some ssh keys:

mkdir /opt/teamcity/ssh  
cd /opt/teamcity/ssh  
ssh-keygen -t rsa #I called my key teamctiy_agents, sorted in this folder  
cat {yourKeynameNere}.pub #Just so we can read it.  

Back on Build Agent Server:

Lets add the ssh keys:
vi /home/admin/.ssh/authorized_keys #add a public key that you just generated

Had one error about SSL, found there error here: I used

We need to set a different JAVA_HOME than the server normally has, because this is the java that will be used for builds: export JAVA_HOME=/home/admin/BuildAgent/jre/

Download and run the fix script:


On Teamcity web interface:

Create "Agent push" preset.
Create agent with push using the SSH key and filepath you created.


  • I put have by build server on a private network behind a firewall. The Teamcity server can communicate directly with it.
  • If I want to actually see the webserver, I add my url to my firewalls reverse proxy.
  • for x2engine, I also had to uncomment session.save_path = "/tmp" from my php.ini file.
  • if you want mysql comman line unitilities

References: - -

Off topic: when installing the build agent On windows: Tested build agent on my local computer: setup router to forward 9090 to my IP. Had to add an extra line of my local config here ownAddress= (had to do this in the text file, not using the installer. The installer added an extra space).