初始化 Ubuntu 开发环境

@eyasliu 2017-03-31 01:32:49发表于 eyasliu/blog

启动一台新的虚拟机时,需要做一些配置

安装必须软件

基础包

sudo apt install -yq wget curl zsh git git-gui make gcc g++

Oh My Zsh

sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

nvm and node

执行前先设置下方的环境变量

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.1/install.sh | zsh
nvm i 7
nvm alias default 7

sublime text

pkg=sublime.deb && wget -O $pkg https://download.sublimetext.com/sublime-text_build-3126_amd64.deb && sudo dpkg -i $pkg && rm -f $pkg

docker

curl -sSL http://acs-public-mirror.oss-cn-hangzhou.aliyuncs.com/docker-engine/internet | sh -
# docker 源换成aliyun, xxxxxxx 请换成自己的加速器
sudo echo "{\"registry-mirrors\": [\"https://xxxxxxxx.mirror.aliyuncs.com\"]" | sudo tee -a /etc/default/docker && sudo service docker restart

一些CDN

设置源

npm and yarn

npm config set registry "https://registry.npm.taobao.org" # 给npm设置淘宝源
yarn config set registry "https://registry.npm.taobao.org" # 给 yarn 设置淘宝源

ubuntu, 其实 cn.archive.ubuntu.com 也是 阿里云的镜像,所以如果本身就是 cn 源就不需要修改

  deb http://mirrors.aliyun.com/ubuntu/ natty main restricted universe multiverse
  deb http://mirrors.aliyun.com/ubuntu/ natty-security main restricted universe multiverse
  deb http://mirrors.aliyun.com/ubuntu/ natty-updates main restricted universe multiverse
  deb http://mirrors.aliyun.com/ubuntu/ natty-proposed main restricted universe multiverse
  deb http://mirrors.aliyun.com/ubuntu/ natty-backports main restricted universe multiverse
  deb-src http://mirrors.aliyun.com/ubuntu/ natty main restricted universe multiverse
  deb-src http://mirrors.aliyun.com/ubuntu/ natty-security main restricted universe multiverse
  deb-src http://mirrors.aliyun.com/ubuntu/ natty-updates main restricted universe multiverse
  deb-src http://mirrors.aliyun.com/ubuntu/ natty-proposed main restricted universe multiverse
  deb-src http://mirrors.aliyun.com/ubuntu/ natty-backports main restricted universe multiverse

环境变量

# nvm
export NVM_NODEJS_ORG_MIRROR=http://npm.taobao.org/mirrors/node
export NVM_IOJS_ORG_MIRROR=http://npm.taobao.org/mirrors/iojs

#phantomjs
export PHANTOMJS_CDNURL=https://npm.taobao.org/dist/phantomjs

# electron
export ELECTRON_MIRROR=http://npm.taobao.org/mirrors/electron/

# node-sass
export SASS_BINARY_SITE=http://npm.taobao.org/mirrors/node-sass

# sqlite3
export SQLITE3_BINARY_SITE=http://npm.taobao.org/mirrors/sqlite3

# python
export PYTHON_MIRROR=http://npm.taobao.org/mirrors/python