July 26, 2014

Installing PHP 5.3.3 on CentOS 5.5 Tutorial

Update: This tutorial will install PHP 5.3.6

In celebration of CentOS now leading the Linux distribution statistics on web servers, with almost 30% of all Linux servers, we thought it fitting that in this tutorial we will show you how to install PHP 5.3.3 (Supports the Kohana Framework) with APC and Memcached on CentOS 5.5.

The assumption for this CentOS 5.5 tutorial is that you are running as root and have a basic understanding of the software required but if you follow this tutorial you should be able to complete the task successfully.

Preliminary Note:

I am using a CentOS 5.5 32bit server in this tutorial:

* centos01.how2centos.com (IP 10.0.0.3)

# yum install yum-priorities

Installing PHP 5.3 on CentOS 5.5 i386

Install the EPEL i386 YUM Repository

# rpm -Uvh http://download.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm

Install the IUS i386 YUM Repository

# rpm -Uvh http://dl.iuscommunity.org/pub/ius/stable/Redhat/5/i386/ius-release-1.0-10.ius.el5.noarch.rpm

# yum install httpd

NOTE: If you have a previously installed version of PHP run this command.

# yum remove php php-*

# yum install php53u-pear php53u php53u-cli php53u-common php53u-devel php53u-gd php53u-mbstring php53u-mcrypt php53u-mysql php53u-pdo php53u-soap php53u-xml php53u-xmlrpc php53u-bcmath php53u-pecl-apc php53u-pecl-memcache php53u-snmp

UPDATE: The above will install APC version 3.1.9 which does not have the bug mentioned below.

NOTE: Version 3.1.4 of APC has a bug that will give you this error in you error.log file PHP Warning: require(): Unable to allocate memory for pool.

To resolve this do the following

# yum remove php53u-pecl-apc
# yum update php53u-pecl-apc --enablerepo=ius-testing

# vi /var/www/html/phpinfo.php

# chkconfig httpd on
# service httpd start

Finally browse to your phpinfo.php http://10.0.0.3/phpinfo.php and view your newly configured PHP 5.3.3 Apache server.

  • MM

    Brilliant tutorial. The instructions worked perfectly other than I had to ‘yum remove php php-*’ first to avoid conflicts. You just save me a lot of time. Thanks.

  • Anonymous

    It’s a absolute pleasure!

  • Anonymous

    When I visited this web writeup I figured this blog’s fans really should review this! http://hubpages.com/hub/rent-a-laptop-rentals . I just don’t get renting a notebook at all! The tab of renting a portable computer even for just about a dozen days will charge you as much as outright going to the store and purchasing the netbook!

  • kelvin

    When I follow the insructions given,I get the no package available message.

  • Anonymous

    @Kelvin – Can you make sure that you installed the following rpm # rpm -Uvh http://dl.iuscommunity.org/pub/ius/stable/Redhat/5/i386/ius-release-1.0-6.ius.el5.noarch.rpm ?

  • Mark Klinski

    When I run:

    # yum install httpd

    I get the following error:

    Loaded plugins: fastestmirror, priorities
    Loading mirror speeds from cached hostfile
    Could not retrieve mirrorlist http://dmirr.iuscommunity.org/mirrorlist?repo=ius-el5&arch=i386 error was
    [Errno 14] HTTP Error 500: Internal Server Error
    Error: Cannot find a valid baseurl for repo: ius

  • Anonymous

    This looks like a mirror issue, you should try again at a later stage.

  • MR E.

    I tried your tutorial but i receive:

    # yum install httpd
    Loaded plugins: fastestmirror, priorities
    Loading mirror speeds from cached hostfile
    * addons: …
    * base: …
    * extras: …
    * updates: …
    Excluding Packages in global exclude list
    Finished
    Setting up Install Process
    No package httpd available.
    Nothing to do

  • Anonymous

    Run this:

    # rpm -qa httpd

    and paste the output?

  • Macintoshbrasil

    I am a complete Linux newb. I admit my failures. But I figure I need to start someplace, so last week I installed CentOS on an extra machine here so I can learn something. (http://www.centos.org)

    If you can answer any of these questions, much appriciated.

    i try to install LAMP on my PC..
    the http://localhost/ apache works fine! but my php wont! , i try to restart, check service, and nothing!! works!!
    Running rpm_check_debug
    Running Transaction Test
    Finished Transaction Test

    Transaction Check Error:
    file /etc/php.ini from install of php53-common-5.3.3-4.ius.el5.x86_64 conflicts with file from package php-common-5.1.6-27.el5.x86_64
    file /usr/lib64/php/modules/mysql.so from install of php53-mysql-5.3.3-4.ius.el5.x86_64 conflicts with file from package php-mysql-5.1.6-27.el5.x86_64
    file /usr/lib64/php/modules/mysqli.so from install of php53-mysql-5.3.3-4.ius.el5.x86_64 conflicts with file from package php-mysql-5.1.6-27.el5.x86_64
    file /usr/lib64/php/modules/pdo_mysql.so from install of php53-mysql-5.3.3-4.ius.el5.x86_64 conflicts with file from package php-mysql-5.1.6-27.el5.x86_64
    file /usr/lib64/php/modules/pdo.so from install of php53-pdo-5.3.3-4.ius.el5.x86_64 conflicts with file from package php-pdo-5.1.6-27.el5.x86_64
    file /usr/lib64/php/modules/pdo_sqlite.so from install of php53-pdo-5.3.3-4.ius.el5.x86_64 conflicts with file from package php-pdo-5.1.6-27.el5.x86_64

    Error Summary
    ————-

    [root@cs ~]# nano /var/www/html/phpinfo.php
    [root@cs ~]# chkconfig httpd on
    [root@cs ~]# service httpd start
    Starting httpd:
    [root@cs ~]# rpm -qa httpd
    httpd-2.2.3-43.el5.centos.3
    [root@cs~]#

  • Anonymous

    We all have to start somewhere!Before installing PHP 5.3.3 run the following command:# yum remove php php-*Then run the yum install php53

  • johnd

    Thanks for this, I’ve been looking for a clear example of how to upgrade PHP on centos for such a long time.
    It upgrading to 5.3.3 like a charm and things seem to be working ok at the moment!

    Thanks again!

  • V Lorenzani

    I love you!!
    Thanks

    Valerio

  • David

    Looked up a load of tutorials on this and yours is the only one that seems straight forward, but would this work with the 64 bit version?

    This is a 64bit install right?

    Linux #######.localdomain 2.6.18-194.11.3.el5 #1 SMP Mon Aug 30 16:19:16 EDT 2010 x86_64

    If this isn’t going to work on 64bit instals, don’t suppose you plan to create another tutorial :-)

    David

  • Anonymous

    This will work perfectly on 64bit using the above tutorial.

  • David

    Went through the tutorial and ran into issues with PHP so uninstalled, but didn’t notice your advice to run yum install php53 after (so only ran yum remove php php-* and started the tutorial from the start), but did everything else and didn’t get any more errors.

    When I loaded a PHP info page it said running Php 5.1.6 so rebooted the server and it appears to have crashed!

    Got the server company to do a hard reboot and still not reponding (can’t connect via SHH).

    Getting KVMIP access, any thoughts on what might have gone wrong?

    David

  • David

    It would appear my network card settings messed up after the upgrade, getting it fixed now.

    Had this problem before when I forst got the server, so highly unlikly yo be directly caused by your tutorial.

    Basialy looks like the server is working with the latest version of Php, but because the NIC has changed settings it’s not online.

    David

  • Azard

    Hi,
    Thanks for the wonderful guide. My php is running fine. But how do I enable mysql support. Thanks..

  • Anonymous

    Make sure your mysql.ini file exists

    # cat /etc/php.d/mysql.ini
    ; Enable mysql extension module
    extension=mysql.so

  • Azard

    Thanks for the reply. mysql.ini exists and it’s content is the same as what you have given.

  • Anonymous

    Then it should be enabled, is it displaying in you phpinfo?

  • Azard

    That’s the problem. It does not show in phpinfo. I am using the package from ius.

  • Azard

    Manage to get mysql extension running but I am using php rpm from Remi. Thanks for the help.

  • S Ghiassy

    Thx, you Rock!

    As a note I had to issue the command

    # yum remove php php-*

    To get it to work.

    Other than that you made the whole process amazingly simple!

  • Turbo124

    Some people may have trouble using this install due to APC 3.1.4 being in this repository. I had troubles with APC ‘failing to allocate memory from pool’ this is a known issue with 3.1.4 that has been addressed in 3.1.5

  • Anonymous

    Resolving this problem is easy!

    # yum update php53-pecl-apc –enablerepo=ius-testing

  • http://www.facebook.com/dat87 Nguyen Thanh Dat

    Hello,
    When I run this command to install:
    # yum install php53-pear php53 php53-cli php53-common
    php53-devel php53-gd php53-mbstring php53-mcrypt
    php53-mysql php53-pdo php53-soap php53-xml php53-xmlrpc
    php53-bcmath php53-pecl-apc php53-pecl-memcache

    Then:
    Loaded plugins: fastestmirror, priorities
    Loading mirror speeds from cached hostfile
    * addons: mirror.team-cymru.org
    * atomic: www4.atomicorp.com
    * base: mirror.san.fastserv.com
    * epel: mirrors.tummy.com
    * extras: mirrors.netdna.com
    * ius: http://www.applesauceman.com
    * remi: remi-mirror.dedipower.com
    * updates: centos.corenetworks.net
    addons | 951 B 00:00
    atomic | 1.9 kB 00:00
    base | 2.1 kB 00:00
    extras | 2.1 kB 00:00
    updates | 1.9 kB 00:00
    Excluding Packages in global exclude list
    Finished
    Excluding Packages from CentOS-5 – Addons
    Finished
    Excluding Packages from CentOS-5 – Base
    Finished
    Excluding Packages from CentOS-5 – Extras
    Finished
    Excluding Packages from CentOS-5 – Updates
    Finished
    426 packages excluded due to repository priority protections
    Setting up Install Process
    No package php53-pear available.
    No package php53 available.
    No package php53-cli available.
    No package php53-common available.
    No package php53-devel available.
    No package php53-gd available.
    No package php53-mbstring available.
    No package php53-mcrypt available.
    No package php53-mysql available.
    No package php53-pdo available.
    No package php53-soap available.
    No package php53-xml available.
    No package php53-xmlrpc available.
    No package php53-bcmath available.
    No package php53-pecl-apc available.
    No package php53-pecl-memcache available.
    Nothing to do

    What is the problem do you know?
    Thank you :)

  • http://www.facebook.com/dat87 Nguyen Thanh Dat

    Hello,
    When I run this command to install:
    # yum install php53-pear php53 php53-cli php53-common
    php53-devel php53-gd php53-mbstring php53-mcrypt
    php53-mysql php53-pdo php53-soap php53-xml php53-xmlrpc
    php53-bcmath php53-pecl-apc php53-pecl-memcache

    Then:
    Loaded plugins: fastestmirror, priorities
    Loading mirror speeds from cached hostfile
    * addons: mirror.team-cymru.org
    * atomic: www4.atomicorp.com
    * base: mirror.san.fastserv.com
    * epel: mirrors.tummy.com
    * extras: mirrors.netdna.com
    * ius: http://www.applesauceman.com
    * remi: remi-mirror.dedipower.com
    * updates: centos.corenetworks.net
    addons | 951 B 00:00
    atomic | 1.9 kB 00:00
    base | 2.1 kB 00:00
    extras | 2.1 kB 00:00
    updates | 1.9 kB 00:00
    Excluding Packages in global exclude list
    Finished
    Excluding Packages from CentOS-5 – Addons
    Finished
    Excluding Packages from CentOS-5 – Base
    Finished
    Excluding Packages from CentOS-5 – Extras
    Finished
    Excluding Packages from CentOS-5 – Updates
    Finished
    426 packages excluded due to repository priority protections
    Setting up Install Process
    No package php53-pear available.
    No package php53 available.
    No package php53-cli available.
    No package php53-common available.
    No package php53-devel available.
    No package php53-gd available.
    No package php53-mbstring available.
    No package php53-mcrypt available.
    No package php53-mysql available.
    No package php53-pdo available.
    No package php53-soap available.
    No package php53-xml available.
    No package php53-xmlrpc available.
    No package php53-bcmath available.
    No package php53-pecl-apc available.
    No package php53-pecl-memcache available.
    Nothing to do

    What is the problem do you know?
    Thank you :)

  • Matt

    I’m having the exact same issue. It does actually install php 5.3 cli and common but none of the modules.

  • Matt

    Looks like it was a bad mirror, a really bad mirror actually. I ran ‘yum clean all’ then ‘yum check-update’ and saw the mirror come back as a 404 (http://www.applesauceman.com/iusstable/Redhat/5/x86_64/repodata/repomd.xml). I added applesauceman.com to my exclude list then cleaned and updated. Still getting No Package, however.

  • Matt

    Taking a look at the actual mirrors, the packages have been renamed from php53-* to php53u-* . Also, the applesauce.com mirror is getting sent with the wrong url path from the mirror list. I had to comment out the mirror list and just use the base url in the ius.repo.d

  • Anonymous

    I tried this last night because I had to setup a quick web server and found that, for some weird reason, they changed the package names ??

    So to fix the problem add a ‘u’ to the end of php53….

    i.e. #yum install php53u-pear php53u php53u-cli php53u-common php53u-devel php53u-gd php53u-mbstring php53u-mcrypt php53u-mysql php53u-pdo php53u-soap php53u-xml php53u-xmlrpc php53u-bcmath php53u-pecl-apc php53u-pecl-memcache php53u-snmp -y

  • http://twitter.com/ggavranovic Gavro

    For people who have dependency issues with php when trying to uninstall (for example: Plesk Panel), the yum replace plugin might be of assistance.

    # yum install yum-plugin-replace
    # yum replace php –replace-with php53u

    You will get some warnings about sub-packages, but when replacing, all the packages do get replaced correctly.

    After this, you can run the rest of the guide to install new/missing packages.

  • http://twitter.com/count_schemula Count Schemula

    Fantastic. Worked ace on CentOS 5.5 on a Rackspace cloud server!

  • Guest McGuesterson

    Very straightforward, thanks! But now I have 5.3.5, and I want 5.3.3. How do I roll back?

  • Justin Buser

    This simply did not work for me no matter how many times I tried it. Php files would just print / echo out to the browser and not be parsed. If you’re having problems do yourself a favor and try the following:

    service httpd stop
    yum erase php*
    rpm -Uvh http://repo.webtatic.com/yum/centos/5/latest.rpm
    yum –enablerepo=webtatic install php php-common php-gd php-mysql php-mbstring php-mcrypt
    service httpd start

    That’s it, works perfectly on x86_64 at least. Plus that rpm has been around and working forever, the new Cent repo crap just doesn’t seem to work.

  • Anonymous

    Just tested the installation guide from start to finish and it works 100%

  • Dave Alan Caruana

    great – at the beginning you will need to update the IUS filename by opening the relevant webpage and getting the latest version – it’s currently http://dl.iuscommunity.org/pub/ius/stable/Redhat/5/i386/ius-release-1.0-8.ius.el5.noarch.rpm

  • Anonymous

    Noted and changed! Thank you for your input

  • Tim D

    I had tried several tutorials with no success because when I was done there was no phpize file.  This method did contain that :)  .  Since I have the 64bit version I just used the files from the X586_64 repository/directory (epel and ius rpms).

    I ran into two problems
    1. My plesk panel did not work (was uninstalled).  I have re-imaged my server and going to try it again and test after each step to see where I mess up.

    —————————————————
    # yum remove php53-pecl-apc
     > It tells me this module does not exist.
    # yum update php53-pecl-apc –enablerepo=ius-testing
     > Same thing, no module, nothing to update.

  • Anonymous

    Apologies, there was a typo in the guide. I have since updated it.

    # yum remove php53u-pecl-apc
    # yum update php53u-pecl-apc –enablerepo=ius-testing

    This wont be necessary though because version 3.1.9 fixed the bug.

  • Tim D

    Awesome!  Can this be done without uninstalling plesk?

  • Anonymous

    I haven’t personally worked with Plesk so I am unsure what it’s behavior will be. If uninstalling php includes uninstalling Plesk then maybe uninstall it, upgrade and the re-install Plesk.

    Good luck and remember to backup before upgrading.

  • ruo

    I get the same question,  and just use the  /etc/yum.repos.d/ius.repo from the other vps to replace it.

  • Anonymous

    Thanks for this! you need to put a paypal donate button on your site so I can contribute to your beer fund, or a link to your amazon wish list! ;-)

  • User123
  • How2CentOS

    Thanks for the update. I have amended the article

  • Nitesh Luharuka

    It works, just need to get updated rpm location form comments of User123 below!!

  • Ömer Faruk Ak

    I couldn’t install php 5.3 

    [root@vps ~]# yum install php53u-pear php53u php53u-cli php53u-common php53u-devel php53u-gd php53u-mbstring php53u-mcrypt php53u-mysql php53u-pdo php53u-soap php53u-xml php53u-xmlrpc php53u-bcmath php53u-pecl-apc php53u-pecl-memcache php53u-snmp
    Loaded plugins: priorities
    Excluding Packages in global exclude list
    Finished
    Setting up Install Process
    No package php53u-pear available.
    No package php53u available.
    No package php53u-cli available.
    No package php53u-common available.
    No package php53u-devel available.
    No package php53u-gd available.
    No package php53u-mbstring available.
    No package php53u-mcrypt available.
    No package php53u-mysql available.
    No package php53u-pdo available.
    No package php53u-soap available.
    No package php53u-xml available.
    No package php53u-xmlrpc available.
    No package php53u-bcmath available.
    No package php53u-pecl-apc available.
    No package php53u-pecl-memcache available.
    No package php53u-snmp available.
    Nothing to do

  • How2CentOS

     Try this

    # yum clean all

    and then install the PHP 5.3 rpms as above

  • Ömer Faruk Ak

    Nothing is changed. :(

  • How2CentOS

    It will work on all versions of CentOS 5 32 bit

    # uname -a
    # rpm -qa | grep ius

    Paste the outputs (We don’t usually do support)

  • Ömer Faruk Ak

    I searched lots of pages but i can not find a solution :(

    [root@vps ~]# uname -aLinux vps.cssogrenelim.com 2.6.32 #1 SMP Mon May 9 13:27:11 CEST 2011 i686 i686 i386 GNU/Linux[root@vps ~]# rpm -qa | grep iusius-release-1.0-10.ius.el5

  • Ömer Faruk Ak

    Won’t you help? :(

  • Ömer Faruk Ak

    Thank you very much for your all help :)

  • Alireza

    Thank you
    it’s really good and worked for me