CloudLinux.ro
Dev environments

How to install PHP (multiple versions) and Composer

Updated 7/20/2026

Different PHP applications require different versions. Here is how to install the right version and Composer, the PHP package manager.

1. Add the multi-version repository

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

2. Install the version you want

apt-get install -y php8.3 php8.3-fpm php8.3-mysql php8.3-mbstring php8.3-xml php8.3-curl

You can install several versions side by side (for example php8.2 and php8.3) and choose per site.

3. Switch the default CLI version

update-alternatives --config php

4. Install Composer

curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer

5. Check

php -v
composer --version

In production

Each site can use a different PHP-FPM version in its own server block, see LEMP stack and deploying Laravel to production.

Put this guide into practice on your own VPS

EU cloud servers, billed hourly, ready in minutes, with one-click installs for dozens of apps.

See pricing

Related tutorials