Install PHP 7.4 on CWP Control Panel – Manual Installation Guide

In this tutorial we’ll install or upgrade php version to 7.4 under CWP control panel for php switcher (php selector and php-fpm selector can be done via forum request only), currently I’m pretty much impressed with php 7.4 performance out of the box with default values. One of the most exciting new features is preloading. It helps speed-up script execution as well as introducing the ability to have faster and cleaner code, thanks to the simplification of common lines of code.

This blog is running on wordpress + php 7.4 + nginx and I’ve found 10-15% of performance is increased like loading performance increase, post publishing is now faster and opcache is pretty much improved.

PHP 7.4 comes with a numerous amount of new features. It is recommended to check your script compatibility before upgrading. SO without wasting much time in reading let start with the upgrade steps :

CWP is now php 7.4 added install from there you can use this tutorial too for custom php install

Step 1 :

Building files which are required to compile php 7.4

Centos 7 :

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

Centos 8 :

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

Step 2 :

Configuring pkg-config path variables

run the below command :

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

Step 3 :

Downloading php 7.4 and installing it :

mkdir -p /usr/local/php-7-4
cd /usr/local/php-7-4
wget https://www.php.net/distributions/php-7.4.30.tar.gz
tar zxvf php-7.4.30.tar.gz
cd php-7.4.30

**current version can be down load here https://www.php.net/downloads download php-7.4.*.tar.gz

Run below configure command one by one for installing php 7.4 for PHP Switcher :

./configure --with-config-file-path=/usr/local/php --with-config-file-scan-dir=/usr/local/php/php.d --enable-fpm --enable-mbstring --with-zip --enable-bcmath --enable-pcntl --enable-ftp --enable-exif --enable-calendar --enable-sysvmsg --enable-sysvsem --enable-sysvshm --with-curl --with-iconv --with-gmp --with-pspell --enable-gd --with-freetype --with-jpeg --with-webp --with-zlib-dir --with-xpm --with-freetype --enable-gd-jis-conv --with-openssl --with-pdo-mysql=shared --with-gettext=/usr --with-zlib=/usr --with-bz2=/usr --with-mysqli --enable-soap --enable-intl --enable-phar --with-xsl --with-xmlrpc --with-kerberos --enable-posix --enable-sockets --with-external-pcre --enable-calendar --with-libdir=lib64 --with-libxml --with-password-argon2 --with-expat --with-mysql-sock=/var/lib/mysql/mysql.sock --with-imap --with-imap-ssl  
make && make install 

Step 4 :

Delete old ini php config :

 rm -rf /usr/local/php/php.d/*

Step 5 :

Check php Version :

php- v

eg output :

[root@mysterydata]# php -v
PHP 7.4.30 (cli) (built: June 09 2022 10:02:44) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies

Congrats !! If you see the php 7.4 there you’ve successfully installed php 7.4 on your server.

Use this forum to get support of the issues with php 7.4 installation: https://forum.mysterydata.com/topic/29/install-php-7-4-on-cwp

Back to top button