Update PHP 5.2 and MySQL 5.0 to PHP 5.3.8 and MySQL 5.5.15 on CentOS 5.5

| 27 Comments

To upgrade PHP and mysql on CentOS we cannot rely on the ‘yum update’ command as CentOS default repositories don’t provide versions above PHP 5.2 and MySQL 5.0.77. So we will have to rely on alternative repositories. For this purpose we will downloaded and installed the EPEL and REMI repositories. I have personally been forced to perform the upgrade on my servers due to the fact that moodle 2.1 (LMS) requires PHP 5.3.2 to operate.

What is EPEL

EPEL stand for Extra Packages for Enterprise Linux. EPEL is a Fedora Special Interest Group that creates, maintains, and manages a high quality set of additional packages for Enterprise Linux, including, but not limited to, Red Hat Enterprise Linux (RHEL), CentOS and Scientific Linux (SL).

EPEL packages are usually based on their Fedora counterparts and will never conflict with or replace packages in the base Enterprise Linux distributions. EPEL uses much of the same infrastructure as Fedora, including buildsystem, bugzilla instance, updates manager, mirror manager and more.

What is REMI

This is a repository created by Remi Collet with the aim to give support for old Fedora releases to allow them to install recent software, also it gives you the ability to have your CentOS/RHEL systems with the latest software available in the net.

Installing EPEL and REMI Repositories

download EPEL

wget http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm

or for 64 Bit server

wget http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm

download REMI

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

install REMI and EPEL

rpm -Uvh remi-release-5*.rpm epel-release-5*.rpm

At this point if you attempt an ‘yum update’ for PHP or MySQL you will either be informed that there are no updates available or that no updates were made due to priority issues. So now we will set prorities for repositorys.

Now open ‘priorities.conf’ for editing (I use ‘nano’ to edit file. You can use ‘vi’ or any other command that you ae familiar with)

nano /etc/yum/pluginconf.d/priorities.conf

and make sure its content reads as follows

[main]
enabled=1

If this file is missing they you have to install yum priorities

yum install yum-priorities

Excluding CentOS repositories from updating PHP, MySQL

To prevent default CentOS respositories from handeling php and mysql updates we need to exclude them for those specific updates. Make the followign edits to CentOS-Base.repo

nano /etc/yum.repos.d/CentOS-Base.repo

Add the following text to the end of the Base, Updates, Addons, and Extras repository entries

priority=1
exclude=*php* *mysql*

Enable (change the enable value 0 to 1) and add the following text to the end of the CentOSPlus repository entry

priority=2
exclude=*php* *mysql*

Changing Priority for EPEL and REMI repositories

open ‘epel.repo’ for edit

nano /etc/yum.repos.d/epel.repo

and add the line ‘priority=3‘ to the end of ‘[epel]‘ section

open ‘remi.repo’ for edit

nano /etc/yum.repos.d/remi.repo

change enabled=0 to enabled=1 and also add the line ‘priority=3‘ to the end of ‘[remi]‘ section

Update PHP and MySQL

We are ready to perform the update from the new repositories. Now if you attempt ‘yum update php php-*‘ you will get mysql dependancy issues. SO you have to update mysql first. And the magic is that along with mysql php also gets update. So all that you have to do now is:

yum update mysql

however if you see that only mysql gets updated, then you have to explicitly update all components

yum update mysql mysql-server php php-*

Restart MySql and Apache

now that you have update php and mysql, you need to restart both.

service mysqld restart
# or
/etc/init.d/mysqld restart
service httpd restart
# or
/etc/init.d/httpd restart

Sources

http://www.andresmontalban.com/

http://darkspace.co/blog/8-linux/

27 Responses to Update PHP 5.2 and MySQL 5.0 to PHP 5.3.8 and MySQL 5.5.15 on CentOS 5.5

  1. LeeThong
  2. I followed these steps, but PHP was not updated. During the MySQL update, I don’t see any mention of PHP. If I try to update PHP directly, it says “Package(s) php available, but not installed.” Any ideas?

    Mike
  3. when I update mysql it out puts:

    Loaded plugins: fastestmirror, priorities
    Options Error: Error parsing “enabled = ””: invalid boolean value

    Matthew
    • Hi Matthew, recheck the edits that you have made to config files like
      /etc/yum/pluginconf.d/priorities.conf
      /etc/yum.repos.d/CentOS-Base.repo
      /etc/yum.repos.d/epel.repo
      /etc/yum.repos.d/remi.repo
      Its very likely that you have miss typed something.

  4. Hi,
    after i do all steps. The php und mysql packages install. but the mysqld -start dont function.
    service mysqld -start : when i do this then shows me: fails.
    What can I do?What could be wrong? i forget to stop the mysqld service bevor starting update. Could this be the problem?

    Drenit
    • Hi Drenit, forgetting to stop mysql doesn;t seem to be the problem. I myself have done it many times. Try reinstalling
      # yum reinstall mysql-server mysql php-mysql

  5. can find by search like

    yum list all | grep php

  6. Everything seemed good except I get this error inside mysql database:
    Your PHP MySQL library version 5.0.67 differs from your MySQL server version 5.5.17. This may cause unpredictable behavior.
    What would be causing this to happen?

    Chad
  7. Hey Man, Thanks a lot!
    It worked for my local Linux instalation, but I wasn’t able to update the remote server. I keep getting this at the end of the download:

    Excluding Packages in global exclude list
    Finished
    Excluding Packages from CentOS-5 – Base
    Finished
    Excluding Packages from CentOS-5 – Plus
    Finished
    Excluding Packages from CentOS-5 – Extras
    Finished
    Excluding Packages from CentOS-5 – Updates
    Finished
    2260 packages excluded due to repository priority protections
    Setting up Update Process
    No Packages marked for Update

    Any idea why? I went through the steps twice.

    • Nebojsac, that’s strange. You have disabled the CentOS Repos from handling php and mysql updates (good) but seems like the EPEL and REMI are not enabled.
      The first block in epep and remi repo must look like as follows (enabled=1, and priority=3):

      [epel]
      name=Extra Packages for Enterprise Linux 5 – $basearch
      #baseurl=http://download.fedoraproject.org/pub/epel/5/$basearch
      mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-5&arch=$basear$
      failovermethod=priority
      enabled=1
      gpgcheck=1
      gpgkey=file:///
      priority=3

      [remi]
      name=Les RPM de remi pour Enterprise Linux $releasever – $basearch
      #baseurl=http://rpms.famillecollet.com/enterprise/$releasever/remi/$basearch/
      mirrorlist=http://rpms.famillecollet.com/enterprise/$releasever/remi/mirror
      enabled=1
      gpgcheck=1
      gpgkey=file:///
      failovermethod=priority
      priority=3

      2260 packages excluded? I don’t know why so many packages there? Is this a fresh installation or an upgrade?

      • That’s exactly what I have on the beginning of those files.
        The installation is pretty fresh, I install packages as I need them there. The PHP version is 5.2.17 though.

        One thing I’ve noticed is that the CentOs.repo file doesn’t have the [Addons] block. Do you think that has anything to do with it?

      • I am not sure if [Addons] is causing the trouble but even if it is there, it have to be excluded for php and mysql updates. Do you have the file /etc/yum/pluginconf.d/priorities.conf ? and its content as
        [main]
        enabled=1
        I am certain that the problem is with the repo settings.

      • Alfie, I have followed the instructions on this post. Runing:
        nano /etc/yum/pluginconf.d/priorities.conf
        opens the file, and it’s contents are
        [main]
        enabled=1

        trying this:
        rpm -Uvh remi-release-5*.rpm epel-release-5*.rpm
        I get a msg saying they’re both installed. And the yum update commands return same as before…

        I really appreciate you taking the time to reply to my error. I’m not to proficient with Linux so this is all a bit new to me. But as I said, I followed the instructions once already, and it worked on my local machine.

  8. Hi Nebojsac, your problem boggles me. I cannot figure out the problem unless I can experience it myself. The following statement is strange; “2260 packages excluded due to repository priority protections”
    Why don’t you try “yum update” and see what’s happening; what it excludes or includes etc
    The problem could be a typographic error in some repo config file.

    • Yeah, I’ll probably try that when it comes to it. Updating to 5.3 opened up a whole new can of worms on my local machine, like imageMagick ceasing to work, and getting errors on updates for it, among other things, so now I’m trying to get that working first, since that is more important, and will tackle the online one a little later. I’ve been quadruple checking my repo files, and comparing to the files on my local machine with no luck. Thank you for all your help! I’ll be sure to reply if that helped fixed my problem, and I’ll be subscribing!
      Cheers!

  9. Hi Alfie,

    Thanks so much for putting making a home for this topic.

    I have followed all steps above, without problem, but get to the point where i have to run:

    # yum install php-mysql

    (since it does not seem to have installed during my previous (partially successful) attempts to upgrade php to 5.3.8 and mysql to 5.5. (so far httpd and plesk configs have become somewhat mangled in this painful upgrade and i’m currently trying to get everything singing together again)).

    this half-works, but then spits out a load of errors, vis::


    ... yada yada - all downloading ok, then....
    Downloading Packages:
    (1/2): php-mysql-5.3.8-5.el5.remi.1.x86_64.rpm | 95 kB 00:00
    (2/2): mysql-libs-5.5.18-1.el5.remi.x86_64.rpm | 1.1 MB 00:00
    --------------------------------------------------------------------------------------------------------------------------------------------------
    Total 5.3 MB/s | 1.2 MB 00:00
    Running rpm_check_debug
    Running Transaction Test
    Finished Transaction Test

    Transaction Check Error:
    file /etc/my.cnf from install of mysql-libs-5.5.18-1.el5.remi.x86_64 conflicts with file from package mysql55-libs-5.5.10-1.w5.x86_64
    file /usr/lib64/mysql/libmysqlclient.so.18.0.0 from install of mysql-libs-5.5.18-1.el5.remi.x86_64 conflicts with file from package mysql55-libs -5.5.10-1.w5.x86_64
    file /usr/share/mysql/charsets/cp1251.xml from install of mysql-libs-5.5.18-1.el5.remi.x86_64 conflicts with file from package mysql55-libs-5.5. 10-1.w5.x86_64
    ...
    yada yada similar errors..

    … so it looks like i have a conflict with a previous install/downloaded repo.

    have you any idea how i might recover from this?

    thanks for any help you can offer.

  10. Hi Alfie, thanks for such a prompt reply.

    good call.

    in fact, iv’e just got over this particular hurdle by first removing the conflicting repo’s in the following way:

    # yum remove mysql55-libs-5.5.10-1.w5.x86_64
    – ok

    then on with a complete reinstall from the top:

    # yum install mysql
    # yum update mysql mysql-server php php-*
    # yum install mysql-server
    # yum install php-devel
    # yum install php-mysql
    – all wen though ok this time – hurrah!

    then restart servers and test:

    # service mysqld restart
    # service httpd restart
    – both ok

    check on the front-end of my primary domain over http running phpinfo in a browser
    shows all correct new versions of php, mysql, php-mysql, etc – great!

    BUT, now i have a slightly different problem::

    i can only get an http session up using chrome browser from MY pc – any other browser or any other PC gives a ‘page not found’ error. – very strange!

    so, it seems like i have some residual problem with Plesk/PSA vhosts config, perhaps?

    do you have any clues?

    (PS. hope the above findings might prove of value to someone else in the same position)

  11. Trying “yum update” brings up the same 2297 number of excluded packages, and only offers to update kernel-* files.

    this is what I see above the files that are set for update and install:
    ——————-
    Loading mirror speeds from cached hostfile
    * base: centos.mirror.iweb.ca
    * centosplus: centos.mirror.iweb.ca
    * epel: mirror.csclub.uwaterloo.ca
    * extras: centos.mirror.iweb.ca
    * remi: rpms.famillecollet.com
    * rpmforge: fr2.rpmfind.net
    * updates: centos.mirror.iweb.ca
    base | 1.1 kB 00:00
    centosplus | 1.9 kB 00:00
    centosplus/primary_db | 59 kB 00:00
    epel | 3.7 kB 00:00
    epel/primary_db | 3.9 MB 00:01
    extras | 2.1 kB 00:00
    remi | 2.5 kB 00:00
    rpmforge | 1.1 kB 00:00
    updates | 1.9 kB 00:00
    updates/primary_db | 420 kB 00:00
    ——————-

    Does it help at all? I’m proceeding to re-check your steps once again since I’m out of ideas…

    • I found out what was happening so to maybe save someone the trouble I’ll share it:

      Turns out if your dedicated host (with CentOS) is managed with WHM, you have to update PHP through the Update Apache option there, and follow the instructions.

      It seems to block any attempt to do so through SSH. I had no idea this was the case. Not it all works! Thanks a lot for you help Alfie, I learned a bunch!

  12. Hey,

    I’m trying to update php and mysql for a wordpress install. I followed your instructions and now when I run the command:

    service mysqld restart

    I get an error saying ‘mysql DAEMON failed to start’.

    I have tried re installing mysql and php but I cant get it to work. Any ideas?

    • Is PHP running fine? It possible that the my.cnf file has the socket pointing to the wrong directory. Try “whereis mysql.sock” and see if in the “my.cnf” file the socket points to the same directory. In my installation my.cnf is located at “/etc/my.cnf”

      • Hey,

        so I found that mysql sock was in usr/lib/mysql so I changed the directories on the my.cnf file. I then tried to start mysqld and got this output:

        [root@server1 ~]# service mysqld start
        Initializing MySQL database: Installing MySQL system tables…
        OK
        Filling help tables…
        OK

        To start mysqld at boot time you have to copy
        support-files/mysql.server to the right place for your system

        PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
        To do so, start the server, then issue the following commands:

        /usr/bin/mysqladmin -u root password ‘new-password’
        /usr/bin/mysqladmin -u root -h server1 password ‘new-password’

        Alternatively you can run:
        /usr/bin/mysql_secure_installation

        which will also give you the option of removing the test
        databases and anonymous user created by default. This is
        strongly recommended for production servers.

        See the manual for more instructions.

        You can start the MySQL daemon with:
        cd /usr ; /usr/bin/mysqld_safe &

        You can test the MySQL daemon with mysql-test-run.pl
        cd /usr/mysql-test ; perl mysql-test-run.pl

        Please report any problems with the /usr/bin/mysqlbug script!

        [ OK ]
        MySQL Daemon failed to start.
        Starting mysqld: [FAILED]

        Still not working. I even looked for the files it refers to in the [mysqld_safe] section, and changed them accordingly…..still failing to start.

  13. Great walkthrough! Worked like a charm.

  14. I get errrors with the very first command:

    wget http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
    –2012-02-22 13:05:56– http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
    Resolving download.fedora.redhat.com… 64.30.224.112
    Connecting to download.fedora.redhat.com|64.30.224.112|:80… connected.
    HTTP request sent, awaiting response… 404 Not Found
    2012-02-22 13:05:56 ERROR 404: Not Found.

    Max L

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

 
Designed and developed by Alfie Punnoose @ Blokeish.com