How to create RPM packages like custom php or Apache

- Download source package
- Run ./configure with your desired flags
- run make
- run checkinstall, this will automatically create RPM package.

Download and install checkinstall package:

http://rpm.pbone.net/index.php3/stat/4/idpl/23516987/dir/centos_6/com/checkinstall-1.6.2-3.el6.1.x86_64.rpm.html

wget ftp://ftp.pbone.net/mirror/ftp5.gwdg.de/pub/opensuse/repositories/home:/ikoinoba/CentOS_CentOS-6/x86_64/checkinstall-1.6.2-3.el6.1.x86_64.rpm

rpm -i checkinstall-1.6.2-3.el6.1.x86_64.rpm
./configure your-FLAGS
make
checkinstall --install=no

and that is it, your RPM is now done.