Put all your excuses in a box ... burn the box, and forget about them.
You are dabbling in rather advanced PHP, and have already identified correctly the problem ... don't be scared, just crack on ...
Here's some ramblings about configuring PHP to overwrite your installation ...
Lets say I have PHP at /usr, scandir at /etc/php.d and configuration at /etc/php.ini
./configure --prefix=/usr --bindir=/usr/bin --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d
That minimal configuration would overwrite my installation, I have included --bindir because by setting that single configuration option you are able to isolate an installation of PHP at, for example, /opt/php-zts.
You require, at least, the additional option
--enable-maintainer-zts
You should inspect your current installation, make a note of the extensions enabled and just work your way up from the default.
If an extension should fail to build, it will usually be because the headers for the library the extension is wrapping are not available on your system, it's usually the case that installation of the dev, or devel package, using your distros package manager will allow the build to succeed.
Once you have a working full build, its good advice to copy config.nice to somewhere sensible so that you have it for the future.
Lastly it's not always desirable to actually overwrite the installation on your system, other software may be using that, so I usually say it's better to isolate an installation, here's a config.nice verbatim from an isolated install on my machine:
#! /bin/sh## Created by configure'./configure' \
'--with-apxs2=/opt/php-zts/bin/apxs' \
'--prefix=/opt/php-zts' \
'--bindir=/opt/php-zts/bin' \
'--with-config-file-dir=/opt/php-zts' \
'--with-config-file-scan-dir=/opt/php-zts/modules.d/' \
'--with-curl=shared,/usr' \
'--with-zlib' \
'--with-libxml2' \
'--enable-simplexml' \
'--with-mysql=mysqlnd' \
'--with-pdo-mysql=mysqlnd' \
'--enable-gd-native-ttf' \
'--with-mysqli' \
'--disable-phar' \
'--enable-shared' \
'--enable-maintainer-zts' \
'--enable-opcache' \
'--enable-sockets' \
'--with-curl=shared' \
'--enable-pcntl=shared' \
'--enable-mbstring' \
"$@"