Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Programming»PHP»How to Install PHP 8.x on Pop!_OS

    How to Install PHP 8.x on Pop!_OS

    By RahulJanuary 25, 20233 Mins ReadUpdated:January 25, 2023

    If you want to develop web applications using PHP on Pop!_OS, you may need to install multiple versions of PHP for testing or compatibility purposes. One way to install multiple versions of PHP on Pop!_OS is to use a Personal Package Archive (PPA). At the day of writing this tutorial PHP 8.2 is the latest version available.

    Advertisement

    In this article, we will discuss the steps for installing PHP 8.2, PHP 8.1 or PHP 8.0 versions on Pop!_OS using a PPA.

    Steps to Install PHP on Pop!_OS

    To install PHP on Pop!_OS using a Personal Package Archive (PPA), you can follow these steps:

    1. Install required packages
    2. Open a terminal and install the software-properties-common package, which provides the “add-apt-repository” command that you will use to add the PPA:

      sudo apt update 
      sudo apt install software-properties-common 
      

    3. Add the Ondřej Surý PPA
    4. Add the Ondřej Surý PPA, which provides updated versions of PHP:

      sudo add-apt-repository ppa:ondrej/php
      

      Update the package list again to include the packages in the PPA:

      sudo apt update
      

    5. Installing PHP 8 on Pop!_OS
    6. Now, execute the following command to install PHP using the apt package manager:

      sudo apt install php8.2
      

      Replace “8.2” with the desired version of PHP like “8.1”, “8.0”, “7.4” or “5.6”. This will also install the PHP package manager “composer” (PHP Package Manager).

    7. Install PHP modules
    8. You can also install the PHP modules that is required for your application. The below given command will install mysql, zip and curl php modules.

      sudo apt install php8.2-mysql php8.2-zip php8.2-curl 
      

      Make sure to use correct php version with command.

    9. Verify PHP installation
    10. Verify that PHP was installed correctly by running the following command:

      php -v 
      

      You should see the version of PHP that you installed.

      Output
      PHP 8.2.1 (cli) (built: Jan 13 2023 10:43:08) (NTS) Copyright (c) The PHP Group Zend Engine v4.2.1, Copyright (c) Zend Technologies with Zend OPcache v8.2.1, Copyright (c), by Zend Technologies

    Switch Between Multiple PHP Versions

    You can use `update-alternatives` command to set or change the default PHP version.

    sudo update-alternatives --config php
    

    The command will list all installed PHP versions on your system. From which you can set the default PHP version.

    There are 3 choices for the alternative php (providing /usr/bin/php).
    
      Selection    Path             Priority   Status
    ------------------------------------------------------------
    * 0            /usr/bin/php8.2   82        auto mode
      1            /usr/bin/php7.4   74        manual mode
      2            /usr/bin/php8.1   81        manual mode
      3            /usr/bin/php8.2   82        manual mode
    
    Press  to keep the current choice[*], or type selection number:
    

    Input a selection number to set default PHP version for the command line.

    Note: This will not change the default PHP version for Apache.

    Conclusion

    Installing multiple PHP versions on Pop!_OS using a PPA involves adding the PPA to your system, updating the package list, and installing the desired PHP version using the apt package manager. This is a relatively easy way to install PHP, but it is important to note that using a PPA can introduce compatibility issues and security risks. It is generally better to use the Pop!_OS package manager or install PHP from source. Regardless of which method you choose, it is important to keep your PHP installation up to date to ensure security and compatibility.

    install php PHP PHP 8 PHP 8.1 PHP 8.2
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    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

    How to Install Composer on Ubuntu 22.04

    How to Install Composer on Ubuntu 22.04

    Add A Comment

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • Error: EACCES: permission denied, scandir (Resolved)
    • How To Install Python 3.11 on Ubuntu 22.04 / 20.04
    • How to Install Python 3.11 on Amazon Linux 2
    • An Introduction to the “./configure” Command: Compiling Source Code in Linux
    • How to Install PHP 8.x on Pop!_OS
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

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