As you may know the latest versions of the software packages are not available in the software repositories. It can take few months for any release upgrade to appear in the repository. Unfortunately in the real world the latest releases never appear in the official repositories of RHEL/CentOS Linux.
In my opinion it is extremely risky to install the packages that were pre-configured by someone else because such packages can contain back-doors or malware.
However you can always keep your PHP up to date using the package with the source code. There is nothing to be afraid of with such approach.
The following article describes the approach that can be used to compile the latest PHP using the source package.
I used fresh installation of the CentOS 6.7 to test this tutorial.
First of all make sure that your system has required packages:
There are multiple brunches currently supported by php.net. The latest is PHP v.7, latest stable is PHP v.5.6, Old Stable is PHP v.5.5. Other releases are considered as outdated and are no longer supported.
It is highly recommended to upgrade to
PHP v.5.6 if you are running
PHP v.5.3 and older versions.
The latest source codes of PHP can be downloaded by running one of the following commands:
The downloaded file should be uncompressed when done:
Next navigate to the source folder:
The next step is to configure the new PHP to make it ready for compilation.
The following huge and freaky configure command is the default for servers driven by Plesk panel, so I am going to use it to compile the most complete PHP:
I am using the following construction to capture the name of the current directory. It should be either
php-5.5.38. The aim of this tutorial is to unify the approach in compiling the PHP:
You don't need to change anything in this configure command no matter if you are installing PHP v.7 or v.5.6 or v.5.5.
The configure command from the about doesn't compile the
Apache2 module. This was done to prevent overwriting the existing php module if you will decide to compile php on the production server.
If you need to have it included into the php installation, than please include the '
--with-apxs2' into the list of configure arguments. Also make sure that
httpd-devel is installed.
The remaining steps are to make and install the php:
It is going to take a while to have it built and installed however at the end you will have the complete php installation located in the following folder:
The final output will look like the following:
Installing shared extensions: /usr/local/php-5.6.24/lib64/20131226/ Installing PHP CLI binary: /usr/local/php-5.6.24/bin/ Installing PHP CLI man page: /usr/share/man/man1/ Installing PHP CGI binary: /usr/local/php-5.6.24/bin/ Installing PHP CGI man page: /usr/share/man/man1/ Installing build environment: /usr/local/php-5.6.24/lib64/build/ Installing header files: /usr/local/php-5.6.24/include/php/ Installing helper programs: /usr/local/php-5.6.24/bin/ program: phpize program: php-config Installing man pages: /usr/share/man/man1/ page: phpize.1 page: php-config.1 /usr/local/src/php-5.6.24/build/shtool install -c ext/phar/phar.phar /usr/local/php-5.6.24/bin ln -s -f phar.phar /usr/local/php-5.6.24/bin/phar Installing PDO headers: /usr/local/php-5.6.24/include/php/ext/pdo/