vagrant简易安装
本文会教你如何使用vagrant用最少的步骤安装和运行一个虚拟机器。这是给初学者的安装建议,它会帮助你解决许多安装过程中常见的陷阱。
github上的安装教程请见:https://github.com/edx/edx-platform#installation—the-first-time
故障排除
这一章节会介绍一些vagrant安装过程中的坑,你也可以去谷歌小组edx[general]小组寻找自己的问题解决的方案。
检查VirtualBox/Vagrant的版本
如果使用Vagrant安装和运行虚拟出现问题,第一步请检查一下VirtualBox和Vagrant 的版本,VirtualBox >=4.2.16,Vagrant >=1.3.5.
重安装
如果安装出错,你可以轻易的使用一下命令重新安装。
$ vagrant destroy -f && vagrant up
这一个命令会删除当前虚拟主机,并创建新的虚拟主机,并重新安装所有的依赖包和配置环境。
需要AWS 和互联网虚拟机服务商?
不需要,
安装NFS共享文件夹
“The following SSH command responded with a non-zero exit status.”
如果出现一下错误:
[default] Mounting NFS shared folders...
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!
mount -o vers=3 192.168.20.1:'/Users/Bluelysium/edx-platform' /edx/edx-platform
Mac操作系统第一次尝试共享文件的时候就会报错提醒:
$ vagrant halt ; vagrant up
如果仍远不能解决活动,请关闭防火墙,使用debug模式重新运行
$ VAGRANT_LOG=debug vagrant destroy -f && vagrant up
出错信息是”It appears your machine doesn’t support NFS”
如果你运行$ vagrant up
出线以下报错信息
It appears your machine doesn't support NFS, or there is not an
adapter to enable NFS on this machine for Vagrant. Please verify
that `nfsd` is installed on your machine, and try again. If you're
on Windows, NFS isn't supported.
你需要安装NFS服务,在Debian/Ubuntu使用一下命令进行安装。
$ sudo apt-get install nfs-common nfs-kernel-server
下载precise32镜像文件
如果下载precise32文件网速很慢或者链接失败,请手动下载,以下是地址http://files.vagrantup.com/precise32.box
然后加载镜像
$ vagrant box add precise32 /path/to/precise32.box
最后运行
$ vagrant destroy -f && vagrant up
处理Windows操作系统行结束和连接符号问题
在Windows运行vagrant up
你需要安装最新的cygwin,并且在cygwin终端里输入命令行
这听起来有点恐怖,是的而且你还需要使用麻省理工的Vagrant 镜像替换原有的镜像。这样做很可能不便于管理源代码,但是可以轻松在windows下运行edx程序.
运行一下程序可以方便的进入edx-platform
根目录
# You need to run this from cygwin, not the Windows command-line (see above)
git rm --cached -r . && git reset --hard
git config --global alias.add-symlink '!__git_add_symlink(){ dst=$(echo "$2")/../$(echo "$1"); if [ -e "$dst" ]; then hash=$(echo "$1" | git hash-object -w --stdin); git update-index --add --cacheinfo 120000 "$hash" "$2"; git checkout -- "$2"; else echo "ERROR: Target $dst does not exist!"; echo " Not creating invalid symlink."; fi; }; __git_add_symlink "$1" "$2"'
git config --global alias.rm-symlink '!__git_rm_symlink(){ git checkout -- "$1"; link=$(echo "$1"); POS=$'\''/'\''; DOS=$'\''\\\\'\''; doslink=${link//$POS/$DOS}; dest=$(dirname "$link")/$(cat "$link"); dosdest=${dest//$POS/$DOS}; if [ -f "$dest" ]; then rm -f "$link"; cmd //C mklink //H "$doslink" "$dosdest"; elif [ -d "$dest" ]; then rm -f "$link"; cmd //C mklink //J "$doslink" "$dosdest"; else echo "ERROR: Something went wrong when processing $1 . . ."; echo " $dest may not actually exist as a valid target."; fi; }; __git_rm_symlink "$1"'
git config --global alias.rm-symlinks '!__git_rm_symlinks(){ for symlink in `git ls-files -s | grep -E "^120000" | cut -f2`; do git rm-symlink "$symlink"; git update-index --assume-unchanged "$symlink"; done; }; __git_rm_symlinks'
git config --global alias.checkout-symlinks '!__git_checkout_symlinks(){ POS=$'\''/'\''; DOS=$'\''\\\\'\''; for symlink in `git ls-files -s | grep -E "^120000" | cut -f2`; do git update-index --no-assume-unchanged "$symlink"; if [ -d "$symlink" ]; then dossymlink=${symlink//$POS/$DOS}; cmd //C rmdir //S //Q "$dossymlink"; fi; git checkout -- "$symlink"; echo "Restored git symlink $symlink <<===>> `cat $symlink`"; done; }; __git_checkout_symlinks'
git rm-symlinks
第一行确保所有的文件的结束符正确。
第四行为连接符添加别名,最后一行创建新的连接符