Well, unfortunately you'll have to copy the entire configure line from the phpinfo() output and reconfigure and make everything again.
As an alternative route, you could ditch that and use the system package manager to install php and any shared modules you want. In Ubuntu ( and other Debian based distros ) you can do:
sudo aptitude install php5 php5-mcrypt php5-mysql php5-postgres php5-mhash php5-gd php5-<extension>
Or, to see what's available:
sudo aptitude search php5
Hope that helps.