56

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

Anshad Vattapoyil
  • 23,145
  • 18
  • 84
  • 132

8 Answers8

216

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"
Krishna Raj
  • 846
  • 1
  • 12
  • 33
Anshad Vattapoyil
  • 23,145
  • 18
  • 84
  • 132
57

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!

Radames E. Hernandez
  • 4,235
  • 27
  • 37
23

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
SharkWeb
  • 361
  • 1
  • 5
22

In Ubuntu 16 the path is under the ~./config directory as shown below.

export PATH="~/.config/composer/vendor/bin:$PATH"
tylersDisplayName
  • 1,603
  • 4
  • 24
  • 42
12

Install composer

check if the composer is working by typing

composer

once the composer is installed, install laravel/installer via composer using the following command

composer global require "laravel/installer"

after installing export the path

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

Then

 source ~/.bashrc
Jagadesha NH
  • 2,529
  • 2
  • 23
  • 41
9

Open terminal and run these commands:

For zsh and bash:

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

source ~/.zshrc
source ~/.bashrc

For bash only:

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

source ~/.bashrc
Md Rasel Ahmed
  • 1,025
  • 9
  • 12
6

I found the solution after i tried many many times. First, check your actual path to the laravel installer. You need to go to /home/(here is your name)/.config/composer/vendor/bin ... to check if it really exist that path. In the beginning i got the 'laravel command not found' and 'bash: /home/eduard/.composer/vendor/bin/laravel: No such file or directory', so i checked if the path was correct, and it really wasn't, my path was /home/eduard/.config/composer/vendor/bin, i was different from any paths i found on internet. After composer global require "laravel/installer=~1.1", the solution is:

  1. go using the terminal to the path to see if it's different, until you find /bin. So, go to /home/(here you put your name)/.config/composer/vendor/bin (this is my path), and remember the path.
  2. then in terminal, cd ~, and then sudo nano .bashrc
  3. scroll down to the ending of the file and add:

    export PATH="$PATH:~/.config/composer/vendor/bin" alias laravel='~/.config/composer/vendor/bin/laravel' (!! important: keep in mind that your path may be a little bit different, make sure that the path exist like in step 1, if it's a little bit different then change it as it's your).

  4. press Ctrl + X, then Y and Enter, to save changes.
  5. refresh changes with source ~/.bashrc
  6. enter laravel in terminal to see if everything is ok.

Keep in mind that your path may be different from any on the web, make sure that your the path it's correct, check it, and put the right one as I did. I'm using Ubuntu 16, but the solution I think is similar for any version, as long as you put your correct path.

Stephen Kennedy
  • 20,585
  • 22
  • 95
  • 108
Robu Eduard
  • 61
  • 1
  • 3
4

I followed this process installing Laravel 5 on my Linux Mint(Ubuntu-based distro): (I have written full steps to help anyone who needed simple steps.)

// download composer
curl -sS https://getcomposer.org/installer | php

// moved it to user folder
sudo mv composer.phar /usr/local/bin/composer

// download the Laravel installer using Composer
composer global require "laravel/installer=~1.1"

// add laravel installer to PATH
export PATH="$PATH:$HOME/.composer/vendor/bin"

// create folder for laravel
mkdir /home/badar/websites/laravel

// create a new project
laravel new blog

Community
  • 1
  • 1
Badar
  • 1,430
  • 1
  • 15
  • 19