Laravel 5 Installation in Ubuntu: laravel command not found
UbuntuLaravelComposer PhpLaravel 5Ubuntu Problem Overview
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
Ubuntu Solutions
Solution 1 - Ubuntu
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 - Ubuntu
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 - Ubuntu
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'
P.S. btw I am using
Debian GNU/Linux 7.8 (wheezy)
PowerMac8,2
ppc64
Solution 4 - Ubuntu
In Ubuntu 16 the path is under the ~./config
directory as shown below.
export PATH="~/.config/composer/vendor/bin:$PATH"
Solution 5 - Ubuntu
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
Solution 6 - Ubuntu
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
Solution 7 - Ubuntu
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:
-
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. -
then in terminal,
cd ~
, and thensudo nano .bashrc
-
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). -
press Ctrl + X, then Y and Enter, to save changes.
-
refresh changes with
source ~/.bashrc
-
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.
Solution 8 - Ubuntu
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