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条回答
混吃等死
2楼-- · 2019-03-07 17:14

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"
查看更多
我欲成王,谁敢阻挡
3楼-- · 2019-03-07 17:23

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

export PATH="~/.config/composer/vendor/bin:$PATH"
查看更多
登录 后发表回答