Laravel 5 Installation in Ubuntu: laravel command

2019-03-07 16:55发布

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

8条回答
Rolldiameter
2楼-- · 2019-03-07 17:00

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.

查看更多
女痞
3楼-- · 2019-03-07 17:05

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
查看更多
戒情不戒烟
4楼-- · 2019-03-07 17:07

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

查看更多
Emotional °昔
5楼-- · 2019-03-07 17:07

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
查看更多
Anthone
6楼-- · 2019-03-07 17:08

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
查看更多
Lonely孤独者°
7楼-- · 2019-03-07 17:11

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

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

This saved my day!

查看更多
登录 后发表回答