How to install PHP (multiple versions) and Composer
Updated 11/29/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
Error tracking for your applications with GlitchTip
Catch production exceptions with the Sentry SDKs on a small server: the project, the DSN, alerts and uptime.
Updated 11/29/2026Dev environmentsTest your application's email with smtp4dev
Send the email from Laravel, WordPress, Node or Python to a test SMTP server and read it in a web inbox, without it ever reaching real customers.
Updated 11/29/2026Dev environmentsHow to set up a staging environment
Test changes on a copy of production before shipping them, to avoid surprises.
Updated 11/29/2026