Logo Logo
Back to list
Linux

Installing and Upgrading PHP on Linux Ubuntu/Debian

14. 03. 2026
Installing and Upgrading PHP on Linux Ubuntu/Debian

PHP is the heart of your web server. In a Linux environment (Ubuntu or Debian), installing and maintaining PHP via the terminal is fast and efficient. Below are the steps for a fresh installation and upgrading to the latest stable version 8.3.

Installing PHP

  1. Open the terminal and update your system packages:
    sudo apt update && sudo apt upgrade
  2. Install PHP (version 8.3 is recommended):
    sudo apt install php
  3. Verify the installation:
    php -v

    The current PHP version should be displayed.

  4. Install common extensions (for database work, XML, ZIP, etc.):
    sudo apt install php-cli php-mbstring php-curl php-xml php-zip php-mysql

Upgrading to PHP 8.3

  1. Add the Ondřej Surý PPA (repository for the latest PHP):
    sudo add-apt-repository ppa:ondrej/php -y
  2. Update lists and install version 8.3:
    sudo apt update
    sudo apt install php8.3 php8.3-cli php8.3-common php8.3-curl php8.3-mbstring php8.3-xml php8.3-zip
  3. Register and set PHP 8.3 as the default version:
    sudo update-alternatives --install /usr/bin/php php /usr/bin/php8.3 83
    sudo update-alternatives --set php /usr/bin/php8.3
  4. Verify the active version:
    php -v

    The output should now show PHP 8.3.x.

Hvala za obisk! Dodajam politiko zasebnosti.

© 2024 Vse pravice pridržane.

Vam je koda pomagala? Če želite podpreti moj trud pri pripravi vodičev in vzdrževanju strani, mi lahko namenite donacijo za kavo.