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.
当前回答
如果有人使用ZSH,所有步骤都是一样的,除了几件事:
找到文件。zshrc 在底部添加以下一行export PATH=~/.composer/vendor/bin:$PATH 源~ / . zshrc
然后试试男仆,如果问密码,那么一切都ok。
其他回答
我这样做了,它在osx上工作:
在终点站吃午餐
nano ~/.bash_profile
粘贴
export PATH=~/.composer/vendor/bin:$PATH
按control + x
按y键
按回车键
Composer bin目录被设置并存储在bin-dir配置变量中,根据您的设置可以有所不同。运行命令composer global config bin-dir——absolute会告诉你全局composer bin目录的绝对路径。使用这个命令,您可以修改.bash_profile,将其完全按照配置的方式添加到PATH中。
# Add Composer bin-dir to PATH if it is installed.
command -v composer >/dev/null 2>&1 && {
COMPOSER_BIN_DIR=$(composer global config bin-dir --absolute 2> /dev/null)
PATH="$PATH:$COMPOSER_BIN_DIR";
}
export PATH
在Fedora:
有些composer bin不在.composer目录中 所以你需要使用以下方法来定位它们:
locate composer | grep vendor/bin
然后在.bashrc中回显该部分
echo 'export PATH="$PATH:$HOME/{you_composer_vendor_path}"' >> ~/.bashrc
我的是"/.config/composer/vendor/bin" 干杯!
在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/
要解决这个问题,请确保您找到了作曲家的路径。phar第一
我的例子是这样的
alias composer="php /Users/Your-username/composer.phar"
进入cd Users >您的用户> Command ls,查看composer. sh是否存在。Phar在那里,如果是,然后将上面的行添加到.bash_profile。请确保将用户名更改为您自己的用户名。
希望这能帮到你