Skip to content

Instantly share code, notes, and snippets.

@rajibbinalam
Last active January 5, 2025 11:12
Show Gist options
  • Save rajibbinalam/195be51ce9f9fd3ac46c38ce1243f061 to your computer and use it in GitHub Desktop.
Save rajibbinalam/195be51ce9f9fd3ac46c38ce1243f061 to your computer and use it in GitHub Desktop.
Setup Multiple PHP on Linux (Zorin OS)

To install PHP 8.1 alongside PHP 7.4 on Zorin OS without uninstalling the existing version, you can follow these steps:

  1. Add Repository:

    sudo add-apt-repository ppa:ondrej/php

    This command adds the PHP repository maintained by Ondřej Surý, who provides up-to-date PHP packages for Ubuntu-based systems.

  2. Update Package List:

    sudo apt update
  3. Install PHP 8.1:

    sudo apt install php8.1

    During the installation, you might be prompted to choose between Apache and Nginx. Select the web server you are using or 'None' if you're not using a web server at the moment.

  4. Install PHP Extensions: You might need to install additional PHP extensions that you had for PHP 7.4. You can do this using apt and the php8.1 prefix.

    sudo apt install php8.1-{extension-name}
  5. Switch PHP Version: Use the update-alternatives command to switch between PHP versions. For example, to switch to PHP 8.1:

    update-alternatives --config php 

    OR

    sudo update-alternatives --set php /usr/bin/php8.1

    To switch back to PHP 7.4, you can use:

    sudo update-alternatives --set php /usr/bin/php7.4
  6. Verify PHP Version: Check the PHP version to ensure the switch was successful:

    php -v

Now, you should have both PHP 7.4 and PHP 8.1 installed on your Zorin OS, and you can switch between them using the update-alternatives command.

Remember to update your web server configuration to use the appropriate PHP version based on your project requirements.

@trvpboi50
Copy link

lit

@rajibbinalam
Copy link
Author

I don't understand what you say by lit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment