Build CentOS 5 generic RPM on CentOS 6

I’ve been trying to build a generic RPM (PHP code only, nothing linked) that installs on CentOS 5 and CentOS 6. We used to do this on CentOS 5, but when we moved our build box to CentOS6 we started to see errors that looked the the following:

rpmlib(FileDigests) is needed by my-example-project-1.2.3-1.noarch
rpmlib(PayloadIsXz) is needed by my-example-project-1.2.3-1.noarch

This is because the RPM was built on CentOS 6, which uses a new compression algorithm that CentOS 5 doesn’t know about.

To make your RPM CentOS 5 and CentOS 6 compatible, add the following to your spec file below the Requires section.

%define _source_filedigest_algorithm md5
%define _binary_filedigest_algorithm md5
%define _source_payload w0.gzdio
%define _binary_payload w0.gzdio

This makes your RPM CentOS 5 compatible

Read More

The class ‘APCIterator’ could not be found

This one catches me out every time, so documenting here for posterity.

Firstly, make sure apc or apcu (PHP 5.5+) is installed by running php -m | grep apc.

If you do have it installed but you’re still getting the error The class 'APCIterator' could not be found. then you probably need to enable APC on the command line. Make sure the following lines exist in your php.ini file:

apc.enabled = on
apc.enable_cli = on

Read More

Easy Graphite instances with Docker

Whenever I’m testing code that sends metrics to Graphite, I usually depend on a shared graphite instance that we have accessible on the network as Graphite is quite a lot of work to install locally. Today though, I realised that we can use Docker to run a Graphite instance for testing. Fifteen minutes later, I have a working Graphite instance that works perfectly.

First, you need docker installed.

Once you have Docker, you need an image to run. I ended up using this one from hopsoft. To download and start the image, run the following command:

sudo docker run -d \
  --name graphite \
  -p 81:80 \
  -p 2003:2003 \
  -p 8125:8125/udp \

This is almost identical to the command provided in the README, except it runs the web UI on localhost:81 rather than localhost:80. I do this because I already have things listening on port 80.

Docker should download all the required dependencies and start the container. Visit http://localhost:81 and you should see the Graphite UI.

Once you’re done testing, you can stop the container with docker stop graphite. If you want to remove the data completely, you can run docker rm docker.

If you just stopped the container, you can restart it at any point in the future with docker start graphite. If you removed the container, you’ll need to use the docker run command above to recreate it (although all the dependencies should be cached)

Read More