Today I was working on a Laravel project and needed to have composer installed for a docker project. To install composer in a Linux Ubuntu machine is very simple. These are the commands to do it.
Update and Upgrade your package manager
sudo apt update && upgrade
Install the latest version of composer
sudo apt install composer
Once the installation completes, you can validate that composer is successfully installed in your computer with the following command:
composer -v
Update. These are some other notes I have regarding installing composer for laravel
1. Update package listsudo apt update && upgrade
2. Install apache serversudo apt install apache2
systemctl status apache2
3. Start and enable apache2systemctl start apache2
systemctl enable apache2
4. Install PHP 7.4 (PHP >= 7.3 is required for Laravel 8)sudo apt install libapache2-mod-php php php-common php-xml php-gd php-opcache php-mbstring php-tokenizer php-json php-bcmath php-zip unzip
5. Confirm php is installedphp -- version
6. Configure PHPcd /etc/php/7.4/apache2
sudo nano php.ini
Change to: cgi.fix_pathinfo=0
Save changes
Restart apache2systemctl restart apache2
7. Install Composersudo apt install curl
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
composer --version
8. Install Laravelcomposer global require laravel/installer
9 Configure Laravelnano ~/.bashrc
Add the following to the end of the file:export PATH="$HOME/.config/composer/vendor/bin:$PATH"
Reload bashrcsource ~/.bashrc
Confirm "Bin" is returned with this command:echo $PATH
9. Create a new laravel appcd ~
laravel new lavavel-app
10. Configure Apache for Laravel sudo chgrp -R www-data lavavel-app/
11. Change permission 775 of the storage directorysudo chmod -R 775 lavavel-app/storage/