Laravel Composer PHP Artisan and Apache

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 list
sudo apt update && upgrade

2. Install apache server
sudo apt install apache2
systemctl status apache2

3. Start and enable apache2
systemctl 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 installed
php -- version

6. Configure PHP
cd /etc/php/7.4/apache2
sudo nano php.ini
Change to: cgi.fix_pathinfo=0
Save changes
Restart apache2
systemctl restart apache2

7. Install Composer
sudo apt install curl
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
composer --version

8. Install Laravel
composer global require laravel/installer

9 Configure Laravel
nano ~/.bashrc
Add the following to the end of the file:
export PATH="$HOME/.config/composer/vendor/bin:$PATH"
Reload bashrc
source ~/.bashrc
Confirm "Bin" is returned with this command:
echo $PATH

9. Create a new laravel app
cd ~
laravel new lavavel-app

10. Configure Apache for Laravel
sudo chgrp -R www-data lavavel-app/

11. Change permission 775 of the storage directory
sudo chmod -R 775 lavavel-app/storage/

3sL5Fwi3Z9M