As of today PHP 8 is the latest available version and is recommended to run your production websites. But many of the older websites still required PHP 7.x or PHP 5.6 to run. The application still using PHP 5.6 are advised to immediately upgrade to PHP 7.4 or the latest PHP versions. One way to install PHP on Pop!_OS is to use a Personal Package Archive (PPA).

Advertisement

This article provides you with the steps for installing PHP 7.4 or PHP 5.6 on Pop!_OS using a PPA.

  • How to Install PHP 8.x on Pop!_OS
  • Installing 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

      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 
      
    2. Add the Ondřej Surý PPA

      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
      
    3. Installing PHP 7.4 on Pop!_OS

      Now, execute the following command to install PHP using the apt package manager:

      sudo apt install php7.4
      
    4. Installing PHP 5.6 on Pop!_OS

      PHP 5.6 is no more maintained by the official team. So its strictly recommended to upgrade your application to the latest version. But if you still need to install PHP 5.6, use the following command:

      sudo apt install php5.6
      
    5. Install PHP modules

      You can also install the PHP modules that are required for your application. The below-given command will install MySQL, Zip, and Curl PHP modules.

      sudo apt install php7.4-mysql php7.4-zip php7.4-curl 
      

      Make sure to use the correct PHP version with the command.

    6. Verify PHP installation

      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 7.4.33 (cli) (built: Nov 8 2022 11:33:35) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies with Zend OPcache v7.4.33, Copyright (c), by Zend Technologies

    Conclusion

    This tutorial helped you to install PHP 7.4 or PHP 5.6 on your Pop!_OS system via PPA. 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 the source.

    Share.
    Leave A Reply


    Exit mobile version