Compile PHP 7.3.13 on CentOS 7 with OCI8 and MongoDB extension.

Compiling PHP version 7.3.13 with OCI8 and MongoDB extension on Centos 7.

First Install Development Tools on CentOS 7.

yum group install "Development Tools"

Download the latest stable PHP version 7.3.13 source code from its website.

cd /usr/src/
tar xvf php-7.3.13.tar.gz
cd php-7.3.13

“configure” is a script designed to aid a program to be run on a wide number of different computers. This will automatically use your system variables to configure and ready the source for your VPS. It basically matches the libraries required by the program, with the ones installed on your system. By doing this, the compiler knows where to look for the libraries required by the source, or in this case by PHP. Besides that, it will also figure out where to install the package afterward. When it is done it will generate a file called Makefile with all the info in it.

 ./configure --prefix=/usr/local/php7313 --with-config-file-path=/usr/local/php7313/etc --with-config-file-scan-dir=/usr/local/php7313/etc/conf.d --includedir=/usr/include/php7313 --with-libdir=lib64 --disable-debug --with-pic --disable-rpath --without-pear --with-bz2 --with-freetype-dir=/usr --with-png-dir=/usr --with-xpm-dir=/usr  --without-gdbm --with-gettext --with-gmp --with-iconv --with-jpeg-dir=/usr --with-openssl=yes --with-pcre-regex --with-zlib --with-layout=GNU --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --enable-exif --enable-sockets --enable-shmop --enable-calendar --with-libxml-dir=/usr --enable-xml --enable-mbstring --enable-mbregex --with-gd=shared --enable-bcmath --with-xmlrpc=shared --enable-wddx=shared --with-xsl=shared,/usr --with-curl=/usr --with-tidy=shared,/usr --with-icu-dir=/usr --enable-json --enable-dom --enable-fileinfo --enable-posix --enable-intl --enable-zip --enable-pdo --enable-xmlreader --enable-xmlwriter --enable-soap --with-pear --with-ldap=/usr --with-mysqli -with-pdo-mysql --with-pdo-sqlite --with-gd

You may face multiple errors during compilation. Resolve the Dependencies first.

Dependencies errors

Error 1: configure: error: libxml2 not found. Please check your libxml2 installation.

 yum install -y  libxml2-devel

Error 2: configure: error: Cannot find OpenSSL’s

yum install openssl-devel

Error 3: configure: error: Please reinstall the BZip2 distribution

 yum install -y  bzip2-devel

Error 4: checking for cURL 7.15.5 or greater… configure: error: cURL version 7.15.5 or later is required to compile php with cURL support.

 yum install -y  curl-devel

Error 5: configure: error: jpeglib.h not found.

yum install -y  libjpeg-devel

Error 6: configure: error: png.h not found.

yum install -y libpng-devel

Error 7: configure: error: xpm.h not found.

yum install libXpm-devel

Error 8: configure: error: freetype-config not found.

 yum install -y freetype-devel

Error 9: configure: error: Unable to locate gmp.h

yum install gmp-devel

Error 10: configure: error: Unable to detect ICU prefix or /usr/bin/icu-config failed. Please verify ICU install prefix and make sure icu-config works.

 yum install libicu-devel

Error 11: configure: error: Cannot find ldap.h

 yum install openldap openldap-devel

Error 12: configure: error: Cannot find libtidy

yum install libtidy-devel

Error 13: configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution

yum install -y libxslt-devel

Error 14: configure: error: Please reinstall the libzip distribution

cd /usr/src/
(Download, compile and install )
tar -zxvf libzip-1.2.0.tar.gz
cd libzip-1.2.0
make install
 cd /usr/src/php-7.3.13
Continue Configuration process again.

Error 15: configure: error: off_t undefined; check your library configuration

# Add below line in /etc/ file. 
vim  /etc/

(Now update the configuration )
ldconfig -v

Error 16: /usr/local/include/zip.h:59:21: fatal error: zipconf.h: No such file or directory

cp /usr/local/lib/libzip/include/zipconf.h /usr/local/include/zipconf.h

Finally Build part has been completed.

Build complete.
Don't forget to run 'make test'.

You are now ready to compile the source. To compile it run the below command. This will compile the source output a lot of rubbish to your console. Just go ahead and let it finish. It will take time if you won’t mention -j option. Increase the number according to your VPS CPU core available. This will reduce the compiling time.

 make -j4

When it is done, you should be ready to install it. Make will now follow the instructions in the Makefile to install the compiled package.

make install


( PHP Installation part has been completed. )

Now Configure PHP and PHP-FPM file.

First copy php.ini file from its source folder. It also might be on the PHP installed folder.

 cp /opt/src/php-7.3.13/etc/php.ini-development /usr/local/php7313/etc/php.ini

Create SymLink:

ln -s /usr/local/php7313/bin/php /usr/local/bin/php73
ln -s /usr/local/php7313/bin/pecl /usr/local/bin/pecl73
ln -s /usr/local/php7313/bin/php-config /usr/local/bin/php-config73

PHP-FPM Config Files:

cd /usr/local/php7313/etc/php-fpm.d/
mv www.conf.default www.conf
mv /usr/local/php7313/etc/php-fpm.conf.default /usr/local/php7313/etc/php-fpm.conf

www PHP-FPM pool

vim /usr/local/php7313/etc/php-fpm.d/www.conf

listen = /usr/local/php7313/var/run/php7313-fpm.sock
listen.mode = 0666
user = nginx
group = nginx
listen.owner = nginx = nginx
pm = dynamic
pm.max_children = 128
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 10000
rlimit_files = 1024
slowlog = log/$pool.log.slow

cat /usr/local/7313/etc/php-fpm.conf | grep -v ";"


PHP-FPM Systemd service setup

copy php-fpm service file from source folder.

cp /usr/src/php-7.3.16/sapi/fpm/php-fpm.service  /usr/lib/systemd/system/php73-fpm.service

vim /usr/lib/systemd/system/php73-fpm.service

Description=The PHP FastCGI Process Manager
ExecStart=/usr/local/php7313/sbin/php-fpm --nodaemonize --fpm-config /usr/local/php7313/etc/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID
 systemctl daemon-reload
 ln -s /usr/local/php7313/sbin/php-fpm /usr/sbin/php73-fpm
 systemctl start php73-fpm

Install MongoDB Package

PECL is a repository for PHP Extensions, providing a directory of all known extensions and hosting facilities for downloading and development of PHP extensions.

 pecl73 install mongodb


Now add line on php.ini file. vim /usr/local/php7313/etc/php.ini
php73 -m | grep mongodb
systemctl restart php73-fpm

Install OCI8 Package

Visit below website and download two packages instantclient-basic and instantclient-devl according to your system architecture.

cd /usr/src
yum localinstall oracle-instantclient19.5-basic-
yum localinstall  oracle-instantclient19.5-devel-
pecl73 install oci8
( Type below mentioned path during installation. )



Now again add extension on php.ini file. vim /usr/local/php7313/etc/php.ini
systemctl restart php73-fpm

Install Nginx and Configure

yum install nginx

vim /etc/nginx/conf.d/

server {
    listen         80 default_server;
    listen         [::]:80 default_server;
    root           /var/www/;
    index          index.html;

  location ~* \.php$ {
    fastcgi_pass unix:/usr/local/php7313/var/run/php7313-fpm.sock;
    include         fastcgi_params;
    fastcgi_param   SCRIPT_FILENAME    $document_root$fastcgi_script_name;
    fastcgi_param   SCRIPT_NAME        $fastcgi_script_name;
mkdir -p /var/www/

vim /var/www/

nginx -t
systemctl restart nginx

Now check for the PHP Version and the installed Extension. They should be listed there.