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 pricingRelated tutorials
Dev environments
How to create a systemd service for your app
Make your app start automatically and restart itself if it stops, with a systemd service.
Updated 7/20/2026Dev environmentsHow to keep sessions running after disconnect with tmux
tmux keeps your terminal sessions alive even after you close SSH, ideal for long-running tasks.
Updated 7/20/2026Dev environmentsHow to install Node.js with nvm (multiple versions)
Install and switch between multiple Node.js versions on the same server with nvm.
Updated 7/20/2026