Build and Install PHP 8.3 for CWP from Source on AlmaLinux 8


This article is based on Sandeep’s article at AlphaGNU.
Install and Build PHP 8.3 in CWP – Control WEB Panel from Source – CWP – Control WEB Panel – AlphaGNU

Sometimes that site gets overwhelmed, so we have a modified version below for AlmaLinux 8.x

At the writing of this article the current stable version of PHP 8.3 is 8.3.10.


INTRODUCTION

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.3 comes with numerous improvements and new features such as:

  • Typed Class Constants
  • Added json_validate function
  • Dynamic class constant and Enum member fetch support
  • class_alias() supports aliasing built-in PHP classes
  • New #[\Override] attribute
  • New stream_context_set_options function
  • PHP CLI Lint (php -l) supports linting multiple files at once
  • Fallback value support for PHP INI Environment Variable syntax
  • Random extension: New \Random\Randomizer::getFloat() and nextFloat() methods
  • Random extension: New \Random\Randomizer::getBytesFromString method
  • gc_status() returns additional GC information

PHP 8.3 may not support your current php scripts/cms/themes.
Check before shifting to PHP 8.3.
Latest version of WordPress works great with it also check the theme and plugin support by the devs.


READ ME FIRST

This article is provided as a courtesy.
Installing, configuring, and troubleshooting third-party applications is outside the scope of basic support provided by Starburst Services.

We are not liable for any damages and/or data loss.


REQUIRMENTS

  • SSH credentials or File Manager access Logged In as Root

STEP 1

Building files which are required to compile php 8.3:

dnf 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 libargon2 libargon2-devel

STEP 2

Now we’ll build libzip and pcre2.
Make sure you have EPEL installed:

dnf install epel-release

Then install some more dependencies and remove the libzip package:

rpm -e --nodeps libzip libzip-devel
dnf 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://github.com/mysterydata/md-disk/raw/main/libzip-1.10.0.tar.gz
tar zxvf libzip*
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/PCRE2Project/pcre2/releases/download/pcre2-10.44/pcre2-10.44.zip -O pcre2.zip  
unzip pcre2.zip
cd pcre2-*/
./configure
make && make install

Install Latest libavif for new AVIF GD image support:

cd /usr/local/src
rm -rf master* libavif-* build-dir
wget https://github.com/mysterydata/md-disk/raw/main/libavif-0.11.1.zip
unzip libavif-0.11.1
mkdir build-dir
cd build-dir
cmake ../libavif-0.11.1
make
make install

STEP 3

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:

rm -rf /usr/local/php-83
mkdir -p /usr/local/php-83
cd /usr/local/php-83
wget http://php.net/distributions/php-8.3.10.tar.gz
tar zxvf php-8.3.10.tar.gz
cd php-8.3.10
./configure --with-config-file-path=/usr/local/php --enable-cgi --with-config-file-scan-dir=/usr/local/php/php.d --with-zlib=/usr --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 --with-imap --with-imap-ssl --with-litespeed
make
make install
curl -s -L https://www.alphagnu.com/upload/mbstring.sh | bash

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

php -v

It should show, e.g.:

PHP 8.3.10 (cli) (built: Aug 27 2024 13:26:00) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.1, Copyright (c) Zend Technologies


Thanks for learning with Starburst Services.

Make sure to visit AlphaGNU at: https://www.alphagnu.com/

Learn more about our services


KB Article Written: 2024-08-27

people found this article helpful. What about you?