How To Install Composer on Linux Mint 20
In this tutorial, we will show you how to install Composer on Linux Mint 20. For those of you who didn’t know, Composer is a powerful dependency manager for PHP, making it an essential tool for modern PHP development. It simplifies the process of installing, updating, and managing third-party libraries and dependencies, ensuring your projects have the required packages and versions.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo
‘ to the commands to get root privileges. I will show you the step-by-step installation of Composer on a Linux Mint 20 (Ulyana).
Prerequisites
- A server running one of the following operating systems: Linux Mint.
- It’s recommended that you use a fresh OS install to prevent any potential issues.
- Access to a terminal or command-line interface
- An active internet connection. You’ll need an internet connection to download the necessary packages and dependencies.
- root access or a user with sudo privileges.
Install Composer on Linux Mint 20 Ulyana
Step 1. It’s always a good practice to keep your system up-to-date with the latest security patches and bug fixes. Open a terminal and run the following command to update the package lists and installed packages:
sudo apt update
This command will update the package lists from the configured repositories and upgrade any outdated packages on your system.
Step 2. Installing dependencies.
Composer requires PHP and a few additional packages to be installed on your system. Run the following command to install PHP, unzip, and other necessary dependencies:
sudo apt install php-cli php-mbstring unzip
Step 3. Installing Composer on Linux Mint 20.
With the prerequisites in place, you can now download the Composer setup script. Open a terminal and navigate to the directory where you want to install Composer (e.g., your home directory or a project directory).
Run the following command to download the Composer installer script:
cd ~ curl -sS https://getcomposer.org/installer -o composer-setup.php
To install Composer globally, use the following command which will download and install Composer 2 as a system-wide command named composer, under /usr/local/bin
:
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
After the installation is complete, you can verify if Composer was installed successfully by running the following command:
composer --version
Run the following command to test your installation:
composer
As new versions of Composer are released, it’s recommended to keep your installation up-to-date to benefit from the latest features, bug fixes, and security improvements. To update Composer to the latest version, run the following command:
composer self-update
Congratulations! You have successfully installed Composer. Thanks for using this tutorial for installing the latest version of Composer on the Linux Mint system. For additional help or useful information, we recommend you to check the official Composer website.