厌烦了windows的终端,想和服务器保持一致的环境,想体验linux命令。在windows系统中安装虚拟机也许是最好的选择,既能保留windows的娱乐性,也能体验编码的乐趣。
vagrant安装使用
Vagrant就是为了方便的实现虚拟化环境而设计的,使用Ruby开发,基于VirtualBox等虚拟机管理软件的接口,提供了一个可配置、轻量级的便携式虚拟开发环境。
VirtualBox安装
VirtualBox是Oracle开源的虚拟化系统,它支持多个平台,所以你可以到官方网站:https://www.virtualbox.org/wiki/Downloads/ 下载适合你平台的VirtualBox最新版本并安装,它的安装过程都很傻瓜化,一步一步执行就可以完成安装了。
Vagrant安装
http://www.vagrantup.com/downloads.html 他的安装过程和VirtualBox的安装一样都是傻瓜化安装,一步一步执行就可以完成安装。
rails环境配置
参照此仓库的说明即可 https://github.com/rails/rails-dev-box
如果不嫌弃,也可以直接clone我的配置文件 https://github.com/btc022003/vagrant-rails
对vagrant配置有兴趣的可以参考这个链接 https://github.com/astaxie/go-best-practice/blob/master/ebook/zh/01.2.md
windows安装vagrant的时候需要注意,2.x的vagrant需要安装powershell5.x的版本,下载链接为:https://www.microsoft.com/en-us/download/details.aspx?id=54616
基于Ubuntu自己安装开发环境
- 安装nvm管理不同版本的nodejs
# nvm仓库链接地址:https://github.com/creationix/nvm
# 安装nvm
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
# 设置环境变量
source ~/.bashrc
# 测试是否安装成功
command -v nvm
# 输出
# nvm
# 安装nodejs
nvm install node
# 测试nodejs是否安装成功
node -v
npm -v
- 安装rbenv管理ruby的版本
更详细的使用说明可以参考:https://ruby-china.org/wiki/rbenv-guide
# rbenv仓库地址:https://github.com/rbenv/rbenv
# 下载仓库代码到本地
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
# 写环境变量
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
source ~/.bashrc
# 测试是否安装成功
type rbenv
# 输出
rbenv is a function
rbenv ()
{
local command;
command="${1:-}";
if [ "$#" -gt 0 ]; then
shift;
fi;
case "$command" in
rehash | shell)
eval "$(rbenv "sh-$command" "$@")"
;;
*)
command rbenv "$command" "$@"
;;
esac
}
# 安装插件ruby-build
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
# 安装指定版本的ruby
rbenv install -l # 列出可以安装的版本
rbenv install 2.5.1 # 安装2.5.1
rbenv global 2.5.1
# 安装rails
gem install rails
# 安装yarn
# https://yarnpkg.com/lang/en/docs/install/#debian-stable
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update && sudo apt-get install yarn
网友评论