CentosControl PanelCWP

Install PHP 8.1 Latest version in CWP control panel

In this tutorial we’ll install most awaited php version in CWP control panel as php switcher. This easy guide will guide you upon how to install PHP 8 easily.

PHP 8.1 comes with numerous improvements and new features such as:

  • – Enumerations
  • – Readonly properties
  • – Fibers
  • – Pure Intersection Types
  • – never return type
  • – First-class Callable Syntax
  • – “final” modifier for class constants
  • – New fsync and fdatasync functions
  • – New array_is_list function
  • – Explicit Octal numeral notatio

PHP 8.1 will not support your current php scripts/cms/themes. Check before shifting to php 8.1.

Step 1 :

Building files which are required to compile php 7.4

Centos 7/el7 :

yum install oniguruma oniguruma-devel gcc make gcc-c++ cpp kernel-headers.x86_64 libxml2-devel openssl-devel bzip2-devel libjpeg-devel libpng-devel freetype-devel openldap-devel postgresql-devel aspell-devel net-snmp-devel libxslt-devel libc-client-devel libicu-devel gmp-devel curl-devel libmcrypt-devel pcre-devel sqlite-devel db4-devel enchant-devel libXpm-devel mysql-devel readline-devel libedit-devel recode-devel libtidy-devel libtool-ltdl-devel libwebp libwebp-devel expat expat-devel  

Centos 8/stream/el8 :

yum install oniguruma oniguruma-devel gcc make gcc-c++ cpp kernel-headers.x86_64 libxml2-devel openssl-devel bzip2-devel libjpeg-devel libpng-devel freetype-devel openldap-devel postgresql-devel aspell-devel net-snmp-devel libxslt-devel libc-client-devel libicu-devel gmp-devel curl-devel libmcrypt-devel pcre-devel sqlite-devel libdb-devel enchant-devel libXpm-devel mysql-devel readline-devel libedit-devel recode-devel libtidy-devel libtool-ltdl-devel libwebp libwebp-devel expat expat-devel libmemcached libmemcached-devel  
Now we’ll build libzip and pcre2 :

Install EPEL :

yum install epel-release

Then install some more dependencies and remove the libzip package :
Centos 7 :

rpm -e --nodeps libzip libzip-devel
yum -y install cmake3 cmake zlib-devel --enablerepo=epel

Centos 8 :

rpm -e --nodeps libzip libzip-devel
yum install cmake zlib-devel
ln -s /usr/bin/cmake /usr/bin/cmake3

Installing Latest version Libzip from source :

cd /usr/local/src
rm -rf libzip*
wget https://libzip.org/download/libzip-1.5.1.tar.gz
tar zxvf libzip*
## for centos 7 :
cd libzip*
## for centos 8 :
cd libzip*/
mkdir build
cd build
/usr/bin/cmake3 ..
make && make install

Installing Latest version pcre2 from source :

cd /usr/local/src
rm -rf pcre2*
wget https://github.com/PhilipHazel/pcre2/releases/download/pcre2-10.39/pcre2-10.39.zip -O pcre2.zip  
unzip pcre2.zip
## for centos 7 :
cd pcre2-*
## for centos 8 :
cd pcre2-*/
./configure
make && make install

Install Latest libavif for new AVIF GD image support:

cd /usr/local/src
rm -rf master* libavif-master*
wget https://github.com/AOMediaCodec/libavif/archive/refs/heads/master.zip
unzip master.zip
cd libavif-master
mkdir build-dir
cd build-dir
#Run this if you've centos 7/el7:
cmake3 ..
#Run this if you've centos 8/stream/el8 or up:
cmake ..
make
make install

Step 2 :

Configuring pkg-config path variables

run the below command :

export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig

After you installed deps and exporting path variable continue to install php 8 with this steps :

mkdir -p /usr/local/php-81
cd /usr/local/php-81
wget http://php.net/distributions/php-8.1.9.tar.gz
tar zxvf php-8.1.9.tar.gz
cd php-8.1.9
./configure --with-config-file-path=/usr/local/php --enable-cgi --with-config-file-scan-dir=/usr/local/php/php.d --with-zlib=/usr --enable-mbstring --with-zip --enable-bcmath --enable-pcntl --enable-ftp --enable-exif --enable-calendar --enable-sysvmsg --enable-sysvsem --enable-sysvshm --with-tidy --with-curl --with-iconv --with-gmp --with-pspell --enable-gd --with-avif --with-jpeg --with-freetype --enable-gd-jis-conv --with-webp --with-zlib-dir=/usr --with-xpm --with-openssl --with-pdo-mysql=mysqlnd --with-gettext=/usr --with-bz2=/usr --with-mysqli --enable-soap --enable-phar --with-xsl --with-kerberos --enable-posix --enable-sockets --with-external-pcre --with-libdir=lib64 --with-mysql-sock=/var/lib/mysql/mysql.sock --enable-intl --with-password-argon2 --enable-litespeed --with-ldap=/usr --with-ldap-sasl=/usr  
make
make install

it will take some time depends on your server speed when it is finished you can check the php version via command :

php -v

eg :

# php -v
PHP 8.1.9 (cli) (built: Aug 04 2022 11:09:47) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.0-dev, Copyright (c) Zend Technologies

if you’ve any question comment below or for discussion go to our forum link : https://forum.mysterydata.com

Sandeep B.

I'm a system admin and php developer and currently working as System Admin In CWP Control panel, expertise in Linux and Windows administration RHEL certified admin.

Related Articles

19 Comments

  1. Everything is fine until installing Install Latest libavif for new AVIF GD image support.

    No comando cd libavif-master mostra o seguinte aviso: -bash: cd: libavif-master: No such file or directory

  2. And what happens if you have an alternative openssl (v 1.1.1) and not the provided with Centos 7? Compilation fails due to the new openssl version which is working fine with apache and nginx.

      1. Thanks @Sandeep but how do I know the right path to my updated openssl? I’ve already tried what you have said but without any success. It fails at the end when compiling the zend module opache (i’m talking from memory but I are almost sure that this was the module causing the problem). May be I was providing a wrong path for –with-openssl but not sure. That’s why I need to know the path to be sure that I’m doing it right.

      2. It shouln’t be like “–with-openssl –with-openssl-dir=/path/to/openssl”? You have used “–with-openssl=/path/to/openssl” and now I’m not sure about the right syntax.

        Anyway my doubt is about how to get the right path to be used with the param. I’ve tried “–with-openssl –with-openssl-dir=/usr/local/bin” but it doesn’t worked.

      3. I got this error:

        Generating phar.php
        /usr/bin/ld: warning: libssl.so.10, needed by /lib64/libssh2.so.1, may conflict with libssl.so.1.1
        /usr/bin/ld: warning: libcrypto.so.10, needed by /lib64/libssh2.so.1, may conflict with libcrypto.so.1.1

        /usr/local/src/php-build/php-8.0.23/ext/opcache/jit/zend_jit.c -o ext/opcache/jit/zend_jit.lo
        make: *** [Makefile:496: ext/phar/phar.php] Error 254

      4. I’ve solved problem with libssh2 by adding the ssh2 module to PHP build. But now I have problem with libldap so I believe that I should compile OpenLDAP from source, to get it to use the updated openssl. Problem is that I don’t know how to rebuild OpenLDAP. Can you help with it?

          1. Thanks. I’ve already tried that. Finally CWP compiled PHP 8 without problems but unfortunately it’s not already being installed and available into the selector. At the end it displayed problems with some messages like this one:

            shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory

            I’m not sure about what more can I try. Can’t get PHP updates since I installed updated openssl into Centos 7. Any other idea?

            Thanks in advance

          2. Why CWP’s PHP updates stop working after install a custom openssl? Can’t this be solved in CWP to allow newer openssl than the one bundled with Centos 7?

            I’ve also tried to upgrade to Centos 8 and Centos stream, but it fails completely.

          3. “it is not recommend to update the openssl in el OS it can break many things.”

            I know. But I’ve not replaced the bundled openssl in the OS, I’ve only compiled it from source and I’ve used it with apache and nginx without any problem. It’s with PHP where the problem comes. The same that I’ve used a custom path to compile nginx and apache it should be some way to do it with updated PHP, but however CWP php-fpm switcher fails in the compilation with messages I’ve previously posted here, with complains about getcwd parent directories.

          4. So, What could it be the solution to solve PHP updates in CWP if there is two openssl versions installed on system? There is not any way to force the use of one of them? I’ve compiled apache and nginx from source to use openssl 1.1.1 without any problem, so it should be the same for PHP, isn’t it?

            It could be very useful if you can publish a guide about this issue and how to solve it. Regards,

  3. checking for res_search… no
    checking for __res_search… yes
    checking whether strptime() declaration fails… yes
    checking whether arc4random_buf is declared… no
    checking for Argon2 support… yes
    checking for libargon2… no
    configure: error: Package requirements (libargon2) were not met:

    Package ‘libargon2’, required by ‘virtual:world’, not found

    Consider adjusting the PKG_CONFIG_PATH environment variable if you
    installed software in a non-standard prefix.

    Alternatively, you may set the environment variables ARGON2_CFLAGS
    and ARGON2_LIBS to avoid the need to call pkg-config.
    See the pkg-config man page for more details.
    [root@cp php-8.1.0]# make && make install
    make: *** No targets specified and no makefile found. Stop.
    [root@cp php-8.1.0]#

    can help me problem install php 8.10 sandeep

  4. Alternatively, you may set the environment variables ARGON2_CFLAGS
    and ARGON2_LIBS to avoid the need to call pkg-config.
    See the pkg-config man page for more details.
    [root@vze php-8.1.0]# make
    make: *** No targets specified and no makefile found. Stop.
    [root@vze php-8.1.0]# make install

  5. yum install oniguruma oniguruma-devel gcc make gcc-c++ cpp kernel-headers.x86_64 libxml2-devel openssl-devel bzip2-devel libjpeg-devel libpng-devel freetype-devel openldap-devel postgresql-devel aspell-devel net-snmp-devel libxslt-devel libc-client-devel libicu-devel gmp-devel curl-devel libmcrypt-devel pcre-devel sqlite-devel libdb-devel enchant-devel libXpm-devel mysql-devel readline-devel libedit-devel recode-devel libtidy-devel libtool-ltdl-devel libwebp libwebp-devel expat expat-devel libmemcached libmemcached-develsnmp-deve Last metadata expiration check: 0:00:49 ago on Mon 03 Jan 2022 01:19:07 PM CET.e No match for argument: oniguruma-devell enchant-devel libXpm-devel mysql-devel r No match for argument: aspell-develdevel libtidy-devel libtool-ltdl-devel libweb No match for argument: enchant-devel
    No match for argument: libedit-devel
    No match for argument: recode-devel
    Package expat-2.2.5-4.el8.x86_64 is already installed.
    No match for argument: libmemcached-devel
    Error: Unable to find a match: oniguruma-devel aspell-devel enchant-devel libedit-devel recode-devel libmemcached-devel

      1. yes, I know, but others don’t know, we have already had this topic (test it and only then publish it) beginners do not know as well as we do!

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button