Install PHP 7.2 on CentOS from yum
First you need to install Remi repository
Enable epel repo with
1 |
yum install epel-release -y |
On CentOS 7
1 |
rpm -ivh https://rpms.remirepo.net/enterprise/remi-release-7.rpm |
On CentOS 6
1 |
rpm -ivh https://rpms.remirepo.net/enterprise/remi-release-6.rpm |
Enable PHP 7.2
1 2 |
yum install yum-utils yum-config-manager --enable remi-php72 |
To install PHP, run
1 2 3 |
yum install -y php php-bcmath php-cli php-common php-devel php-gd \ php-imap php-intl php-json php-ldap php-lz4 php-mbstring php-mysqlnd \ php-soap php-intl php-opcache php-xml php-pdo |
Downgrading PHP version
if you ever want to change PHP version, lets say PHP 7.0, do the following. Remove current PHP
1 |
rpm -qa | grep php | xargs yum remove -y |
Disable PHP 7.2 repo.
1 |
yum-config-manager --disable remi-php72 |
Enable PHP 7.0 repo
1 |
yum-config-manager --enable remi-php70 |
Now install PHP as above.
PHp Binary
PHP cli will be installed in /usr/bin/php72, you can create a symlink if you want.
PHP-FPM
To install php-fpm module, run
1 |
yum install php72-php-fpm -y |
To start php-fpm, run
1 |
systemctl start php72-php-fpm |