In order to build and install php in Ubuntu 12.10, beyond the normal "build-essential" package, I had to install the following packages: apache2-prefork-dev libxml2-dev libsnmp libsnmp-dev libtool
Command line should be like this:
sudo apt-get install apache2-prefork-dev libxml2-dev libsnmp libsnmp-dev libtool