CentOS 7
Sponsored Link

Install PHP 7.32018/10/17

 
The version of PHP in CentOS 7 repository is 5.4 but Install 7.3 with RPM package if you need.
[1] It's possible to install from Remi's Repository.
It's OK to install it even if 5.4 is already installed because 7.3 is located on another PATH.
[root@dlp ~]#
yum --enablerepo=remi-safe -y install php73 php73-php-pear php73-php-mbstring
[2] PHP 7.3 is installed under the /opt directory and the link [/bin/php73] is created. If you'd like to access with [php], Load Environment variables like follows.
[root@dlp ~]#
php73 -v

PHP 7.3.0RC3 (cli) (built: Oct 9 2018 09:26:31) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.0-dev, Copyright (c) 1998-2018 Zend Technologies
[root@dlp ~]#
which php73

/bin/php73
[root@dlp ~]#
ll /bin/php73

lrwxrwxrwx. 1 root root 32 Oct 16 12:22 /bin/php73 -> /opt/remi/php73/root/usr/bin/php
# load environment variables with SCL tool

[root@dlp ~]#
scl enable php73 bash

[root@dlp ~]#
php -v

PHP 7.3.0RC3 (cli) (built: Oct 9 2018 09:26:31) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.0-dev, Copyright (c) 1998-2018 Zend Technologies
[3] If you'd like to enable PHP 7.3 automatically at login time, configure like follows.
[root@dlp ~]#
vi /etc/profile.d/php73.sh
# create new

source /opt/remi/php73/enable
export X_SCLS="`scl enable php73 'echo $X_SCLS'`"
[4] To use 7.3 on Apache httpd, Configure PHP-FPM like follows.
# install from Remi

[root@dlp ~]#
yum --enablerepo=remi-safe -y install php73-php-fpm
[root@dlp ~]#
vi /etc/httpd/conf.d/php.conf
# create new

<FilesMatch \.php$>
    SetHandler "proxy:fcgi://127.0.0.1:9000"
</FilesMatch>
AddType text/html .php
DirectoryIndex index.php
php_value session.save_handler "files"
php_value session.save_path    "/var/opt/remi/php73/lib/php/session"

[root@dlp ~]#
systemctl start php73-php-fpm

[root@dlp ~]#
systemctl enable php73-php-fpm

[root@dlp ~]#
systemctl restart httpd
# create phpinfo to verify working

[root@dlp ~]#
echo '<?php phpinfo(); ?>' > /var/www/html/info.php

[root@dlp ~]#
curl http://localhost/info.php | grep 'PHP Version' | tail -1 | sed -e 's/<[^>]*>//g'

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 65711    0 65711    0     0  2137k      0 --:--:-- --:--:-- --:--:-- 2212k
PHP Version 7.3.0RC3
[5] If you'd like to use 7.3 as embedded on Apache httpd, Configure like follows.
# install from Remi

[root@dlp ~]#
yum --enablerepo=remi-safe -y install php73-php
# rename and disable the old version if it exists

[root@dlp ~]#
mv /etc/httpd/conf.modules.d/10-php.conf /etc/httpd/conf.modules.d/10-php.conf.org

[root@dlp ~]#
systemctl restart httpd

# create phpinfo to verify working

[root@dlp ~]#
echo '<?php phpinfo(); ?>' > /var/www/html/info.php

[root@dlp ~]#
curl http://localhost/info.php | grep 'PHP Version' | tail -1 | sed -e 's/<[^>]*>//g'

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 69155    0 69155    0     0  1622k      0 --:--:-- --:--:-- --:--:-- 1688k
PHP Version 7.3.0RC3
Matched Content