I'm on Ubuntu 14.04 and I've been trying all possible methods to install Laravel to no avail. Error messages everything I try. I'm now trying the first method in the quickstart documentation, that is, via Laravel Installer, but it says to "Make sure to place the ~/.composer/vendor/bin directory in your PATH so the Laravel executable is found when you run the Laravel command in your terminal." so my question is, how do I do that? This may be a simple question but I'm really frustrated and would appreciate any help.
当前回答
在Fedora:
有些composer bin不在.composer目录中 所以你需要使用以下方法来定位它们:
locate composer | grep vendor/bin
然后在.bashrc中回显该部分
echo 'export PATH="$PATH:$HOME/{you_composer_vendor_path}"' >> ~/.bashrc
我的是"/.config/composer/vendor/bin" 干杯!
其他回答
AWS Ubuntu 18.04 LTS
Linux ws1 4.15.0-1023-aws #23-Ubuntu SMP Mon Sep 24 16:31:06 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
echo 'export PATH="$PATH:$HOME/.config/composer/vendor/bin"' >> ~/.bashrc && source ~/.bashrc
为我工作。
对于Linux Mint 18:编辑~/。Bashrc并在底部添加这一行:
export PATH="$PATH:$HOME/.config/composer/vendor/bin"
然后resource .bashrc(在控制台中输入):
source ~/.bashrc (or close and reopen the terminal)
通过在控制台中输入测试它:
echo $PATH
或者输入console:
laravel
在bashrc文件中添加环境变量
对于Ubuntu 17.04和17.10:
echo 'export PATH="~/.config/composer/vendor/bin"' >> ~/.bashrc
针对Ubuntu 18.04
echo 'export PATH="$PATH:$HOME/.composer/vendor/bin"' >> ~/.bashrc
检查环境变量是否工作,首先重新加载bashrc文件
source ~/.bashrc
如果没有任何工作方法,则首先检查安装Composer的位置以检查运行此命令:
locate composer -l 1
然后复制输出添加输出到这一行,并再次运行命令。
echo 'export PATH="OUTPUTHERE/vendor/bin"' >> ~/.bashrc
Laravel命令工作成功后,给父文件夹权限(例如,你正在使用apache服务器,而不是给apache web列表目录这样的权限)
sudo chown $USER:$USER -R /var/www/html/
打开Mac终端:
vi ~/.bashrc
如果你没有使用过vi,一开始看起来可能有点滑稽,所以仔细输入以下代码,按顺序:
i
export PATH="$PATH:$HOME/.composer/vendor/bin"
按ESC
:
w
按回车键
:
q
按回车键
现在您应该已经返回到正常的终端视图。
检查编写器现在有正确的路径:
cd ~/.composer
echo $PATH
如果您看到包含您的文件目录的路径(例如/Users/JeffStrongman/.composer/vendor/bin),那么您就可以开始了。
cd
然后运行安装。我在配置我的Mac使用Laravel Valet时遇到了这个问题。
示例(可选)
valet install
对我来说,在Ubuntu 22.04中,这是可行的:
export PATH="$PATH:$HOME/.config/composer/vendor/bin"