Laravel 5 Installation in Ubuntu: laravel command not found [duplicate]

Solution 1:

Got fixed after setting path for composer vendors.So the correct step which worked is,

Download laravel installer: composer global require "laravel/installer=~1.1"

Setup PATH: export PATH="~/.composer/vendor/bin:$PATH"

Then run command : laravel new project-name or sudo laravel new project-name

For mac,

echo 'export PATH="$HOME/.composer/vendor/bin:$PATH"' > ~/.bashrc
source ~/.bashrc

Ubuntu 16.04 with latest laravel installer

Install composer if not exists,

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('SHA384', 'composer-setup.php') === '55d6ead61b29c7bdee5cccfb50076874187bd9f21f65d8991d46ec5cc90518f447387fb9f76ebae1fbbacf329e583e30') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
sudo mv composer.phar /usr/local/bin/composer

Install laravel installer,

composer global require "laravel/installer"

Edit environment config,

nano .bashrc

Then add,

export PATH="$PATH:$HOME/.config/composer/vendor/bin"

Then reload path config,

source ~/.bashrc

Ubuntu 17.04 and 17.10:

export PATH="~/.config/composer/vendor/bin:$PATH"

Ubuntu 18.04

export PATH="$HOME/.composer/vendor/bin:$PATH"

Solution 2:

After searching in internet I was found for Ubuntu 17.04, 17.10, 18.04 and 20.04 this code that work's fine:

export PATH="~/.config/composer/vendor/bin:$PATH"

This saved my day!

Solution 3:

If for some reasons previous Answer doesn't work, like in my situation, try this (as a root or with sudo):

nano ~/.bashrc

and then put to the end of the file this:

alias laravel='~/.composer/vendor/bin/laravel'

Source

P.S. btw I am using

Debian GNU/Linux 7.8 (wheezy)
PowerMac8,2
ppc64