PHP Linux installation or php upgrade howto

Q. How do I install PHP under Red Hat enterprise Linux?

Advertisement

A. PHP (Hypertext Preprocesso) is a server-side web programming language that you can embed into HTML pages. When a user accesses a PHP-based page, PHP dynamically creates a web page that is then passed to the browser.

PHP works with Apache, Lighttpd and other webservers. PHP offers built-in database integration for several commercial and non-commercial database management systems. It also has the ability to perform many useful Web-related tasks using a large set of built-in functions.

PHP generally runs on a web server, taking PHP code as its input and creating Web pages as output, but command-line scripting and client-side GUI applications are part of the three primary uses of PHP as well. PHP can be deployed on any web server and on almost every OS platform free of charge.

Installing PHP is easy these days.

Red Hat enterprise Linux PHP installation

If you would like to install or upgrade PHP use up2date command:
# up2date php

CentOS/Fedora core Linux PHP installation

If you would like to install PHP use yum command
# yum install php

If you would like to upgrade PHP use yum command
# yum update php

Debian / Ubentu Linux PHP installation

If you would like to install or upgrade PHP use atp-get command
# apt-get install php4-cgi php4-cli
# sudo apt-get install php4-cgi php4-cli

To install PHP 5
# apt-get install php5-cgi php5-cli
# sudo apt-get install php5-cgi php5-cli

FreeBSD PHP installation

Use pkg_add command as follows:
# pkg_add -v -r php

Use above command to install Apache or Lighttpd web server.

🥺 Was this helpful? Please add a comment to show your appreciation or feedback.

nixCrat Tux Pixel Penguin
Hi! 🤠
I'm Vivek Gite, and I write about Linux, macOS, Unix, IT, programming, infosec, and open source. Subscribe to my RSS feed or email newsletter for updates.

33 comments… add one
  • everydaypanos Jun 24, 2010 @ 19:13

    Is it me or everyone is kind of trying NOT to answer the question? It’s like: I know how to update PHP but I don’t really care to help anyone else because I spent hours googling and some noob wants it on a plate.

    Don’t you just love the Open Source community spirit?

    At the end of the day, yum update php is NOT the solution. Because the problem is upgrading to a version of PHP that you actually want…

  • Andi Herdiana Jul 5, 2010 @ 3:53

    Please help me!
    How to upgrade php and MySQL on FEDORA CORE 4 with detail description!

    Thank you before!

  • Aaron Sep 15, 2010 @ 15:19

    Goodness, I wasn’t trying to garner any awe. I was venting because developing on a closed network RHEL server is a major pain in the ass! No repo’s make me cry hard.

    I forgot I even made this post haha. I’m faced with more of the same and started looking for a PHP upgrade procedure via BASH landed me back here…

    PHP 5.0 on the production server but my dev server is using 5.2 so when I went to stand up a Flex application today the DateTime function bit me.

    By the way, the network is still SECRET and will always be regardless if I speak of it or not.

    /google on MOAR!

  • Terry Sep 28, 2010 @ 15:15

    You must have a way to download files, if you can get a .gz source file.

    For example: at home, find the RPM for the package you want to use, burn it to a CD, take it to work, mount the CD, then use the rpm command to install the package.

    If bringing a file from home isn’t permitted, then ask your network admins to get the rpm file for you from the ‘net and copy it to your secret network. Then use rpm to install it.

  • Dayawansa Oct 18, 2010 @ 9:52

    I have PHP 5.1 and MYsql 5.0.22. My system is Redhat enterprse server 5. But I am unable to connect the mysql database through PHP.Can you tell me how to upgrade to the latest PHP version from internet at my unix box? Do I have to first uninstall the old version or something

  • Sanford Dickert Nov 23, 2010 @ 2:42

    Check the following site for an upgrade path on CentOS 5 at godaddy.

    http://wiki.centos.org/HowTos/PHP_5.1_To_5.2

    • danoprey Jun 29, 2011 @ 9:28

      Perfect, thank you so much for the guide.

    • Ganga Sep 29, 2011 @ 11:26

      Yes. It works perfectly for me..
      I am using Centos5.5….

      Thanks Sanford….

  • sapy Feb 25, 2011 @ 11:16

    Pls run the following command :whereis php
    now depending on the mode of installation may be u can try setting the home path of php for updated version.

  • harfano Dec 5, 2012 @ 3:21

    i’ve trying Sandford suggestion but it’s not working.i’m using CentOS 5.8 (final) on i386.
    is there any other way? please…

  • prathap Feb 24, 2014 @ 9:27

    Hi All,

    I try to update php 5.1.6 to latest but not able to update. i’m using CentOS-5.10.

    [root@srv01 ~]# lsb_release -a
    LSB Version: :core-4.0-ia32:core-4.0-noarch:graphics-4.0-ia32:graphics-4.0-noarch:printing-4.0-ia32:printing-4.0-noarch
    Distributor ID: CentOS
    Description: CentOS release 5.10 (Final)
    Release: 5.10
    Codename: Final
    [root@srv01 ~]# php –version
    PHP 5.1.6 (cli) (built: Dec 10 2013 22:14:51)
    Copyright (c) 1997-2006 The PHP Group
    Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
    [root@srv01 ~]# yum update php
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
    * addons: mirror.dhakacom.com
    * base: mirror.dhakacom.com
    * epel: buaya.klas.or.id
    * extras: mirror.dhakacom.com
    * rpmforge: mirror.oscc.org.my
    * updates: mirror.dhakacom.com
    Setting up Update Process
    No Packages marked for Update
    [root@srv01 ~]#

  • Karthik Jul 9, 2016 @ 11:15

    Hi,
    I have difficulty to upgrade my Red hat 5.6 Server’s Php version 5.1.6 to 5.5. Can anyone guide me the steps which I should follow.
    I have downloaded .tar file, unzipped then ran the configure and make install commands. Then it shows php 5.5 when I’m running php -v command. But running the script for finding php details in browser its still showing 5.1.6 .

Leave a Reply

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

Use HTML <pre>...</pre> for code samples. Your comment will appear only after approval by the site admin.