Install PHP 5.4/5.5/5.6 and PHP 7 on CentOS

Sean78Black

Member
Joined
May 29, 2016
Messages
84
Points
8
To install, you need to use the extended storage of CentOS, it is EPEL and Remi repository.

Install EPEL repository

Code:
$ sudo yum install epel-release
If you can not use this command, you can install via RPM:

For CentOS 5:
Code:
$ wget http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
CentOS 6:
Code:
$ wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
CentOS 7:
Code:
$ wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
After you download the RPM file above, use the following command to install:

Code:
$ sudo rpm -Uvh epel-release*.rpm
Remi repository

Remi repository is the repository for PHP on CentOS installation support PHP version 5.4 / 5.5 / 5.6 and PHP 7.

For CentOS 5:
Code:
$ wget http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
CentOS 6:
Code:
$ wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
CentOS 7:
Code:
$ wget http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
After you download the RPM file above, use the following command to install:

Code:
$ sudo rpm -Uvh remi-release*.rpm
To select PHP version to install, you need to enable it in the repository Remi. Open and edit file /etc/yum.repos.d/remi.repo

Code:
$ sudo nano /etc/yum.repos.d/remi.repo
You can see in it parts such as: [remi] for PHP 5.4, [remi-php55] fori PHP 5.5 and [remi-php56] for 5.6. to enable the version you want to install, edit “enabled=0” to “enabled=1“.

Code:
[remi] # fori PHP 5.4
name=Les RPM de remi pour Enterprise Linux 6 - $basearch
#baseurl=http://rpms.famillecollet.com/enterprise/6/remi/$basearch/
mirrorlist=http://rpms.famillecollet.com/enterprise/6/remi/mirror
[B]enabled=1[/B]
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi

[remi-php55] # fori PHP 5.5
name=Les RPM de remi de PHP 5.5 pour Enterprise Linux 6 - $basearch
#baseurl=http://rpms.famillecollet.com/enterprise/6/php55/$basearch/
mirrorlist=http://rpms.famillecollet.com/enterprise/6/php55/mirror
# WARNING: If you enable this repository, you must also enable "remi"
[B]enabled=1[/B]
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi

[remi-php56] # fori PHP 5.6
name=Les RPM de remi de PHP 5.6 pour Enterprise Linux 6 - $basearch
#baseurl=http://rpms.famillecollet.com/enterprise/6/php56/$basearch/
mirrorlist=http://rpms.famillecollet.com/enterprise/6/php56/mirror
# WARNING: If you enable this repository, you must also enable "remi"
[B]enabled=1[/B]
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi
That's all, you can use yum to install PHP-FPM and some PHP functions as follows:
Code:
$ sudo yum install php-fpm php-mysql php-gd php-mbstring php-pear php-xml php-xmlrpc php-devel
To install PHP 7, use the following command:
Code:
$ sudo yum install php70
To update PHP to a newer version, use the following command:
Code:
$ sudo yum update
Ok, whether you're using CentOS 5, you can still use the new PHP version.

Good luck!
 
Older threads
Replies
8
Views
4,631
Replies
9
Views
3,377
Replies
0
Views
2,534
SIG
Latest threads
Replies
1
Views
9
Replies
0
Views
37
Replies
0
Views
37
Replies
1
Views
48
Replies
3
Views
112

Latest postsNew threads

Referral contests

Referral link for :

Sponsors

Popular tags

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top