How to compile PHP-7.2 on CentOS

Español English

PHP

On November 30, 2017 the PHP development team released the PHP 7.2 version, this release added news features, here some of them:

  • New object type: Previously the object statement was used to convert one data type to another one e.g. an array to an sdtClass object and/or vice versa, PHP 7.2 introduces the object data type which can be used to specify the type of parameter and/or for the type of a function return.
  • Extension loading by name: Now it is not necessary to specify the file extension (.so for Unix, .dll for Windows) when loading an extension allowing greater portability in the php configuration file (php.ini).
  • Abstract method overriding: Now an abstract class that inherits from another abstract class can change/overwrite an abstract method of its parent class.
  • Sodium is now a core extension: Sodium is a modern and easy to use encyption library that allows encryption/decryption, signatures, password hashing and more… now the extension is part of the PHP core.
  • Parameter type widening : Now a child class can omit the parameter type when overwrite or implement a method from the parent class or interface respectively.

Goals

  • Update to the latest version of PHP
  • Get benefits from the latest language features
  • Correct errors from previous versions
  • Customize the installation process

Prerequisites

This tutorial assumes that:

  • You have some knowledge about GNU/Linux
  • You have CentOS GNU/Linux installed
  • You are familiar with the command interpreter
  • You are familiar with the compilation process

Compile/Install

To compile/install PHP we’re going to use the butterfly builder

Download

You can download butterfly builder from github or typing:

$ curl -# -L -O https://github.com/yoander/pbt/archive/master.zip

Unzip

$ unzip master.zip

If the unzip command is not found you can install it, executing:

# yum -y install unzip

Cambiar al DIR pbt-master

$ cd pbt-master

The PHP available version at the time of writing this tutorial is 7.2.32. Set the settings through the pbt.init file according to your needs.

php_version=7.2.6
compression=tar.xz
php_mode=fpm
fpm_user=phpfpm
fpm_group=phpfpm
fpm_listen=9000
web_server=nginx
install_prefix=/usr/
sysinit=systemd
sysinit_versioned=true
databases="mysql sqlite"
php_env=dev

Give execution permissions.

$ chmod a+x pbt

Compilar/Instalar

./pbt

After the build, compilation and install process finish, you can get PHP information typing in your browser http://IP/info.php

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.