Linux Administrator Miscellaneouss

PHP 5.4 Installation Steps On CentOS 6.x And Redhat 6.x System

PHP-5.4-installation
mm
Written by Santosh Prasad

PHP is the scripting language which is used to generate dynamic web page, PHP script contain HTML,Text and script blocks. Whenever any user request for a PHP page using browser than PHP script executed on web server and display the result in browser.

In this tutorial I am going to explain how we can install php 5.4 version on our centOSs system. Still RHEL and CentOS 6 ship PHP 5.3 version. We need third party repository to install PHP 5.4. There are lots of third-party repositories available that provide 5.4 version., In this tutorial I am going to use Software Collections (SCL) repository to accomplish this task.

INSTALLATION ON REDHAT 6.x

Follow the below steps to install PHP 5.4 version using Software Collections repository.Before going ahead  you will need to use Subscription Manager to enable Software Collections (SCL).

#subscription‐manager repos ‐‐enable rhel‐server‐rhscl‐6‐eus‐rpms

After enabling SCL install PHP 5.4 and its modules.

Installation

#yum install php54 php54‐php php54‐php‐gd php54‐php‐mbstring

You will get some output like below

Loaded plugins: fastestmirror, replace
Setting up Install Process
Loading mirror speeds from cached hostfile
* epel: mirror.steadfast.net
* remi-safe: ca.mirror.babylon.network
* webtatic: us-east.repo.webtatic.com
Resolving Dependencies
--> Running transaction check
---> Package php54.x86_64 0:2.0-1.el6 will be installed
--> Processing Dependency: php54-runtime for package: php54-2.0-1.el6.x86_64
--> Processing Dependency: php54-php-pear for package: php54-2.0-1.el6.x86_64
--> Processing Dependency: php54-php-common for package: php54-2.0-1.el6.x86_64
--> Processing Dependency: php54-php-cli for package: php54-2.0-1.el6.x86_64
---> Package php54-php.x86_64 0:5.4.40-4.el6 will be installed
---> Package php54-php-gd.x86_64 0:5.4.40-4.el6 will be installed
---> Package php54-php-mbstring.x86_64 0:5.4.40-4.el6 will be installed
--> Running transaction check
---> Package php54-php-cli.x86_64 0:5.4.40-4.el6 will be installed
---> Package php54-php-common.x86_64 0:5.4.40-4.el6 will be installed
---> Package php54-php-pear.noarch 1:1.9.4-10.sc1.el6 will be installed
--> Processing Dependency: php54-php-xml for package: 1:php54-php-pear-1.9.4-10. sc1.el6.noarch
--> Processing Dependency: php54-php-posix for package: 1:php54-php-pear-1.9.4-1 0.sc1.el6.noarch
---> Package php54-runtime.x86_64 0:2.0-1.el6 will be installed
--> Running transaction check
---> Package php54-php-process.x86_64 0:5.4.40-4.el6 will be installed
---> Package php54-php-xml.x86_64 0:5.4.40-4.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
php54 x86_64 2.0-1.el6 centos-sclo-rh 3.4 k
php54-php x86_64 5.4.40-4.el6 centos-sclo-rh 1.3 M
php54-php-gd x86_64 5.4.40-4.el6 centos-sclo-rh 119 k
php54-php-mbstring x86_64 5.4.40-4.el6 centos-sclo-rh 492 k
Installing for dependencies:
php54-php-cli x86_64 5.4.40-4.el6 centos-sclo-rh 2.6 M
php54-php-common x86_64 5.4.40-4.el6 centos-sclo-rh 595 k
php54-php-pear noarch 1:1.9.4-10.sc1.el6 centos-sclo-rh 370 k
php54-php-process x86_64 5.4.40-4.el6 centos-sclo-rh 48 k
php54-php-xml x86_64 5.4.40-4.el6 centos-sclo-rh 113 k
php54-runtime x86_64 2.0-1.el6 centos-sclo-rh 1.0 M

Transaction Summary
================================================================================
Install 10 Package(s)

Total download size: 6.7 M
Installed size: 20 M
Is this ok [y/N]: y
Downloading Packages:
(1/10): php54-2.0-1.el6.x86_64.rpm | 3.4 kB 00:00
(2/10): php54-php-5.4.40-4.el6.x86_64.rpm | 1.3 MB 00:00
(3/10): php54-php-cli-5.4.40-4.el6.x86_64.rpm | 2.6 MB 00:00
(4/10): php54-php-common-5.4.40-4.el6.x86_64.rpm | 595 kB 00:00
(5/10): php54-php-gd-5.4.40-4.el6.x86_64.rpm | 119 kB 00:00
(6/10): php54-php-mbstring-5.4.40-4.el6.x86_64.rpm | 492 kB 00:00
(7/10): php54-php-pear-1.9.4-10.sc1.el6.noarch.rpm | 370 kB 00:00
(8/10): php54-php-process-5.4.40-4.el6.x86_64.rpm | 48 kB 00:00
(9/10): php54-php-xml-5.4.40-4.el6.x86_64.rpm | 113 kB 00:00
(10/10): php54-runtime-2.0-1.el6.x86_64.rpm | 1.0 MB 00:00
--------------------------------------------------------------------------------
Total 6.7 MB/s | 6.7 MB 00:01
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : php54-runtime-2.0-1.el6.x86_64 1/10
Installing : php54-php-common-5.4.40-4.el6.x86_64 2/10
Installing : php54-php-cli-5.4.40-4.el6.x86_64 3/10
Installing : php54-php-process-5.4.40-4.el6.x86_64 4/10
Installing : php54-php-xml-5.4.40-4.el6.x86_64 5/10
Installing : 1:php54-php-pear-1.9.4-10.sc1.el6.noarch 6/10
Installing : php54-2.0-1.el6.x86_64 7/10
Installing : php54-php-5.4.40-4.el6.x86_64 8/10
Installing : php54-php-gd-5.4.40-4.el6.x86_64 9/10
Installing : php54-php-mbstring-5.4.40-4.el6.x86_64 10/10
Verifying : php54-php-5.4.40-4.el6.x86_64 1/10
Verifying : php54-runtime-2.0-1.el6.x86_64 2/10
Verifying : php54-php-process-5.4.40-4.el6.x86_64 3/10
Verifying : php54-php-gd-5.4.40-4.el6.x86_64 4/10
Verifying : php54-php-xml-5.4.40-4.el6.x86_64 5/10
Verifying : php54-php-mbstring-5.4.40-4.el6.x86_64 6/10
Verifying : 1:php54-php-pear-1.9.4-10.sc1.el6.noarch 7/10
Verifying : php54-php-cli-5.4.40-4.el6.x86_64 8/10
Verifying : php54-2.0-1.el6.x86_64 9/10
Verifying : php54-php-common-5.4.40-4.el6.x86_64 10/10

Installed:
php54.x86_64 0:2.0-1.el6 php54-php.x86_64 0:5.4.40-4.el6
php54-php-gd.x86_64 0:5.4.40-4.el6 php54-php-mbstring.x86_64 0:5.4.40-4.el6

Dependency Installed:
php54-php-cli.x86_64 0:5.4.40-4.el6
php54-php-common.x86_64 0:5.4.40-4.el6
php54-php-pear.noarch 1:1.9.4-10.sc1.el6
php54-php-process.x86_64 0:5.4.40-4.el6
php54-php-xml.x86_64 0:5.4.40-4.el6
php54-runtime.x86_64 0:2.0-1.el6

Complete!

Don’t forget to install PHP database module for your database.Follow the below command to install database module.

#yum install php54‐php‐mysqlnd

And after executing above command you will get some output like below.

Loaded plugins: fastestmirror, replace
Setting up Install Process
Loading mirror speeds from cached hostfile
* epel: mirror.steadfast.net
* remi-safe: ca.mirror.babylon.network
* webtatic: us-east.repo.webtatic.com
Resolving Dependencies
--> Running transaction check
---> Package php54-php-mysqlnd.x86_64 0:5.4.40-4.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
php54-php-mysqlnd x86_64 5.4.40-4.el6 centos-sclo-rh 1.8 M

Transaction Summary
================================================================================
Install 1 Package(s)

Total download size: 1.8 M
Installed size: 2.4 M
Is this ok [y/N]: y
Downloading Packages:
php54-php-mysqlnd-5.4.40-4.el6.x86_64.rpm | 1.8 MB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : php54-php-mysqlnd-5.4.40-4.el6.x86_64 1/1
Verifying : php54-php-mysqlnd-5.4.40-4.el6.x86_64 1/1

Installed:
php54-php-mysqlnd.x86_64 0:5.4.40-4.el6

Complete!

Note :- Please don’t forget to disable to load PHP 5.3 Apache Module.

#mv /etc/httpd/conf.d/php.conf /etc/httpd/conf.d/php53.disable

Now you can see default “php54.php.conf” in “/etc/httpd/conf.d/” location.Which help to load correct PHP 5.4 Module for Apache.

Now restart Apache.

#service httpd restart

Now verify the PHP version using below command.

#php -v

PHP 5.4.45 (cli) (built: Sep 19 2016 15:07:26)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
with blackfire v1.14.1~linux-x64-non_zts54, https://blackfire.io, by Blackfireio Inc.

INSTALLATION ON CENTOS 6.x

Follow the below steps to install php 5.4 version on CentOS 6.x.

First install the Software Collections Repository (SCL)

#yum install centos-release-SCL

You will get some output like below.

Loaded plugins: fastestmirror, replace
Setting up Install Process
Loading mirror speeds from cached hostfile
* epel: mirror.steadfast.net
* remi-safe: ca.mirror.babylon.network
* webtatic: us-east.repo.webtatic.com
Resolving Dependencies
--> Running transaction check
---> Package centos-release-scl-rh.noarch 0:2-3.el6.centos will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
centos-release-scl-rh noarch 2-3.el6.centos extras 12 k

Transaction Summary
================================================================================
Install 1 Package(s)

Total download size: 12 k
Installed size: 19 k
Is this ok [y/N]: y
Downloading Packages:
centos-release-scl-rh-2-3.el6.centos.noarch.rpm | 12 kB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : centos-release-scl-rh-2-3.el6.centos.noarch 1/1
Verifying : centos-release-scl-rh-2-3.el6.centos.noarch 1/1

Installed:
centos-release-scl-rh.noarch 0:2-3.el6.centos

Complete!

Than install PHP 5.4 with modules.

Installation PHP 5.4 with Modules

#yum install php54 php54-php php54-php-gd php54-php-mbstring

You will get some output like below.

Loaded plugins: fastestmirror, replace
Setting up Install Process
Loading mirror speeds from cached hostfile
* epel: mirror.steadfast.net
* remi-safe: ca.mirror.babylon.network
* webtatic: us-east.repo.webtatic.com
Resolving Dependencies
--> Running transaction check
---> Package php54.x86_64 0:2.0-1.el6 will be installed
--> Processing Dependency: php54-runtime for package: php54-2.0-1.el6.x86_64
--> Processing Dependency: php54-php-pear for package: php54-2.0-1.el6.x86_64
--> Processing Dependency: php54-php-common for package: php54-2.0-1.el6.x86_64
--> Processing Dependency: php54-php-cli for package: php54-2.0-1.el6.x86_64
---> Package php54-php.x86_64 0:5.4.40-4.el6 will be installed
---> Package php54-php-gd.x86_64 0:5.4.40-4.el6 will be installed
---> Package php54-php-mbstring.x86_64 0:5.4.40-4.el6 will be installed
--> Running transaction check
---> Package php54-php-cli.x86_64 0:5.4.40-4.el6 will be installed
---> Package php54-php-common.x86_64 0:5.4.40-4.el6 will be installed
---> Package php54-php-pear.noarch 1:1.9.4-10.sc1.el6 will be installed
--> Processing Dependency: php54-php-xml for package: 1:php54-php-pear-1.9.4-10. sc1.el6.noarch
--> Processing Dependency: php54-php-posix for package: 1:php54-php-pear-1.9.4-1 0.sc1.el6.noarch
---> Package php54-runtime.x86_64 0:2.0-1.el6 will be installed
--> Running transaction check
---> Package php54-php-process.x86_64 0:5.4.40-4.el6 will be installed
---> Package php54-php-xml.x86_64 0:5.4.40-4.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
php54 x86_64 2.0-1.el6 centos-sclo-rh 3.4 k
php54-php x86_64 5.4.40-4.el6 centos-sclo-rh 1.3 M
php54-php-gd x86_64 5.4.40-4.el6 centos-sclo-rh 119 k
php54-php-mbstring x86_64 5.4.40-4.el6 centos-sclo-rh 492 k
Installing for dependencies:
php54-php-cli x86_64 5.4.40-4.el6 centos-sclo-rh 2.6 M
php54-php-common x86_64 5.4.40-4.el6 centos-sclo-rh 595 k
php54-php-pear noarch 1:1.9.4-10.sc1.el6 centos-sclo-rh 370 k
php54-php-process x86_64 5.4.40-4.el6 centos-sclo-rh 48 k
php54-php-xml x86_64 5.4.40-4.el6 centos-sclo-rh 113 k
php54-runtime x86_64 2.0-1.el6 centos-sclo-rh 1.0 M

Transaction Summary
================================================================================
Install 10 Package(s)

Total download size: 6.7 M
Installed size: 20 M
Is this ok [y/N]: y
Downloading Packages:
(1/10): php54-2.0-1.el6.x86_64.rpm | 3.4 kB 00:00
(2/10): php54-php-5.4.40-4.el6.x86_64.rpm | 1.3 MB 00:00
(3/10): php54-php-cli-5.4.40-4.el6.x86_64.rpm | 2.6 MB 00:00
(4/10): php54-php-common-5.4.40-4.el6.x86_64.rpm | 595 kB 00:00
(5/10): php54-php-gd-5.4.40-4.el6.x86_64.rpm | 119 kB 00:00
(6/10): php54-php-mbstring-5.4.40-4.el6.x86_64.rpm | 492 kB 00:00
(7/10): php54-php-pear-1.9.4-10.sc1.el6.noarch.rpm | 370 kB 00:00
(8/10): php54-php-process-5.4.40-4.el6.x86_64.rpm | 48 kB 00:00
(9/10): php54-php-xml-5.4.40-4.el6.x86_64.rpm | 113 kB 00:00
(10/10): php54-runtime-2.0-1.el6.x86_64.rpm | 1.0 MB 00:00
--------------------------------------------------------------------------------
Total 6.7 MB/s | 6.7 MB 00:01
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : php54-runtime-2.0-1.el6.x86_64 1/10
Installing : php54-php-common-5.4.40-4.el6.x86_64 2/10
Installing : php54-php-cli-5.4.40-4.el6.x86_64 3/10
Installing : php54-php-process-5.4.40-4.el6.x86_64 4/10
Installing : php54-php-xml-5.4.40-4.el6.x86_64 5/10
Installing : 1:php54-php-pear-1.9.4-10.sc1.el6.noarch 6/10
Installing : php54-2.0-1.el6.x86_64 7/10
Installing : php54-php-5.4.40-4.el6.x86_64 8/10
Installing : php54-php-gd-5.4.40-4.el6.x86_64 9/10
Installing : php54-php-mbstring-5.4.40-4.el6.x86_64 10/10
Verifying : php54-php-5.4.40-4.el6.x86_64 1/10
Verifying : php54-runtime-2.0-1.el6.x86_64 2/10
Verifying : php54-php-process-5.4.40-4.el6.x86_64 3/10
Verifying : php54-php-gd-5.4.40-4.el6.x86_64 4/10
Verifying : php54-php-xml-5.4.40-4.el6.x86_64 5/10
Verifying : php54-php-mbstring-5.4.40-4.el6.x86_64 6/10
Verifying : 1:php54-php-pear-1.9.4-10.sc1.el6.noarch 7/10
Verifying : php54-php-cli-5.4.40-4.el6.x86_64 8/10
Verifying : php54-2.0-1.el6.x86_64 9/10
Verifying : php54-php-common-5.4.40-4.el6.x86_64 10/10

Installed:
php54.x86_64 0:2.0-1.el6 php54-php.x86_64 0:5.4.40-4.el6
php54-php-gd.x86_64 0:5.4.40-4.el6 php54-php-mbstring.x86_64 0:5.4.40-4.el6

Dependency Installed:
php54-php-cli.x86_64 0:5.4.40-4.el6
php54-php-common.x86_64 0:5.4.40-4.el6
php54-php-pear.noarch 1:1.9.4-10.sc1.el6
php54-php-process.x86_64 0:5.4.40-4.el6
php54-php-xml.x86_64 0:5.4.40-4.el6
php54-runtime.x86_64 0:2.0-1.el6

Complete!

Again don’t forget to install PHP database module for your database.Follow the below command to install database module.

# yum install php54-php-mysqlnd

You will get some output like below.

Loaded plugins: fastestmirror, replace
Setting up Install Process
Loading mirror speeds from cached hostfile
* epel: mirror.steadfast.net
* remi-safe: ca.mirror.babylon.network
* webtatic: us-east.repo.webtatic.com
Resolving Dependencies
--> Running transaction check
---> Package php54-php-mysqlnd.x86_64 0:5.4.40-4.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
php54-php-mysqlnd x86_64 5.4.40-4.el6 centos-sclo-rh 1.8 M

Transaction Summary
================================================================================
Install 1 Package(s)

Total download size: 1.8 M
Installed size: 2.4 M
Is this ok [y/N]: y
Downloading Packages:
php54-php-mysqlnd-5.4.40-4.el6.x86_64.rpm | 1.8 MB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : php54-php-mysqlnd-5.4.40-4.el6.x86_64 1/1
Verifying : php54-php-mysqlnd-5.4.40-4.el6.x86_64 1/1

Installed:
php54-php-mysqlnd.x86_64 0:5.4.40-4.el6

Complete!

Again don’t forget to disable to load PHP 5.3 Apache Module.

#mv /etc/httpd/conf.d/php.conf /etc/httpd/conf.d/php53.disable

Now you can see default “php54.php.conf” in “/etc/httpd/conf.d/” location.Which help to load correct PHP 5.4 Module for Apache.

Now it is time to Activate the PHP 5.4 version on your system

ACTIVATING PHP 5.4 VERSION ON SYSTEM

You will need to execute below command to activate PHP 5.4 on your system.

#source /opt/rh/php54/enable

Above command is used to make PHP 5.4 executable path its environment for current login user.

For all user you will need to add “source /opt/rh/php54/enable” line in “/etc/profile”

Now activate PHP 5.4 running below command.

#source /etc/profile

For Specific user you will need to add ” source /opt/rh/php54/enable ” line in user home ” .bash_profile ” file.

Now restart Apache.

#service httpd restart

 

Note :- PHP 5.4 package installed in ” /opt/rh/ ” directory.

Now you can verify PHP Version and its information using phpinfo.php page. Create a PHP info file with below text in web document root.

#cd /var/www/html/

#vim phpinfo.php

<?php

phpinfo();

?>

Save and execute.

Now open your browse and type below url to verify php 5.4 version like below. Please replace domain “www.example.com” with your domain and localhost name.

http://www.example.com/phpinfo.php

And you will get some result like below.

look-linux-phpinfo

I hope this article will be helpful to understand how we can install PHP 5.4 version on CentOS 6.x and Redhat 6.x system. If you have any queries and problem please comment in comment section or you can also ask your question.

Thanks:)

About the author

mm

Santosh Prasad

Hi! I'm Santosh and I'm here to post some cool article for you. If you have any query and suggestion please comment in comment section.

Leave a Comment