Compile PHP7.4 on Centos6

There are reasons, when you need to compile PHP yourself. I would personally always prefer that way, as it lets you have more control and it is also more fun. It is like doing VOR approach, instead of ILS II. 🙂

Anyway, over time it might get challenging to compile new source code on pretty old OS.

It is 2021 and Centos6 has reached end-of-lifetime on November 30, 2020, but we still run it on several old servers and customers are not going to upgrade soon. Let’s look at simple compilation steps, that allow us install PHP7.4 on Centos6 in 2021.

Enable old Centos repositories

In case you will miss system packages – you will need to install/enable repository with old RPM (latest) packages. There are 2 simple commands (source files are at the bottom of this article in case they disappear from

curl --output /etc/yum.repos.d/CentOS-Base.repo
curl --output /etc/yum.repos.d/epel.repo

Installing required packages

yum -y install libtidy libtidy-devel systemd-devel libxml2 libxml2-devel curl libcurl libcurl-devel libicu libicu-devel bison flex git autoconf unzip

Manually install Oniguruma and SQLite

For some reason these 2 packages were giving me issues with PHP7.4 due to version incompatibility. I was able to install PHP7.2 without them, but PHP7.4 forced me for manual compilation.


Located at GitHub:

Please pay attention to configuration parameters – we are installing Oniguruma in /usr with libraries in /usr/lib64.

git clone
cd oniguruma
autoreconf -vfi
./configure --prefix=/usr --libdir=/usr/lib64
make && make install


There is SQLite precompiled package for Centos6, but PHP7.4 will complain about its version and that’s why we are installing latest version manually. Download source code (note: select version with  *-autoconf-*) from Again – please pay attention to configuration parameters, do not forget them!

tar -zxf sqlite-autoconf-3340100.tar.gz
cd sqlite-autoconf-3340100
./configure --prefix=/usr --libdir=/usr/lib64

Installing PHP

Download PHP source code from here:
Link to PHP archive might be different, please always use latest version, as link in commands is here for reference only.

tar -zxf php-7.4.15.tar.gz
cd php-7.4.15
'./configure' '--enable-bcmath' '--enable-calendar' '--enable-exif' \
'--enable-ftp' '--enable-mbstring' '--enable-soap' '--enable-sockets' \
'--prefix=/opt/php-7.4' '--with-curl' '--enable-gd=/opt/gd-2.1.0' \
'--with-gettext' '--enable-pdo' '--with-openssl=/opt/openssl-1.1.1' \
'--with-zlib' '--disable-posix' '--enable-mysqlnd' '--with-pdo-mysql=mysqlnd' \
'--with-mysqli=/usr/local/mysql/bin/mysql_config' '--enable-opcache=yes' \
'--with-libdir=lib64' 'OPENSSL_CFLAGS=-I/opt/openssl-1.1.1/include' \
'OPENSSL_LIBS=-L/opt/openssl-1.1.1/lib64 -lssl -lcrypto'
make && make install

Important note. PHP cofiguration options are for illustation only – you might want to adjust your prefix, where you install it, path to GD library and GD library version, path to your OpenSSL version and MySQL installation. You might also want to compile other extensions and modules and therefore please always refer to PHP’s list of available options:

./configure --help


Wish you good luck, hope it helps and if you have questions or comments, please feel free to contact me!