Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

When I try to install laravel 5 in ubuntu, I am getting error like this,

laravel: command not found

I followed these steps,

composer global require "laravel/installer=~1.1"

laravel new blog

like image 864
Anshad Vattapoyil Avatar asked Feb 19 '15 02:02

Anshad Vattapoyil


3 Answers

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"
like image 139
Anshad Vattapoyil Avatar answered Nov 16 '22 06:11

Anshad Vattapoyil


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!

like image 56
Radames E. Hernandez Avatar answered Nov 16 '22 06:11

Radames E. Hernandez


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
like image 23
SharkWeb Avatar answered Nov 16 '22 06:11

SharkWeb