GNU/Linux >> Belajar Linux >  >> Cent OS

Instal / Tingkatkan ke PHP 7.1 di CentOS 7 / RHEL 7 menggunakan Remi RPM Repo

Beberapa hari yang lalu saya harus meningkatkan ke PHP 7.1 di server nixcp.com, ini adalah peningkatan besar karena saya menjalankan PHP 5.6.x.

Ini berada di bagian atas daftar tugas saya setelah saya membaca bahwa PHP 7.1 20% lebih cepat dari PHP 7.0 (dan kita semua tahu PHP 7.0 sekitar dua kali lebih cepat dari PHP 5.6.x), karena saya terobsesi dengan kecepatan web dan web kinerja, ini adalah kesempatan untuk menguji PHP 7.1 dan manfaatnya.

Instal PHP 7.1 di CentOS 7 Langkah demi Langkah

Setelah saya meneliti apakah semua aplikasi PHP saya kompatibel, saya memulai proses upgrade dari PHP 5.6.x ke PHP 7.1 pada CentOS 7.x 64 bit. Ini adalah prosedur yang saya gunakan di server saya.

Dapatkan daftar semua Paket PHP Anda saat ini, untuk berjaga-jaga:

rpm -qa | grep php

Seharusnya terlihat seperti ini:

[[email protected]:~]rpm -qa | grep php
php-common-5.6.30-1.el7.remi.x86_64
php-pear-1.10.3-1.el7.remi.noarch
php-pecl-memcache-3.0.8-4.el7.remi.5.6.x86_64
php-devel-5.6.30-1.el7.remi.x86_64
php-mysqlnd-5.6.30-1.el7.remi.x86_64
php-mcrypt-5.6.30-1.el7.remi.x86_64
php56-php-common-5.6.30-1.el7.remi.x86_64
php-cli-5.6.30-1.el7.remi.x86_64
php-pecl-jsonc-devel-1.3.10-2.el7.remi.5.6.x86_64
php-pecl-igbinary-2.0.1-1.el7.remi.5.6.x86_64
php-gd-5.6.30-1.el7.remi.x86_64
php-mbstring-5.6.30-1.el7.remi.x86_64
php56-runtime-2.1-5.el7.remi.x86_64
php56-php-pecl-msgpack-0.5.7-1.el7.remi.x86_64
php-5.6.30-1.el7.remi.x86_64
php-pecl-jsonc-1.3.10-2.el7.remi.5.6.x86_64
php-xml-5.6.30-1.el7.remi.x86_64
php-process-5.6.30-1.el7.remi.x86_64
php-xcache-3.2.0-1.el7.remi.5.6.x86_64
php-pecl-memcached-2.2.0-3.el7.remi.5.6.x86_64
php-soap-5.6.30-1.el7.remi.x86_64
php-opcache-5.6.30-1.el7.remi.x86_64
php56-php-pecl-jsonc-1.3.10-1.el7.remi.x86_64
php56-php-pecl-igbinary-2.0.1-1.el7.remi.x86_64
php-pdo-5.6.30-1.el7.remi.x86_64
php-fpm-5.6.30-1.el7.remi.x86_64
php56-php-pecl-zip-1.13.5-1.el7.remi.x86_64
php-pecl-zip-1.13.5-1.el7.remi.5.6.x86_64
php-pecl-msgpack-0.5.7-1.el7.remi.5.6.x86_64
php-xmlrpc-5.6.30-1.el7.remi.x86_64
[[email protected]:~]

Instal Remi Repo untuk CentOS 7.x

Saya sudah menginstal repo Remi, tetapi jika belum, Anda dapat melakukannya dengan menggunakan perintah ini:

wget http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
rpm -Uvh remi-release-7.rpm

Setelah itu, aktifkan paket PHP-71 dari repo Remi Anda, jalankan perintah ini:

yum-config-manager --enable remi-php71

Keluaran yang diharapkan:

[[email protected]:~]yum-config-manager --enable remi-php71
Loaded plugins: fastestmirror, langpacks
==== repo: remi-php71 =======
[remi-php71]
async = True
bandwidth = 0
base_persistdir = /var/lib/yum/repos/x86_64/7
baseurl =
cache = 0
cachedir = /var/cache/yum/x86_64/7/remi-php71
check_config_file_age = True
compare_providers_priority = 80
cost = 1000
deltarpm_metadata_percentage = 100
deltarpm_percentage =
enabled = True
enablegroups = True
...
...
...

Kemudian jalankan pembaruan yum:

yum update -y

Jika Anda tidak mengupgrade, dan hanya ingin menginstal PHP 7.1 di CentOS 7, jalankan saja:

yum install php php-devel php-gd php-mbstring php-mcrypt php-soap php-mysqlnd

Itu harus memperbarui semua paket PHP Anda saat ini ke PHP 7.1, seperti yang Anda lihat di bawah:

Jika Anda mendapatkan masalah ini:

You could try using --skip-broken to work around the problem
** Found 1 pre-existing rpmdb problem(s), 'yum check' output follows:
php-5.6.30-1.el7.remi.x86_64 has missing requires of httpd-mmn = ('0', '20120211x8664', None)

Ini dapat diperbaiki dengan menginstal paket httpd, yang tidak saya gunakan tetapi diperlukan:

yum install httpd -y

Setelah itu saya menonaktifkan httpd dari proses boot untuk memastikan tidak akan mencoba untuk boot bersama dengan Nginx dan menyebabkan konflik port 80:

systemctl disable httpd

Hapus Xcache, karena sejauh yang saya lihat tidak tersedia untuk PHP 7.1.x

yum remove php-xcache* -y

Jika Anda menyimpan Xcache, ini dapat menyebabkan kesalahan yum seperti yang Anda lihat di bawah:

--> Finished Dependency Resolution
Error: Package: 1:php-xcache-3.2.0-1.el7.remi.5.6.x86_64 (@remi-php56)
Requires: php(zend-abi) = 20131226-64
Removing: php-common-5.6.30-1.el7.remi.x86_64 (@remi-php56)
php(zend-abi) = 20131226-64
Updated By: php-common-7.1.3-1.el7.remi.x86_64 (remi-php71)
php(zend-abi) = 20160303-64
Available: php-common-5.4.16-42.el7.x86_64 (base)
php(zend-abi) = 20100525-64
Available: php-common-5.6.29-1.el7.remi.x86_64 (remi-php56)
php(zend-abi) = 20131226-64
Available: php-common-7.1.2-1.el7.remi.x86_64 (remi-php71)
php(zend-abi) = 20160303-64
Error: Package: 1:php-xcache-3.2.0-1.el7.remi.5.6.x86_64 (@remi-php56)
Requires: php(api) = 20131106-64
Removing: php-common-5.6.30-1.el7.remi.x86_64 (@remi-php56)
php(api) = 20131106-64
Updated By: php-common-7.1.3-1.el7.remi.x86_64 (remi-php71)
php(api) = 20160303-64
Available: php-common-5.4.16-42.el7.x86_64 (base)
php(api) = 20100412-64
Available: php-common-5.6.29-1.el7.remi.x86_64 (remi-php56)
php(api) = 20131106-64
Available: php-common-7.1.2-1.el7.remi.x86_64 (remi-php71)
php(api) = 20160303-64
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest

Satu hal yang saya perhatikan:beberapa paket masih dari versi PHP 5.6:

[[email protected]:~]rpm -qa | grep php56
php56-php-common-5.6.30-1.el7.remi.x86_64
php56-runtime-2.1-5.el7.remi.x86_64
php56-php-pecl-msgpack-0.5.7-1.el7.remi.x86_64
php56-php-pecl-jsonc-1.3.10-1.el7.remi.x86_64
php56-php-pecl-igbinary-2.0.1-1.el7.remi.x86_64
php56-php-pecl-zip-1.13.5-1.el7.remi.x86_64

Hapus itu dan instal versi 7.1 dari Remi:

yum remove php56*
yum install yum install php71-php-common php71-runtime php71-php-pecl-msgpack php71-php-pecl-jsonc php71-php-pecl-igbinary php71-php-pecl-zip

Dan upgrade dari PHP 5.6 ke PHP 7.1 selesai.

Terakhir, pastikan Anda memulai ulang http dan php-fpm untuk menerapkan perubahan:

systemctl restart nginx
systemctl restart php-fpm

Itu saja, sekarang Anda tahu cara meningkatkan atau menginstal PHP 7.1 di CentOS 7. Beri tahu saya jika Anda memiliki pertanyaan atau masalah setelah mengikuti tutorial ini.

Instal / Tingkatkan ke PHP 7.1 di CentOS 7 / RHEL 7 menggunakan Remi RPM Repo terakhir diubah:5 April 2017 oleh Esteban Borges
Cent OS
  1. Instal PHP 7.4 di CentOS 8

  2. [Linux]:Cara meningkatkan paksa php dari 5.1.6 ke 5.3.3 menggunakan yum di CentOS/Fedora/RHEL

  3. Tingkatkan PHP 5.3 ke PHP 7.0 menggunakan yum di CentOS/RHEL/Fedora

  1. Cara menginstal atau meningkatkan ke PHP 7 di CentOS 7 Linux Server

  2. Instal PHP Mcrypt di CentOS 6 VPS

  3. Cara Menginstal PHP 7.4 / 7.3 / 7.2 di CentOS 7 / RHEL 7 &CentOS 6 / RHEL 6

  1. Cara Menginstal Xdebug di RHEL 8 / CentOS 8 Linux

  2. Cara Menginstal PHP 7.4 / 7.3 Pada CentOS 8 / RHEL 8

  3. Cara Menginstal PHP 7.3, 7.2, 7.1 di CentOS/RHEL 6.10