Install or update PHP 5 on Centos

I tried compiling PHP 5.2 on CentOS but after so many tries I gave up. I was getting struck at compiling PHP with gd. And without gd it was useless. So I decided to yum and install the same.

By default if you use yum install php it will be install only php 4 series and not 5. In order to install version 5 I had to enable repo centosplus.

yum install php –enablerepo=centosplus

or

yum update php –enablerepo=centosplus

I came across another interesting repo for yum by kbsingh and after installing I was able to install a lot more. If you are interested please check out this website

http://centos.karan.org/

Have fun !! 😉

Published
Categorized as Linux

By Imthiaz

Programmer, SAAS, CMS & CRM framework designer, Love Linux & Apple products, Currently addicted to mobile development & working @bluebeetle

33 comments

  1. i keep getting this error: Excluding packages in global exclude list

    any one know why that is?

  2. BTW this as of November 2007 only PHP 5.1.6 is included in the centosplus repository, not PHP 5.2

  3. Thanks for the guide: I installed as per Joe said above, using the latest releases. Install seemed to go OK, but if I check phpinfo, it still says 5.1.6!
    Any ideas please?

  4. to Joe: why do you use ‘-enable-soap’ as the configure options? If you configure in this way, the upgrade will be really different as the CentOS 5’s default configure for php 5.1.6.

  5. Thanks for this, it worked and my PHP version is upgraded but it’s still 5.1 not 5.2.

    Any ideas how to get 5.2?

  6. If you want to get PHP-5.2 on CentOS-5, you really should be looking at using the php-5.2 hosted in the c5-testing repository at the moment ( those packages will get moved into the CentOS-5 Plus repo in the next few weeks ) – but for the time being look at http://wiki.centos.org/Repositories for info on howto get the c5-testing repo setup on your machine and use the php-5.2 from there.

    Hope this helps.

  7. Well i found the problem with Joe’s way
    php when you do make install moves all to /usr/local and httpd looks for php in /usr

  8. for the copy/pasters (like myself)

    there are two dashes (–) before eneablerepo=centosplus

    yum update php –enablerepo=centosplus

  9. @Brent: Do i need to uninstall the php that i installed by ‘Yum install php’? And which packages do I need to use the ‘make’ command?

  10. @Stephan If you want to compile PHP you might have to install gcc and all its dependencies

    yum install gcc gcc-c++ kernel-devel

    If you want to compile you don’t have to uninstall it. You can compile php to another custom location in configure

    ./configure –prefix=/usr/local/php5.2.8

  11. I have a Centos install that just keep giving “Error: Missing Dependency: php <= 4.4.0 is needed by package php-sqlite2” when i try to install ?? can anyone help me out ?

  12. I figured it out it was caused by my Plesk install which holds a different Mysql server package … reinstalled Plesk PHP en Mysql al together and it works 🙂

  13. Hello,

    I’m I have also re-compiled php and restarted the server. phpinfo still shows the old version??

    on the command line show the correct version though

    # php -v
    PHP 5.2.10 (cli) (built: Sep 14 2009 06:51:48)
    Copyright (c) 1997-2009 The PHP Group
    Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies

    anyone can help or shed some light pls.

    1. Hi pachimon,
      I too faced the same problem. command line shows it 5.2.4 while phpinfo() shows it as 5.2.9

      I restarted apache many times and also logged out and logged in. But no luck.

      were you able to fix it?

      Thanks
      Mike

  14. I used the method from http://www.atomicorp.com/wiki/index.php/PHP
    to upgrade my php on centOS 5 to php version 5.2.12, it seems working fine, but a lot of modules are missing (exactly 4 from the error warning):

    PHP Warning: PHP Startup: fileinfo: Unable to initialize module
    Module compiled with module API=20050922, debug=0, thread-safety=0
    PHP compiled with module API=20060613, debug=0, thread-safety=0
    These options need to match
    in Unknown on line 0

    [05-Feb-2010 11:12:14] PHP Warning: PHP Startup: mcrypt: Unable to initialize module
    Module compiled with module API=20050922, debug=0, thread-safety=0
    PHP compiled with module API=20060613, debug=0, thread-safety=0
    These options need to match
    in Unknown on line 0

    [05-Feb-2010 11:12:14] PHP Warning: PHP Startup: memcache: Unable to initialize module
    Module compiled with module API=20050922, debug=0, thread-safety=0
    PHP compiled with module API=20060613, debug=0, thread-safety=0
    These options need to match
    in Unknown on line 0

    [05-Feb-2010 11:12:14] PHP Warning: PHP Startup: mssql: Unable to initialize module
    Module compiled with module API=20050922, debug=0, thread-safety=0
    PHP compiled with module API=20060613, debug=0, thread-safety=0
    These options need to match
    in Unknown on line 0

Comments are closed.