How to Install/build PHP 5.6/7.0/7.1/7.2 manually on CWP – Centos Web Panel

by Sandeep B.

In this tutorial we’ll cover php installation manually via commands on CWP server, it is pretty easy to build the php from source which will drastically increase the performance and stability. To build from source/manually you need to follow this tutorial step by step to achieve your desired php version installation. Best thing is you can add your own requirement flags for php extension to the configure option which by default not present in cwp php switcher.

PHP 7.3 installation tutorial : https://www.mysterydata.com/how-to-install-build-php-7-3-manually-on-cwp-centos-web-panel/

This tutorial is created upon request by our visitors.

Lets get started

Step 1

Install the dependencies :

yum -y install 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 icu libicu 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

Step 2

Installation of php 5.6/7.0/7.1/7.2 :

PHP 5.6

installation of php 5.6

rm -rf /usr/local/php-5-6
mkdir -p /usr/local/php-5-6
cd /usr/local/php-5-6
wget http://php.net/distributions/php-5.6.40.tar.gz
tar zxvf php-5.6.40.tar.gz
cd php-5.6.40
./configure --with-config-file-path=/usr/local/php --with-config-file-scan-dir=/usr/local/php/php.d --with-zlib --enable-soap --with-mysql-sock=/var/lib/mysql/mysql.sock --with-pspell --enable-wddx --with-tidy --enable-exif --enable-phar --enable-bcmath --enable-calendar --with-curl --with-iconv --with-mysql --with-mysqli --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-mcrypt --with-gettext --with-xsl --with-xmlrpc --with-pdo-mysql=mysqlnd --enable-posix --enable-ftp --with-openssl --enable-mbstring --with-kerberos --with-bz2 --enable-sockets --enable-zip --with-gd --with-jpeg-dir=/usr --with-freetype-dir=/usr --with-png-dir=/usr --enable-gd-native-ttf --with-pcre-regex --with-libdir=lib64 --enable-shmop --enable-intl --with-icu-dir=/usr --with-imap --with-imap-ssl --with-litespeed --with-pgsql=/usr/lib64/pgsql --with-pdo-pgsql 
make && make install

To enable FPM just use this config :

./configure --with-config-file-path=/usr/local/php --with-config-file-scan-dir=/usr/local/php/php.d --with-zlib --enable-soap --with-mysql-sock=/var/lib/mysql/mysql.sock --with-pspell --enable-wddx --with-tidy --enable-exif --enable-phar --enable-bcmath --enable-calendar --with-curl --with-iconv --with-mysql --with-mysqli --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-mcrypt --with-gettext --with-xsl --with-xmlrpc --with-pdo-mysql=mysqlnd --enable-posix --enable-ftp --with-openssl --enable-mbstring --with-kerberos --with-bz2 --enable-sockets --enable-zip --with-gd --with-jpeg-dir=/usr --with-freetype-dir=/usr --with-png-dir=/usr --enable-gd-native-ttf --with-pcre-regex --with-libdir=lib64 --enable-shmop --enable-intl --with-icu-dir=/usr --with-imap --with-imap-ssl --with-litespeed --with-pgsql=/usr/lib64/pgsql --with-pdo-pgsql --enable-fpm
make && make install

PHP 7.0

installation of php 7.0

rm -rf /usr/local/php-7-0
mkdir -p /usr/local/php-7-0
cd /usr/local/php-7-0
wget http://php.net/distributions/php-7.0.33.tar.gz
tar zxvf php-7.0.33.tar.gz
cd php-7.0.33
./configure --with-config-file-path=/usr/local/php --with-config-file-scan-dir=/usr/local/php/php.d --with-zlib=/usr --enable-mbstring --enable-zip --enable-bcmath --enable-pcntl --enable-ftp --enable-exif --enable-calendar --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx --with-tidy --with-curl --with-mcrypt --with-iconv --with-gmp --with-pspell --with-gd --with-jpeg-dir=/usr --with-freetype-dir=/usr --with-png-dir=/usr --enable-gd-native-ttf --enable-gd-jis-conv --with-zlib-dir=/usr --with-xpm-dir=/usr --with-openssl --with-pdo-mysql=/usr --with-gettext=/usr --with-bz2=/usr --with-mysqli --enable-soap --enable-phar --with-xsl --with-xmlrpc --with-kerberos --enable-posix --enable-sockets --with-pcre-regex --with-libdir=lib64 --with-mysql-sock=/var/lib/mysql/mysql.sock --enable-shmop --enable-intl --with-icu-dir=/usr --with-imap --with-imap-ssl --with-litespeed --with-pgsql=/usr/lib64/pgsql --with-pdo-pgsql 
make && make install

To enable FPM just use this config :

./configure --with-config-file-path=/usr/local/php --with-config-file-scan-dir=/usr/local/php/php.d --with-zlib=/usr --enable-mbstring --enable-zip --enable-bcmath --enable-pcntl --enable-ftp --enable-exif --enable-calendar --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx --with-tidy --with-curl --with-mcrypt --with-iconv --with-gmp --with-pspell --with-gd --with-jpeg-dir=/usr --with-freetype-dir=/usr --with-png-dir=/usr --enable-gd-native-ttf --enable-gd-jis-conv --with-zlib-dir=/usr --with-xpm-dir=/usr --with-openssl --with-pdo-mysql=/usr --with-gettext=/usr --with-bz2=/usr --with-mysqli --enable-soap --enable-phar --with-xsl --with-xmlrpc --with-kerberos --enable-posix --enable-sockets --with-pcre-regex --with-libdir=lib64 --with-mysql-sock=/var/lib/mysql/mysql.sock --enable-shmop --enable-intl --with-icu-dir=/usr --with-imap --with-imap-ssl --with-litespeed --with-pgsql=/usr/lib64/pgsql --with-pdo-pgsql --enable-fpm 
make && make install

PHP 7.1

installation of php 7.1

rm -rf /usr/local/php-7-1
mkdir -p /usr/local/php-7-1
cd /usr/local/php-7-1
wget http://php.net/distributions/php-7.1.33.tar.gz
tar zxvf php-7.1.33.tar.gz
cd php-7.1.33
./configure --with-config-file-path=/usr/local/php --with-config-file-scan-dir=/usr/local/php/php.d --with-zlib=/usr --enable-mbstring --enable-zip --enable-bcmath --enable-pcntl --enable-ftp --enable-exif --enable-calendar --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx --with-tidy --with-curl --with-mcrypt --with-iconv --with-gmp --with-pspell --with-gd --with-jpeg-dir=/usr --with-freetype-dir=/usr --with-png-dir=/usr --enable-gd-native-ttf --enable-gd-jis-conv --with-zlib-dir=/usr --with-xpm-dir=/usr --with-openssl --with-pdo-mysql=/usr --with-gettext=/usr --with-bz2=/usr --with-mysqli --enable-soap --enable-phar --with-xsl --with-xmlrpc --with-kerberos --enable-posix --enable-sockets --with-pcre-regex --with-libdir=lib64 --with-mysql-sock=/var/lib/mysql/mysql.sock --enable-shmop --enable-intl --with-icu-dir=/usr --with-imap --with-imap-ssl --with-litespeed --with-pgsql=/usr/lib64/pgsql --with-pdo-pgsql 
make && make install

To enable FPM just use this config :

./configure --with-config-file-path=/usr/local/php --with-config-file-scan-dir=/usr/local/php/php.d --with-zlib=/usr --enable-mbstring --enable-zip --enable-bcmath --enable-pcntl --enable-ftp --enable-exif --enable-calendar --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx --with-tidy --with-curl --with-mcrypt --with-iconv --with-gmp --with-pspell --with-gd --with-jpeg-dir=/usr --with-freetype-dir=/usr --with-png-dir=/usr --enable-gd-native-ttf --enable-gd-jis-conv --with-zlib-dir=/usr --with-xpm-dir=/usr --with-openssl --with-pdo-mysql=/usr --with-gettext=/usr --with-bz2=/usr --with-mysqli --enable-soap --enable-phar --with-xsl --with-xmlrpc --with-kerberos --enable-posix --enable-sockets --with-pcre-regex --with-libdir=lib64 --with-mysql-sock=/var/lib/mysql/mysql.sock --enable-shmop --enable-intl --with-icu-dir=/usr --with-imap --with-imap-ssl --with-litespeed --with-pgsql=/usr/lib64/pgsql --with-pdo-pgsql --enable-fpm 
make && make install

PHP 7.2

installation of php 7.2

rm -rf /usr/local/php-7-2
mkdir -p /usr/local/php-7-2
cd /usr/local/php-7-2
wget http://php.net/distributions/php-7.2.29.tar.gz
tar zxvf php-7.2.29.tar.gz
cd php-7.2.29
./configure --with-config-file-path=/usr/local/php --with-config-file-scan-dir=/usr/local/php/php.d --with-zlib=/usr --enable-mbstring --enable-zip --enable-bcmath --enable-pcntl --enable-ftp --enable-exif --enable-calendar --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx --with-tidy --with-curl --with-iconv --with-gmp --with-pspell --with-gd --with-jpeg-dir=/usr --with-freetype-dir=/usr --with-png-dir=/usr --enable-gd-jis-conv --with-zlib-dir=/usr --with-xpm-dir=/usr --with-openssl --with-pdo-mysql=/usr --with-gettext=/usr --with-bz2=/usr --with-mysqli --enable-soap --enable-phar --with-xsl --with-xmlrpc --with-kerberos --enable-posix --enable-sockets --with-pcre-regex --with-libdir=lib64 --with-mysql-sock=/var/lib/mysql/mysql.sock --enable-shmop --enable-intl --with-icu-dir=/usr --with-imap --with-imap-ssl --with-litespeed --with-pgsql=/usr/lib64/pgsql --with-pdo-pgsql 
make && make install

To enable FPM just use this config :

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

Step 3

Restart apache server and check php version via command :

service httpd restart
php -v

If this post helps you in any way please consider a donation

Donate with PayPal :

md-donate

You may also like

22 comments

David July 6, 2018 - 11:40 am

Many thanks for this valuable tutorial, works perfectly.

Reply
TN July 20, 2018 - 2:55 pm

Thank you so much. I have used a lot of your tutorials. I’ve bookmarked your website and keep coming back for more. Can you do a tutorial on how we can add memcached to php in “PHP Selector”? With PHP Switcher, we have the options to add all the extensions and so on but in PHP Selector we don’t have that option. I already installed memcached and redis with PHP Switcher but it doesn’t work for other PHP versions from the PHP Selector.

Reply
Sandy July 21, 2018 - 1:01 pm

Hello TN,
soon i’ll post the tutorial

Reply
TN July 21, 2018 - 2:22 pm

Thank you. I will be looking for it.

Reply
Jame August 3, 2018 - 10:17 am

To Uninstall any php version? which commandline?

Reply
Sandy August 3, 2018 - 10:28 am

Hello James,
the process will be automatic, it will be replaced by the php version which you’re installing

Reply
Abhijit August 14, 2018 - 6:45 am

No targets specified and no makefile found. Stop.

Reply
Sandy August 14, 2018 - 6:51 am

You’re doing wrong or missed some steps

Reply
Jack October 19, 2018 - 1:06 pm

Hi SANDY
Thank you for your great tutorial.
Update buttons in YUM manager are inactive in CWP ( they only available in Pro ).
Is possible update manually? if yes, how?

Reply
Sandy October 19, 2018 - 8:13 am

Just run this command
yum update

Reply
Jack November 3, 2018 - 12:43 pm

Thanks a lot
Works fine

Reply
Muhammad Farooq Zia December 28, 2018 - 9:07 pm

Can I follow similar steps for PHP 7.3.0? Please add the guide, thanks

Reply
Sandy December 29, 2018 - 1:09 pm

unfortunately the steps will work but you need some additional config, tutorial is releasing soon.

Reply
Sandy December 29, 2018 - 2:15 pm

How to Install/build PHP 7.3 manually on CWP – Centos Web Panel
https://www.mysterydata.com/how-to-install-build-php-7-3-manually-on-cwp-centos-web-panel/

Reply
Niraj May 14, 2019 - 5:06 am

Hi,
I tested cwp on ip (without making any account) and it was working. Now i created one account and trying to install wp. PHP is not working for new account/user. I tested two files. One php and html. html is working fine. Please suggest what to do. I tried everything on this blog and on cwp forum.

Thanks,

Reply
Sandy May 15, 2019 - 7:49 am

hi always check apache error logs, what is there ?

Reply
Toan December 29, 2019 - 10:10 am

Hello,
I follow this tutorial but i don’t see php-fpm work so can you help me how to it can work?
For now here is my php info: https://prnt.sc/qh35g1
Thanks!

Reply
Sandy January 1, 2020 - 11:01 am

hi for php-fpm selector you need to have pro license.

Reply
Toan February 4, 2020 - 12:58 pm

Hello, so we can not manual select php-fmp?
Thanks

Reply
Waheed August 16, 2020 - 10:10 pm

apache_get_modules() is not working in cwp7

Can you please help me?

Reply
Sandeep B. August 17, 2020 - 4:23 pm

you need to use this command in your php script :
/usr/local/apache/bin/apachectl -t -D DUMP_MODULES
or
/usr/local/apache/bin/httpd -t -D DUMP_MODULES

Reply

Leave a Comment