Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Programming»PHP»How To Install PHP 7.4 – 7.0 on Ubuntu 18.04

    How To Install PHP 7.4 – 7.0 on Ubuntu 18.04

    By RahulAugust 5, 20225 Mins Read

    PHP 7.4 is the latest stable release of PHP. Say thanks to Ondřej Surý for maintaining PPA of most the popular PHP versions on launchpad. If you want to install a specific version of PHP, then this article can be helpful for you. This article will help you to install PHP 7.4, 7.3, 7.2, 7.1 & PHP 7.0 on Ubuntu 18.04 LTS using PPA

    Advertisement
    • Read: How to Install PHP 7 on Debian via PPA

    You can also install multiple PHP versions on your system and switch PHP version between them. Also, you can configure Apache VirtualHosts to use different-2 PHP versions.

    Install PHP 7.4 on Ubuntu

    PHP 7.4 is the latest stable version is available for installation. Use the following set of commands to enable PPA for PHP 7.4 in your Ubuntu system and install it. You can use this version for production use also.

    sudo apt-get install software-properties-common
    sudo add-apt-repository ppa:ondrej/php
    sudo apt-get update
    sudo apt-get install -y php7.4
    

    Now use the following command to check installed php version on your system.

    php -v 
    
    PHP 7.4.5 (cli) (built: Apr 28 2020 14:49:23) ( NTS )
    Copyright (c) The PHP Group
    Zend Engine v3.4.0, Copyright (c) Zend Technologies
        with Zend OPcache v7.4.5, Copyright (c), by Zend Technologies
    

    Install PHP 7.3 on Ubuntu

    PHP 7.3 stable version has been released. Use the following set of commands to enable PPA for PHP 7.3 in your Ubuntu system and install it. You can use this version for production use also.

    sudo apt-get install software-properties-common
    sudo add-apt-repository ppa:ondrej/php
    sudo apt-get update
    sudo apt-get install -y php7.3
    

    Now use the following command to check installed php version on your system.

    php -v 
    
    PHP 7.3.9-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Sep  2 2019 12:54:04) ( NTS )
    Copyright (c) 1997-2018 The PHP Group
    Zend Engine v3.3.9, Copyright (c) 1998-2018 Zend Technologies
        with Zend OPcache v7.3.9-1+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
    

    Install PHP 7.2 on Ubuntu

    PHP 7.2 stable version has been released. Use the following set of commands to enable PPA for PHP 7.2 in your Ubuntu system and install it. You can use this version for production use also.

    sudo apt-get install software-properties-common
    sudo add-apt-repository ppa:ondrej/php
    sudo apt-get update
    sudo apt-get install -y php7.2
    

    Now use the following command to check installed php version on your system.

    php -v 
    
    PHP 7.2.16-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Mar  7 2019 20:23:29) ( NTS )
    Copyright (c) 1997-2018 The PHP Group
    Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
        with Zend OPcache v7.2.16-1+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
    

    Install PHP 7.1 on Ubuntu

    Use the following set of commands to add PPA for PHP 7 in your Ubuntu system and install PHP 7.1 version.

    sudo apt-get install software-properties-common
    sudo add-apt-repository ppa:ondrej/php
    sudo apt-get update
    sudo apt-get install -y php7.1
    

    Now use the following command to check installed php version on your system.

    php -v 
    
    PHP 7.1.27-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Mar  7 2019 20:02:25) ( NTS )
    Copyright (c) 1997-2018 The PHP Group
    Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
        with Zend OPcache v7.1.27-1+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
    

    Install PHP 7.0 on Ubuntu

    Use the following set of commands to add PPA for PHP 7 in your Ubuntu system and install PHP 7.0 version.

    sudo apt-get install python-software-properties
    sudo add-apt-repository ppa:ondrej/php
    sudo apt-get update
    sudo apt-get install -y php7.0
    

    Now use the following command to check installed php version on your system.

    php -v 
    
    PHP 7.0.33-5+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Mar  8 2019 09:49:15) ( NTS )
    Copyright (c) 1997-2017 The PHP Group
    Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
        with Zend OPcache v7.0.33-5+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2017, by Zend Technologies
    

    Install PHP 7 Modules

    You may also need to install modules based on your application requirements. Use the following command to search available PHP 7 modules in the package repository.

    sudo apt-cache search php7*
    
    php-all-dev - package depending on all supported PHP development packages
    php7.0 - server-side, HTML-embedded scripting language (metapackage)
    php7.0-cgi - server-side, HTML-embedded scripting language (CGI binary)
    php7.0-cli - command-line interpreter for the PHP scripting language
    php7.0-common - documentation, examples and common module for PHP
    php7.0-curl - CURL module for PHP
    php7.0-dev - Files for PHP7.0 module development
    php7.0-gd - GD module for PHP
    php7.0-gmp - GMP module for PHP
    ...
    ...
    ...
    php7.1-xml - DOM, SimpleXML, WDDX, XML, and XSL module for PHP
    php7.1-xmlrpc - XMLRPC-EPI module for PHP
    php7.1-zip - Zip module for PHP
    php7.1-opcache - Zend OpCache module for PHP
    php7.1 - server-side, HTML-embedded scripting language (metapackage)
    php7.1-xsl - XSL module for PHP (dummy)
    ...
    ...
    php7.2-bcmath - Bcmath module for PHP
    php7.2-bz2 - bzip2 module for PHP
    php7.2-cgi - server-side, HTML-embedded scripting language (CGI binary)
    php7.2-cli - command-line interpreter for the PHP scripting language
    php7.2-common - documentation, examples and common module for PHP
    php7.2-curl - CURL module for PHP
    php7.2-dba - DBA module for PHP
    

    You can install the required PHP modules on your system as below command. Make sure to install packages for correct PHP version by specifying the version with the package name. Without defining the package version, it will install the latest package.

    sudo apt-get install php7.2-mysql php7.2-curl php7.2-json php7.2-cgi php7.2-xsl
    

    Congratulation! Enjoy the development with PHP 7.

    PHP PHP 7.1 PHP 7.2 PHP 7.3 Ubuntu
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    Installing PHP on Pop!_OS

    How to Install PHP 8.x on Pop!_OS

    Managing Dependencies with Composer: A Beginner’s Guide

    10 Simple Ways to Speed Up Your WordPress Website

    10 Simple Ways to Speed Up Your WordPress Website

    View 48 Comments

    48 Comments

    1. Khurram Arif on August 5, 2021 12:07 pm

      what is php service to check is running after installation and modules installation

      Reply
    2. Anvi on January 23, 2021 11:48 am

      Thanks for the post!

      Reply
    3. Damien on November 1, 2020 5:24 pm

      After adding ondrej repository,
      I ran the update command, but I get this error:

      Hit:1 https://packages.sury.org/php stretch InRelease
      Ign:2 http://ppa.launchpad.net/ondrej/php/ubuntu hirsute InRelease
      Err:3 http://ppa.launchpad.net/ondrej/php/ubuntu hirsute Release
      404 Not Found
      Reading package lists… Done

      Please is there a solution to this ?

      Reply
    4. Anais on October 5, 2020 11:02 am

      Hello, I’m setting a new server for a website on ubuntu 18.04 and when I install php 7.1 with ondrej ppa it installs php7.1-mapi
      “Note, selecting ‘php7.1-mapi’ for regex ‘php7.1′”
      I tried 7.0 or 7.3 and it says : “E: Unable to locate package php7.3
      E: Couldn’t find any package by glob ‘php7.3’
      E: Couldn’t find any package by regex ‘php7.3′”
      Last year I already installed ondrej ppa with 7.1 on another server ubuntu 18.04 and it worked fine. Now it won’t there’s only php 7.2 and as there are compatiblities issues, I want the 7.1.

      Reply
    5. bahador on June 16, 2020 3:49 am

      thank you very much!

      Reply
    6. Tăng Danh on May 15, 2020 2:20 pm

      Thank you so much !

      Reply
    7. Bobbler on May 12, 2020 10:00 am

      Thanks for providing install instructions to the newer php7.4.5 I couldn’t find how to install it anywhere. This article helped. A lot.

      Reply
    8. @CNSKnight on February 15, 2020 11:38 pm

      `apt-get` > just `apt`

      Reply
    9. syaikhul on September 4, 2019 4:51 am

      Pleas help me to solve this problem.! i’m beginner

      You might want to run ‘apt –fix-broken install’ to correct these.
      The following packages have unmet dependencies:
      default-jre-headless : Depends: openjdk-11-jre-headless
      hhvm : Depends: libboost-context1.65.1 but it is not going to be installed
      Depends: libboost-program-options1.65.1 but it is not going to be installed
      Depends: libdwarf1 (>= 20160507+git20160523.9086738) but it is not going to be installed
      Depends: libgoogle-glog0v5 but it is not going to be installed
      Depends: libjemalloc1 (>= 3.5.0) but it is not going to be installed
      Depends: libmcrypt4 but it is not going to be installed
      Depends: libmemcached11 but it is not going to be installed
      Depends: libodbc1 (>= 2.3.1) but it is not going to be installed
      Depends: libonig4 (>= 5.9.5) but it is not going to be installed
      Depends: libre2-4 (>= 20160901) but it is not going to be installed
      Depends: libtbb2 but it is not going to be installed
      openjdk-11-jre : Depends: openjdk-11-jre-headless (= 11.0.2+9-3ubuntu1~18.04.3)
      E: Unmet dependencies. Try ‘apt –fix-broken install’ with no packages (or specify a solution).

      Reply
    10. Jose G. on August 1, 2019 2:00 am

      Thanks. It’s so usefull.

      Gracias.. Muy util. Saludos.

      Reply
    11. Vishwas on July 12, 2019 7:25 am

      Getting this on sudo apt-get install php7.2

      Reading package lists… Done
      Building dependency tree
      Reading state information… Done
      E: Unable to locate package php7.2
      E: Couldn’t find any package by regex ‘php7.2’

      Reply
      • Rahul on July 12, 2019 9:04 am

        Which Ubuntu version are you using?

        Reply
        • Timothy on July 30, 2019 3:44 am

          This is the error message I’m getting with Ubuntu 16.04. I don’t know what version Vishwas was using though. Thank you for your valuable help in making the world a better place!

          Reply
    12. MOHD AIDI on May 30, 2019 6:17 am

      hi,
      can you suggest me how to install php7.1-curl in ubuntu 14.04?

      i have tried many ways but cannot find the ext curl in repo. please help me sir.

      Reply
    13. Manoj Gupta on March 4, 2019 7:00 pm

      Hi,

      Can you please let me know, how to install php7.1.33 in Ubuntu 16.04 server.

      I tried with the above solution but from this solution, I can install only 7.1.26.

      Please suggest.

      Regards;
      Manoj Gupta

      Reply
    14. sandy on February 6, 2019 12:15 pm

      thanks for valubal answer

      Reply
    15. sarfaraz on January 3, 2019 9:19 am

      LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php

      Reply
    16. aditia on December 8, 2018 12:32 am

      hello is there any way to upgrade php 7.2 to 7.3? i’m currently running php 7.2 want to upgrade to php 7.3 but i’m afraid breaking the system

      Reply
    17. Isaac Rosario Durán on August 15, 2018 10:05 pm

      I need some help. I can’t instll some extensions on PHP (Ubuntu server v18) MBString and ZIP.
      When i try to install i got the follow error.

      —– Error below —–

      Reading package lists… Done
      Building dependency tree
      Reading state information… Done
      E: Unable to locate package php7.2-mbstring
      E: Couldn’t find any package by glob ‘php7.2-mbstring’
      E: Couldn’t find any package by regex ‘php7.2-mbstring’
      E: Unable to locate package php7.2-zip
      E: Couldn’t find any package by glob ‘php7.2-zip’
      E: Couldn’t find any package by regex ‘php7.2-zip’

      Reply
    18. Mayank jadeja on May 28, 2018 1:47 pm

      Hello,
      Is there any way by which I can install php 7.1.0 or 7.0.2 in Ubuntu 18.04.
      As i want to work on Magento 2 & its not compatible with PHP versions like 7.2.x , 7.1.1 or 7.0.3

      Reply
    19. Diogo Morais on May 4, 2018 9:48 am

      The Brazil thanks you.

      Reply
    20. Oliver Russell on April 18, 2018 7:34 am

      If you are installing PHP 7.2 on a server, then I would recommend using Cloudways for it. This php 7.2 hosting (https://www.cloudways.com/blog/php-7-2-hosting-on-cloudways/ ) allows you to launch a PHP server on cloud in just one click and then upgrade your version to 7.2 from server management settings in one-click as well. The whole process takes under 20minutes.

      Reply
    21. Raju ginne on February 15, 2018 6:08 am

      can you write a tutorial about compiling php latest from source i tried but confusing

      Reply
    22. Raju ginne on January 18, 2018 4:46 am

      hello there is an update(7.2.1 ) on jan 4 2018/ how to upgrade from php.net launch pad net not working.

      getting count() issues
      PHP Warning: count(): Parameter must be an array or an object that implements Countable

      Reply
      • Rahul K. on January 18, 2018 5:56 am

        Yes, simply upgrade to PHP 7.2.1 also not worked for me. So I removed current version

        apt purge php7.2*

        and install it again with all required modules. It worked for me.

        apt install php7.2

        Reply
    23. Sanjay kumar on December 5, 2017 9:10 am

      i get this error..after php7.2
      php: symbol lookup error: php: undefined symbol: pcre_jit_exec

      Reply
      • Rahul K. on December 5, 2017 9:17 am

        Which OS are you using? Are you using a 32bit system? Please try to update libpcre3 package on your system.

        Reply
        • RONALD on September 7, 2018 4:18 am

          Thank you sir. this worked for me too 🙂

          Reply
    24. Raju ginne on December 3, 2017 4:24 am

      Thank you for updating php 7.2

      Reply
    25. Anjanesh Lekshminarayanan on December 2, 2017 3:03 pm

      How do I setup my Apache’s directory’s .htaccess in such a way that for this specific directory execute php7.1 for .php files ?

      Reply
    26. Akash on November 23, 2017 4:12 pm

      Nice post .Thanks for this awesome post.

      Reply
    27. Alex on October 22, 2017 9:06 am

      Rahul, how I can fast switch between PHP 7.0 – 7.1 using PPA ?

      Reply
    28. Alex on October 22, 2017 8:56 am

      Thanks Rahul. Very useful article.

      Reply
    29. Waqas Ahmed on September 14, 2017 11:02 am

      Thank you for your effort, it saves a day 🙂

      Reply
    30. Paventhan on July 15, 2017 10:43 am

      Hi Rahul, is it good to install the PHP 7.1 for the production use, because i heared we cant find any library files for the latest version of PHP.

      Reply
    31. Kevin on February 22, 2017 3:37 pm

      Adding the repository results in the following message:

      “PLEASE DON’T USE PHP 5.4 OR PHP 5.5. The PHP 5.5 and later are no longer supported with security updates, therefore they are not included in this repository.”

      I think you meant to say: “The PHP 5.5 and EARLIER are no longer supported . . . .” Right?

      Reply
      • Rahul K. on February 23, 2017 6:55 am

        Yes Kevin,

        I agree with you. I have informed the repository owner regarding it.

        Reply
    32. Harshal on January 19, 2017 2:04 pm

      Thanks, Rahul,

      I am a Web Developer and recently shifted to Ubuntu, i was searching for 3-5 hours to install PHP7. Glad to find your blog.

      Harshal,
      https://www.pitechnologies.org

      Reply
    33. sandeep on May 27, 2016 9:57 am

      You Are relay save my day Thanks for this Grate Tutorial

      Reply
    34. Jagroop Singh on February 23, 2016 5:14 am

      Thanks for saving my day 🙂

      Reply
    35. Al on January 23, 2016 3:13 am

      Thanks for this!
      I had to also add python-software-properties-common in order to get add-apt-repository.
      I’m on 15.10

      Reply
    36. Ondřej Surý on January 15, 2016 9:20 am

      Rahul, could you please update the article to point to ppa:ondrej/php, I will be deprecating php-7.0 as the co-installable repository is working just fine, so I am just building the same packages twice. I am trying to hunt down all the popular articles around, so I could kill the ppa:ondrej/php-7.0.

      Thanks,
      Ondrej

      Reply
      • Rahul on January 15, 2016 12:54 pm

        Thanks for your information. We have updated article accordingly.

        Reply
    37. Milan on January 4, 2016 12:49 pm

      Hi,

      it is posible to use two version of php – 5.6 and 7 ?
      5.6 for deployment and 7 for experiments in CLI or separated php7-fpm server.

      Thank you.

      Reply
      • Ondřej Surý on February 23, 2016 6:39 am

        Sure, ppa:ondrej/php contains both PHP 5.6 and 7.0 that could be installed together. You just cannot enable both PHP Apache modules at the same time.

        Reply
    38. Guilherme on December 29, 2015 3:04 am

      Hi, how can I install phpMyAdmin with PHP7.0? Thank you.

      Reply
      • Rahul on December 29, 2015 7:36 am

        Hi,

        Download phpMyAdmin source code and extract on DocumentRoot. Currently I could not found any phpmyadmin packages which support php7

        https://www.phpmyadmin.net/downloads/

        Reply
      • Ferri Sutanto on February 28, 2016 5:54 am

        Maybe you want to try single file database management called Adminer .. its so fast and light

        https://www.adminer.org/

        Reply

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • 20 Basic Linux Commands for the Beginners (Recommended)
    • tail Command in Linux with Examples
    • What is a Orphan Process in Unix/Linux
    • How To Display Warning Message to Unauthorized SSH Access
    • How to Set a Custom SSH Login Banner and MOTD
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.