Ubuntu 中的 Laravel 5 安装:未找到 Laravel 命令
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28597648/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel 5 Installation in Ubuntu: laravel command not found
提问by devo
When I try to install laravel 5 in ubuntu, I am getting error like this,
当我尝试在 ubuntu 中安装 laravel 5 时,出现这样的错误,
laravel: command not found
laravel: command not found
I followed these steps,
我按照这些步骤,
composer global require "laravel/installer=~1.1"
composer global require "laravel/installer=~1.1"
laravel new blog
laravel new blog
回答by devo
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"
下载 Laravel 安装程序: composer global require "laravel/installer=~1.1"
Setup PATH: export PATH="~/.composer/vendor/bin:$PATH"
设置路径: export PATH="~/.composer/vendor/bin:$PATH"
Then run command : laravel new project-name
or sudo laravel new project-name
然后运行命令:laravel new project-name
或sudo laravel new project-name
For mac,
对于 mac,
echo 'export PATH="$HOME/.composer/vendor/bin:$PATH"' > ~/.bashrc
source ~/.bashrc
Ubuntu 16.04 with latest laravel installer
带有最新 Laravel 安装程序的 Ubuntu 16.04
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,
安装 Laravel 安装程序,
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:
Ubuntu 17.04 和 17.10:
export PATH="~/.config/composer/vendor/bin:$PATH"
Ubuntu 18.04
Ubuntu 18.04
export PATH="$HOME/.composer/vendor/bin:$PATH"
回答by TylersSN
In Ubuntu 16 the path is under the ~./config
directory as shown below.
在 Ubuntu 16 中,路径位于~./config
目录下,如下所示。
export PATH="~/.config/composer/vendor/bin:$PATH"
回答by Radames E. Hernandez
After searching in internet I was found for Ubuntu 17.04, 17.10and 18.04this code that work's fine:
在互联网上搜索后,我发现 Ubuntu 17.04、17.10和18.04这段代码运行良好:
export PATH="~/.config/composer/vendor/bin:$PATH"
This saved my day!
这拯救了我的一天!
回答by SharkWeb
If for some reasons previous Answer doesn't work, like in my situation, try this (as a root or with sudo):
如果由于某些原因以前的答案不起作用,例如在我的情况下,请尝试此操作(以 root 身份或使用 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
PS顺便说一句我正在使用
Debian GNU/Linux 7.8 (wheezy)
PowerMac8,2
ppc64
回答by Rasel Ahmed
Open terminal and run these commands:
打开终端并运行以下命令:
For zsh and bash:
对于 zsh 和 bash:
export PATH="$HOME/.config/composer/vendor/bin:$PATH"
source ~/.zshrc
source ~/.bashrc
For bash only:
仅用于 bash:
export PATH=~/.config/composer/vendor/bin:$PATH
source ~/.bashrc
回答by Jagadesha NH
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 后,使用以下命令通过 Composer 安装 laravel/installer
composer global require "laravel/installer"
after installing export the path
安装后导出路径
echo 'export PATH="$PATH:$HOME/.composer/vendor/bin"' >> ~/.bashrc
Then
然后
source ~/.bashrc
回答by Badar
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.)
我按照这个过程在我的 Linux Mint(基于 Ubuntu 的发行版)上安装 Laravel 5:(我已经写了完整的步骤来帮助任何需要简单步骤的人。)
// 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
// 下载 composer
curl -sS https://getcomposer.org/installer| php
// 将其移动到用户文件夹
sudo mv composer.phar /usr/local/bin/composer// 使用 Composer 下载 Laravel 安装程序
composer global require "laravel/installer=~1.1"// 将 laravel 安装程序添加到 PATH
export PATH="$PATH:$HOME/.composer/vendor/bin"// 为 laravel 创建文件夹
mkdir /home/badar/websites/laravel// 创建一个新项目
laravel 新博客
回答by Robu Eduard
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:
我尝试了很多次后找到了解决方案。首先,检查你的 Laravel 安装程序的实际路径。你需要去/home/(here is your name)/.config/composer/vendor/bin
...检查它是否真的存在那个路径。一开始我得到了'laravel command not found'和'bash: /home/eduard/.composer/vendor/bin/laravel: No such file or directory',所以我检查了路径是否正确,它确实是't,我的路径是/home/eduard/.config/composer/vendor/bin
,我不同于我在互联网上找到的任何路径。之后composer global require "laravel/installer=~1.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. - 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.
- 使用终端到路径看看它是否不同,直到找到
/bin
. 所以,去/home/(here you put your name)/.config/composer/vendor/bin
(这是我的路径),并记住路径。 - 然后在终端中,
cd ~
然后sudo nano .bashrc
向下滚动到文件末尾并添加:
export PATH="$PATH:~/.config/composer/vendor/bin" alias laravel='~/.config/composer/vendor/bin/laravel'
(!!重要:请记住,您的路径可能略有不同,请确保该路径存在于第 1 步中,如果有一点不同,则将其更改为您的路径)。- 按 Ctrl + X,然后按 Y 和 Enter,以保存更改。
- 刷新更改
source ~/.bashrc
- 进入
laravel
终端查看是否一切正常。
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.
请记住,您的路径可能与网络上的路径不同,请确保您的路径是正确的,检查它,然后像我一样输入正确的路径。我使用的是 Ubuntu 16,但我认为任何版本的解决方案都是相似的,只要你输入正确的路径。