2

I recently installed PHP54 on a RHEL 6.5 server from the RHN Software Collection 1.1 The package has successfully been installed, and it needs to be mentioned there is an existing previous installed PHP version (5.3.3) on the servers which is the current enabled version.

I have checked several sites/forums/blogs and the suggestions are always the same, enable via scl (Setup and run software from Software Collection environment) and/or sourcing the file "/opt/rh/php54/enable". This seems to be a proper workaround to enable PHP54 as can be seen in the commands below.

But it is not permanent, as soon as I exit the shell the user who enabled PHP the changes are discarded. NOTE: the commands has been run as "root" with the exact same behaviour shown in the following commands.

I've found references to add the source workaround into the ".bash_profile" of the user(s), but does not seems to be the best solution for me, I am wondering if someone else have already faced this problem and how it was solved.

Any suggestions?

[mithrandir@mordor ~]# scl enable php54 "php -v"
PHP 5.4.16 (cli) (built: Feb  4 2014 08:10:51)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies


[mithrandir@mordor ~]# php -v
PHP 5.3.3 (cli) (built: Jul 15 2014 08:48:08)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies


[mithrandir@mordor ~]# source /opt/rh/php54/enable
[mithrandir@mordor ~]# php -v
PHP 5.4.16 (cli) (built: Feb  4 2014 08:10:51)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies


[mithrandir@mordor ~]# date
Fri Aug 29 12:29:35 MDT 2014

[mithrandir@mordor ~]# exit
logout

[me@mordor ~]$ sudo su -
[sudo] password for me:

[mithrandir@mordor ~]# php -v
PHP 5.3.3 (cli) (built: Jul 15 2014 08:48:08)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies

[mithrandir@mordor ~]# date
Fri Aug 29 12:29:57 MDT 2014
Cyrus
  • 84,225
  • 14
  • 89
  • 153
3LRusS1T0
  • 51
  • 1
  • 6

3 Answers3

3

It seems that in order to enable a package from the RH Software Collection the only way is by adding a script under "/etc/profile.d" and including the "source /opt/rh/php54/enable" command.

This is a link to RH devs blog, showing the solution. Be aware that it is for python33 but this workaround applies for software included on RHSC such as PHP54.

Permanently Enable a Software Collection

I implemented the solution and it is working. I hope this helps someone else.

3LRusS1T0
  • 51
  • 1
  • 6
1

Open a command shell window and check the PHP rpm package which is installed.

# rpm -qa | grep php

There should be an Apache php module. You need to download a rpm file which adds PHP to your Apache web server. Use the website http://blog.famillecollet.com/post/2013/06/16/Red-Hat-will-provide-PHP-5.4-for-RHEL-6. Here you find the hints how to permanently install PHP 5.4.:

# source /opt/rh/php54/enable
# php -v
PHP 5.4.14 (cli) (built: May 23 2013 07:42:19) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
Franz Holzinger
  • 913
  • 10
  • 20
  • Sorry @Franz Holzinger this is not the problem, PHP54 was installed successfully: [me@mordor ~]$ rpm -qa | grep php54 php54-1.1-5.el6.x86_64 php54-php-common-5.4.16-16.el6.x86_64 php54-runtime-1.1-5.el6.x86_64 php54-php-process-5.4.16-16.el6.x86_64 php54-php-xml-5.4.16-16.el6.x86_64 php54-php-cli-5.4.16-16.el6.x86_64 php54-php-pear-1.9.4-10.el6.noarch My problem is to have it enabled permanently but I guess I found the answer on RedHat devs blogs [link](http://developerblog.redhat.com/2014/03/19/permanently-enable-a-software-collection/) will update the post shortly. – 3LRusS1T0 Aug 29 '14 at 20:39
  • So then PHP 5.4 is there permanently. Isn't this that what you wanted to have? – Franz Holzinger Aug 29 '14 at 21:08
  • I needed it permanently **enabled** on the server. It seems that the only way is by adding a script under "/etc/profile.d" and including the "source /opt/rh/php54/enable" command. – 3LRusS1T0 Aug 29 '14 at 22:34
  • However your output of "rpm -qa | grep php" comes only for your session after you have activated PHP 5.4 already. Maybe you do not need the former php 5.3 on the server any more? If so, then you could replace the PHP 5.3 completely by PHP 5.4. I have found this. [link](http://www.tecmint.com/install-apache-mysql-php-on-redhat-centos-fedora/) ## Installing on RHEL ## # yum --enablerepo=remi,remi-test install php-mysql php-pgsql php-pecl-mongo php-sqlite php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml php-pecl-apc php-cli php-pear php-pdo – Franz Holzinger Aug 30 '14 at 07:43
-1

If you want PHP 5.4 permanently enabled and your /etc/conf.d/ directory has the conf file for PHP 5.4 (possibly php54-php.conf) in it, you can comment out the lines in /etc/conf.d/php.conf that load the PHP 5.3 modules:

<IfModule prefork.c>
  LoadModule php5_module modules/libphp5.so
</IfModule>
<IfModule worker.c>
  LoadModule php5_module modules/libphp5-zts.so
</IfModule>

You can also delete /etc/conf.d/php.conf or rename the file to remove the .conf extension so that it isn't loaded by /etc/conf/httpd.conf. After doing either of these, restart Apache to load PHP 5.4.

Ryan
  • 659
  • 7
  • 13
  • The original question didn't ask anything about Apache. Your answer doesn't apply to PHP on the CLI or with other web server set ups (e.g., PHP-FPM). – Scott Buchanan Mar 03 '15 at 22:12