How to install PHP (multiple versions) and Composer
Updated 10/16/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 pricingRelated tutorials
How to send WhatsApp messages from your apps with OpenWA
OpenWA gives you a REST API over WhatsApp, on your own server. Here is how to install it, connect it and send your first message, safely.
Updated 10/16/2026Dev environmentsHow to deploy an app from Git with Openship
From a Git repo to a live app, with a database, domain and SSL, on your own server, with no config files.
Updated 10/16/2026Dev environmentsHow to create a systemd service for your app
Make your app start automatically and restart itself if it stops, with a systemd service.
Updated 10/16/2026