How to Install Composer on Pop!_OS / Ubuntu
Composer is the standard dependency manager for PHP. If you're setting up Laravel, Symfony, or really any modern PHP project, this is one of the first tools you'll install. This guide covers installing it on Pop!_OS or any Ubuntu-based distribution, with the official hash-verification step so you're not just trusting a random script.
Prerequisites
You'll need:
A Pop!_OS or Ubuntu system with terminal (sudo) access
gitandcurlinstalled
Check whether you already have them:
git -v && curl -V
If either is missing:
sudo apt-get install git curl
Step 1 — Install PHP CLI and Required Extensions
Composer needs php-cli to run, and unzip to extract package archives.
sudo apt update
sudo apt install php-cli unzip
Confirm the installation with Y when prompted.
Step 2 — Download the Composer Installer
Composer installs itself using a small PHP script. Download it to a temporary location:
cd ~
curl -sS https://getcomposer.org/installer -o /tmp/composer-setup.php
Step 3 — Verify the Installer
Don't skip this — it confirms the script you downloaded hasn't been tampered with. Composer publishes the expected hash at getcomposer.org/download; fetch it programmatically and compare:
HASH=$(curl -sS https://composer.github.io/installer.sig)
php -r "if (hash_file('SHA384', '/tmp/composer-setup.php') === '$HASH') { echo 'Installer verified' . PHP_EOL; } else { echo 'Installer corrupt' . PHP_EOL; unlink('/tmp/composer-setup.php'); }"
You should see:
Installer verified
If you see Installer corrupt instead, delete the file and re-download it — don't proceed with a script that fails verification.
Step 4 — Install Composer Globally
This installs Composer as a system-wide composer command:
sudo php /tmp/composer-setup.php --install-dir=/usr/local/bin --filename=composer
You should see output confirming the install, ending with something like:
Composer (version 2.x.x) successfully installed to: /usr/local/bin/composer
Use it: php /usr/local/bin/composer
Step 5 — Verify the Installation
composer --version
You'll see Composer's ASCII logo and its version number printed — confirmation it's installed and available from anywhere on your system.
Step 6 — Clean Up
Remove the temporary installer script now that it's no longer needed:
rm /tmp/composer-setup.php
Common Issues
composer: command not found — Check that /usr/local/bin is in your PATH: echo $PATH. If it's missing, add export PATH="/usr/local/bin:$PATH" to your ~/.bashrc and reload with source ~/.bashrc.
Permission errors during install — Make sure you're running Step 4 with sudo, since it writes to /usr/local/bin, a system directory.
Wrong PHP version picked up — If you have multiple PHP versions installed, php-cli might not point at the one you expect. Run php -v to check, and use update-alternatives --config php to switch if needed.
What's Next
With Composer installed, you're ready to scaffold a new project:
composer create-project laravel/laravel my-app
Or add Composer as a dependency manager to an existing PHP project by running composer init in its root directory.