3

Whatever tutorial I follow, I end up with this error. Here is an example tutorial.

[jalal@goku ~]$ sudo yum install epel-release yum-utils
Package epel-release-7-11.noarch already installed and latest version
Package yum-utils-1.1.31-50.el7.noarch already installed and latest version
[jalal@goku ~]$ sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
Error: Nothing to do

system spec is:

$ uname -a
Linux goku.bu.edu 3.10.0-957.5.1.el7.x86_64 #1 SMP Fri Feb 1 14:54:57 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
$ lsb_release -a
LSB Version:    :core-4.1-amd64:core-4.1-noarch
Distributor ID: CentOS
Description:    CentOS Linux release 7.6.1810 (Core) 
Release:    7.6.1810
Codename:   Core

How should I install php 7.x on CentOS 7?

Also, if I ignore it and follow the commands below, (even though I have removed php5.x) it keeps installing php 5.x:

$ sudo yum-config-manager --enable remi-php73
[sudo] password for jalal: 
=============================== repo: remi-php73 ===============================
[remi-php73]
async = True
bandwidth = 0
base_persistdir = /var/lib/yum/repos/x86_64/7
baseurl = 
cache = 0
cachedir = /var/cache/yum/x86_64/7/remi-php73
check_config_file_age = True
compare_providers_priority = 80
cost = 1000
deltarpm_metadata_percentage = 100
deltarpm_percentage = 
enabled = 1
enablegroups = True
exclude = 
failovermethod = priority
ftp_disable_epsv = False
gpgcadir = /var/lib/yum/repos/x86_64/7/remi-php73/gpgcadir
gpgcakey = 
gpgcheck = True
gpgdir = /var/lib/yum/repos/x86_64/7/remi-php73/gpgdir
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi
hdrdir = /var/cache/yum/x86_64/7/remi-php73/headers
http_caching = all
includepkgs = 
ip_resolve = 
keepalive = True
keepcache = False
mddownloadpolicy = sqlite
mdpolicy = group:small
mediaid = 
metadata_expire = 21600
metadata_expire_filter = read-only:present
metalink = 
minrate = 0
mirrorlist = http://cdn.remirepo.net/enterprise/7/php73/mirror
mirrorlist_expire = 86400
name = Remi's PHP 7.3 RPM repository for Enterprise Linux 7 - x86_64
old_base_cache_dir = 
password = 
persistdir = /var/lib/yum/repos/x86_64/7/remi-php73
pkgdir = /var/cache/yum/x86_64/7/remi-php73/packages
priority = 99
proxy = False
proxy_dict = 
proxy_password = 
proxy_username = 
repo_gpgcheck = False
retries = 10
skip_if_unavailable = False
ssl_check_cert_permissions = True
sslcacert = 
sslclientcert = 
sslclientkey = 
sslverify = True
throttle = 0
timeout = 30.0
ui_id = remi-php73
ui_repoid_vars = releasever,
   basearch
username = 

$ sudo yum install php php-common php-opcache php-mcrypt php-cli php-gd php-curl php-mysqlnd
Package php-mcrypt is obsoleted by php-pecl-mcrypt, trying to install php-pecl-mcrypt-1.0.2-2.el7.remi.7.3.x86_64 instead
Error: Package: php-pecl-mcrypt-1.0.2-2.el7.remi.7.3.x86_64 (remi-php73)
           Requires: php(api) = 20180731-64
           Installing: php-common-5.4.16-46.el7.x86_64 (base)
               php(api) = 20100412-64
           Available: php55w-common-5.5.38-1.w7.x86_64 (webtatic)
               php(api) = 20121113-64
           Available: php56w-common-5.6.39-1.w7.x86_64 (webtatic)
               php(api) = 20131106-64
           Available: php56w-common-5.6.40-1.w7.x86_64 (webtatic)
               php(api) = 20131106-64
           Available: php70w-common-7.0.33-1.w7.x86_64 (webtatic)
               php(api) = 20151012-64
           Available: php71u-common-7.1.25-1.ius.centos7.x86_64 (ius)
               php(api) = 20160303-64
           Available: php71u-common-7.1.25-2.ius.centos7.x86_64 (ius)
               php(api) = 20160303-64
           Available: php71u-common-7.1.26-1.ius.centos7.x86_64 (ius)
               php(api) = 20160303-64
           Available: php71w-common-7.1.25-1.w7.x86_64 (webtatic)
               php(api) = 20160303-64
           Available: php71w-common-7.1.26-1.w7.x86_64 (webtatic)
               php(api) = 20160303-64
           Available: php72u-common-7.2.13-1.ius.centos7.x86_64 (ius)
               php(api) = 20170718-64
           Available: php72u-common-7.2.13-2.ius.centos7.x86_64 (ius)
               php(api) = 20170718-64
           Available: php72u-common-7.2.14-1.ius.centos7.x86_64 (ius)
               php(api) = 20170718-64
           Available: php72w-common-7.2.13-1.w7.x86_64 (webtatic)
               php(api) = 20170718-64
           Available: php72w-common-7.2.14-1.w7.x86_64 (webtatic)
               php(api) = 20170718-64
Error: Package: php-pecl-mcrypt-1.0.2-2.el7.remi.7.3.x86_64 (remi-php73)
           Requires: php(zend-abi) = 20180731-64
           Installing: php-common-5.4.16-46.el7.x86_64 (base)
               php(zend-abi) = 20100525-64
           Available: php55w-common-5.5.38-1.w7.x86_64 (webtatic)
               php(zend-abi) = 20121212-64
           Available: php56w-common-5.6.39-1.w7.x86_64 (webtatic)
               php(zend-abi) = 20131226-64
           Available: php56w-common-5.6.40-1.w7.x86_64 (webtatic)
               php(zend-abi) = 20131226-64
           Available: php70w-common-7.0.33-1.w7.x86_64 (webtatic)
               php(zend-abi) = 20151012-64
           Available: php71u-common-7.1.25-1.ius.centos7.x86_64 (ius)
               php(zend-abi) = 20160303-64
           Available: php71u-common-7.1.25-2.ius.centos7.x86_64 (ius)
               php(zend-abi) = 20160303-64
           Available: php71u-common-7.1.26-1.ius.centos7.x86_64 (ius)
               php(zend-abi) = 20160303-64
           Available: php71w-common-7.1.25-1.w7.x86_64 (webtatic)
               php(zend-abi) = 20160303-64
           Available: php71w-common-7.1.26-1.w7.x86_64 (webtatic)
               php(zend-abi) = 20160303-64
           Available: php72u-common-7.2.13-1.ius.centos7.x86_64 (ius)
               php(zend-abi) = 20170718-64
           Available: php72u-common-7.2.13-2.ius.centos7.x86_64 (ius)
               php(zend-abi) = 20170718-64
           Available: php72u-common-7.2.14-1.ius.centos7.x86_64 (ius)
               php(zend-abi) = 20170718-64
           Available: php72w-common-7.2.13-1.w7.x86_64 (webtatic)
               php(zend-abi) = 20170718-64
           Available: php72w-common-7.2.14-1.w7.x86_64 (webtatic)
               php(zend-abi) = 20170718-64
Error: Package: php-opcache-7.3.2-1.el7.remi.x86_64 (remi-php73)
           Requires: php-common(x86-64) = 7.3.2-1.el7.remi
           Installing: php-common-5.4.16-46.el7.x86_64 (base)
               php-common(x86-64) = 5.4.16-46.el7
           Available: php55w-common-5.5.38-1.w7.x86_64 (webtatic)
               php-common(x86-64) = 5.5.38-1.w7
           Available: php56w-common-5.6.39-1.w7.x86_64 (webtatic)
               php-common(x86-64) = 5.6.39-1.w7
           Available: php56w-common-5.6.40-1.w7.x86_64 (webtatic)
               php-common(x86-64) = 5.6.40-1.w7
           Available: php70w-common-7.0.33-1.w7.x86_64 (webtatic)
               php-common(x86-64) = 7.0.33-1.w7
           Available: php71u-common-7.1.25-1.ius.centos7.x86_64 (ius)
               php-common(x86-64) = 7.1.25-1.ius.centos7
           Available: php71u-common-7.1.25-2.ius.centos7.x86_64 (ius)
               php-common(x86-64) = 7.1.25-2.ius.centos7
           Available: php71u-common-7.1.26-1.ius.centos7.x86_64 (ius)
               php-common(x86-64) = 7.1.26-1.ius.centos7
           Available: php71w-common-7.1.25-1.w7.x86_64 (webtatic)
               php-common(x86-64) = 7.1.25-1.w7
           Available: php71w-common-7.1.26-1.w7.x86_64 (webtatic)
               php-common(x86-64) = 7.1.26-1.w7
           Available: php72u-common-7.2.13-1.ius.centos7.x86_64 (ius)
               php-common(x86-64) = 7.2.13-1.ius.centos7
           Available: php72u-common-7.2.13-2.ius.centos7.x86_64 (ius)
               php-common(x86-64) = 7.2.13-2.ius.centos7
           Available: php72u-common-7.2.14-1.ius.centos7.x86_64 (ius)
               php-common(x86-64) = 7.2.14-1.ius.centos7
           Available: php72w-common-7.2.13-1.w7.x86_64 (webtatic)
               php-common(x86-64) = 7.2.13-1.w7
           Available: php72w-common-7.2.14-1.w7.x86_64 (webtatic)
               php-common(x86-64) = 7.2.14-1.w7
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest
$ sudo yum install --skip-broken php php-common php-opcache php-mcrypt php-cli php-gd php-curl php-mysqlnd
Package php-mcrypt is obsoleted by php-pecl-mcrypt, trying to install php-pecl-mcrypt-1.0.2-2.el7.remi.7.3.x86_64 instead

Packages skipped because of dependency problems:
    libmcrypt-2.5.8-13.el7.x86_64 from epel
    php-opcache-7.3.2-1.el7.remi.x86_64 from remi-php73
    php-pecl-mcrypt-1.0.2-2.el7.remi.7.3.x86_64 from remi-php73

===============================================================================================================================================
 Package                             Arch                       Version                                   Repository                      Size
===============================================================================================================================================
Installing:
 php                                 x86_64                     5.4.16-46.el7                             base                           1.4 M
 php-cli                             x86_64                     5.4.16-46.el7                             base                           2.7 M
 php-common                          x86_64                     5.4.16-46.el7                             base                           565 k
 php-gd                              x86_64                     5.4.16-46.el7                             base                           128 k
 php-mysqlnd                         x86_64                     5.4.16-46.el7                             base                           174 k
Installing for dependencies:
 php-pdo                             x86_64                     5.4.16-46.el7                             base                            99 k
Skipped (dependency problems):
 libmcrypt                           x86_64                     2.5.8-13.el7                              epel                            99 k
 php-opcache                         x86_64                     7.3.2-1.el7.remi                          remi-php73                     304 k
 php-pecl-mcrypt                     x86_64                     1.0.2-2.el7.remi.7.3                      remi-php73                      29 k

Transaction Summary
===============================================================================================================================================
Install                        5 Packages (+1 Dependent package)
Skipped (dependency problems)  3 Packages

Is this ok [y/d/N]: y
$ php -v
PHP 5.4.16 (cli) (built: Oct 30 2018 19:30:51) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
Mona Jalal
  • 34,860
  • 64
  • 239
  • 408

3 Answers3

0

Firstly, you don't need the Remi repository on Centos to get PHP 7, currently (as in today) you do need it for PHP 7.3 though.

However, if you want to install PHP 7 EDIT 7.2 (which I recommend for production now) on Centos you can do so with the epel repository:

Fist check if you have the right repo(s) installed or not:

$ yum repolist | grep -e ius -e remi

If you don't already have one of those repos you will need to install it.

After that, it's just a matter of removing old PHP and installing PHP 7 (7.2 from IUS or 7.3 from remi):

$ yum remove php* -y
$ yum install php72u

EDIT

As per Remi's comment, php72u actually comes from IUS which I hadn't noticed! To get PHP 7.3 from the remi repository, you can either run yum update or:

$ yum install php php-cli php-fpm php-mysqlnd php-zip php-devel php-gd php-mcrypt php-mbstring php-curl php-xml php-pear php-bcmath php-json
Yes Barry
  • 9,514
  • 5
  • 50
  • 69
0

Installation Steps of PHP 7.x on RHEL 7 Server

1) Enable EPEL, RHEL 7 Server Optional repository and Install remirepo rpm

Login to your RHEL 7 Server and run the beneath commands one after the another to enable EPEL repository, install remirepo and enable RHEL 7 Server optional repository

[root@user~]# rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
[root@user ~]# wget http://rpms.remirepo.net/enterprise/remi-release-7.rpm
[root@user ~]# rpm -Uvh remi-release-7.rpm epel-release-latest-7.noarch.rpm
[root@user ~]# subscription-manager repos --enable=rhel-7-server-optional-rpms

2) Configure PHP 7.x repo

[root@user ~]# yum install yum-utils
[root@user ~]# yum-config-manager --enable remi-php72

3) Install PHP 7.2 and its dependencies

[root@user ~]# yum install php php-common php-opcache php-mcrypt php-cli php-gd php-curl php-mysql -y

4) Verify PHP Version

[root@user ~]# php -v

Please refer the below link for details , it gives you step by step procedure:

https://www.linuxtechi.com/install-php-7-centos-7-rhel-7-server/

Thanks

Sarath Kumar
  • 145
  • 8
0

Install versions of PHP in centos 7


7.1

7.2

7.3

7.4 or extensions

How do I change the default PHP base-version on shell?

Paulo Boaventura
  • 1,365
  • 1
  • 9
  • 29