在 Ubuntu 14.04 上我尝试通过 Composer 建立 Drush。
我添加 PATH="~/.composer/vendor/bin:$PATH到服务器.bashrc或.bash_profile服务器上。
Drush 在服务器上正确调用。
但它不适用于远程:
ssh myalias 'drush'
bash: drush: command not found
我检查echo $PATH了网络服务器和远程,我看到:
/home/<MY_USER>/.composer/vendor/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games为什么有差异(没有差异/home/<MY_USER>/.composer/vendor/bin)?如何添加远程回调的正确路径?
我将在这里做出一些假设:
drush安装在~/.composer/vendor/binmyalias是您所在的远程主机的名称drushmyalias您提到的网络服务器实际上与示例命令中的相同bash当您使用 shell交互登录时,将执行bash启动脚本。.bash_profile如果你设置PATH在这里就一切都很好,你可以drush直接找到。
当您以非交互方式运行某些内容(例如 )时ssh remotehost id,没有登录 shell,因此.bash_profile不会运行。但是,由于您的 shell 是执行bash会话脚本的。.bashrc我怀疑你没有PATH在那里设置,所以drush找不到。
您有多种选择。这里有四点建议
.bashrc调用(我的偏好).bash_profilePATH=...行.bashrc(简单).bash_profile和移入由和.bashrc提供的公共文件(更优雅).bash_profile.bashrcdrush在系统位置(例如/usr/local/bin或 下的某个位置/opt)并确保该目录包含在系统范围的PATH设置中(较难)