Install Php Using Source Code

To install PHP from source code, you can follow these general steps. Keep in mind that the exact commands and steps may vary depending on your operating system. Below, I'll provide a basic guide for a RPM-based CentOS, assuming you have the necessary development tools installed.

Download Source

We will get the download link of latest stable PHP source package from:

install Dependencies in Centos

  • sudo yum install epel-release -y

  • yum install autoconf libtool re2c bison libxml2-devel bzip2-devel libcurl-devel gcc libpng-devel libicu-devel gcc-c++ libmcrypt-devel libwebp-devel libjpeg-devel openssl-devel libxslt-devel make oniguruma-devel libsodium libsodium-devel libzip-devel.x86_64 -y

  • yum install -y libxml2-devel openssl-devel \

    sqlite-devel curl-devel libpng-devel \

    libwebp-devel libjpeg-devel freetype-devel

compile php

  • ./configure --prefix=/usr/local/php --with-freetype --disable-short-tags --enable-xml --enable-cli --with-openssl --with-pcre --with-pcre-jit --with-zlib --enable-bcmath --with-bz2 --with-curl --enable-exif --enable-gd --enable-intl --with-mysqli --enable-pcntl --with-pdo-mysql --enable-soap --enable-sockets --with-xmlrpc --with-zip --with-webp --with-jpeg --enable-png --enable-json --enable-hash --enable-mbstring --with-mcrypt --with-libxml --with-libxml --enable-ctype --enable-calendar --enable-dom --enable-fileinfo --with-mhash --enable-incov --enable-opcache --enable-phar --enable-simplexml --with-xsl --with-pear --with-sodium

  • make

  • make test

  • make install

  • echo 'export PATH="/usr/local/php/bin:$PATH"' >> ~/.bashrc

  • source ~/.bashrc

  • php --version

  • cp php.ini-production /usr/local/php/lib/php.ini