各种开发语言项目环境国内(**国内加速镜像)配置教程和部分实践经验,包括github.com, nodejs,npm,nvm, yarn, java, maven, gradle, python, mysys2, elasticsearch, php等等,更多正在加入中
本项目地址:https://github.com/mengyou658/awesome-env-config-cn
欢迎大家一起补充
- ruby
- pod
- ...
- 推荐使用阿里云镜像https://developer.aliyun.com/mirror/ 包括了各种镜像
- 推荐使用chrome插件 https://github.com/jadezi/github-accelerator/ 访问github对应的网站自动展示加速连接
- 国内镜像源1,推荐:https://hub.fastgit.xyz
- 国内镜像源1,这个目前不能直接访问,下载之类的不影响 推荐:https://hub.fastgit.org
- 国内镜像源2:https://github.com.cnpmjs.org 这个没有上面的快点
-
nodejs 安装
-
直接下载安装(推荐使用nvm管理nodejs版本自由切换):
- 下载地址: https://npm.taobao.org/mirrors/node 选择对应的版本下载安装即可
-
-
linux或者mac
镜像源:https://hub.fastgit.xyz/nvm-sh/nvm
官方地址:https://github.com/nvm-sh/nvm
- 安装
- linux或者mac安装,镜像:
curl -o- https://raw.fastgit.org/nvm-sh/nvm/master/install.sh | sed -e "s/raw.githubusercontent.com/raw.fastgit.org/g" | sed -e "s/github.com/hub.fastgit.org/g" | bash 或者 wget -qO- https://raw.fastgit.org/nvm-sh/nvm/master/install.sh | sed -e "s/raw.githubusercontent.com/raw.fastgit.org/g" | sed -e "s/github.com/hub.fastgit.org/g" | bash
- linux或者mac安装,官方:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash 或者 wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
- linux或者mac安装,镜像:
- 配置国内源
- 设置环境变量:NVM_NODEJS_ORG_MIRROR,bash编辑~/.bashrc,zsh编辑~/.zshrc
export NVM_NODEJS_ORG_MIRROR=https://npm.taobao.org/mirrors/node
- 安装
-
windows
镜像源:https://hub.fastgit.org/coreybutler/nvm-windows
官方推荐地址:https://github.com/coreybutler/nvm-windows
-
安装
-
配置国内源
- 设置
nvm node_mirror https://npm.taobao.org/mirrors/node nvm npm_mirror https://npm.taobao.org/mirrors/npm/
-
-
yarn 安装
- 需要首先安装nodejs
- 然后使用npm安装yarn或者更新
npm i -g yarn 或者 npm install -g yarn
-
配置国内源
yarn config set registry https://registry.npmmirror.com
- npm 默认安装nodejs后就已经有了,使用以下命令查看
npm -v
- npm更新,一下不适用于nvm安装的node
npm i -g npm
- 配置国内源,最简单的一种方式,自动配置淘宝源中多个配置
npm install -g --registry=https://registry.npmmirror.com mirror-config-china
- java jdk 安装
- 配置现在一般都不需要配置
-
maven安装,apache比较良心,下载相关的基本都自带镜像 http://maven.apache.org/download.cgi
-
配置国内源
<mirror> <id>alimaven</id> <name>aliyun maven</name> <url>https://maven.aliyun.com/repository/public</url> <mirrorOf>central</mirrorOf> </mirror> <mirror> <id>jcenter</id> <name>jcenter</name> <url>https://maven.aliyun.com/repository/central</url> <mirrorOf>central</mirrorOf> </mirror> <mirror> <id>google</id> <name>google</name> <url>https://maven.aliyun.com/repository/google</url> <mirrorOf>central</mirrorOf> </mirror> <mirror> <id>spring</id> <name>aliyun maven spring</name> <url>https://maven.aliyun.com/repository/spring</url> <mirrorOf>central</mirrorOf> </mirror> <mirror> <id>spring-plugin</id> <name>aliyun maven spring-plugin</name> <url>https://maven.aliyun.com/repository/spring-plugin</url> <mirrorOf>central</mirrorOf> </mirror> <mirror> <id>gradle-plugin</id> <name>aliyun maven gradle-plugin</name> <url>https://maven.aliyun.com/repository/gradle-plugin</url> <mirrorOf>central</mirrorOf> </mirror> <mirror> <id>grails-core</id> <name>aliyun maven grails-core</name> <url>https://maven.aliyun.com/repository/grails-core</url> <mirrorOf>central</mirrorOf> </mirror> <mirror> <id>apache snapshots</id> <name>aliyun maven apache snapshots</name> <url>https://maven.aliyun.com/repository/apache-snapshots</url> <mirrorOf>central</mirrorOf> </mirror>
-
gradle 安装
-
gradle 配置
终极配置,在用户目录下~/.gradle/目录下增加init.gradle文件,内容如下
allprojects { buildscript { repositories { mavenLocal() def NEXUS_URL = 'https://maven.aliyun.com/repository/public' def jcenter_URL = 'https://maven.aliyun.com/repository/jcenter' def m2_URL = 'https://maven.aliyun.com/repository/gradle-plugin' def spring_plugin_URL = 'https://maven.aliyun.com/repository/spring-plugin' def spring_URL = 'https://maven.aliyun.com/repository/spring' def GOOGLE_URL = 'https://maven.aliyun.com/repository/google' all { ArtifactRepository repo -> if(repo instanceof MavenArtifactRepository){ def url = repo.url.toString() if (url.startsWith('https://repo1.maven.org/maven2') || url.startsWith('https://jcenter.bintray.com') || url.startsWith('http://mirrors.ibiblio.org')) { project.logger.lifecycle "Repository ${repo.url} replaced by $jcenter_URL." remove repo } else if (url.startsWith('https://plugins.gradle.org/m2/')) { project.logger.lifecycle "Repository ${repo.url} replaced by $m2_URL." remove repo } else if (url.startsWith('http://repo.spring.io/libs-milestone/')) { project.logger.lifecycle "Repository ${repo.url} replaced by $spring_URL." remove repo } else if (url.startsWith('http://repo.spring.io/plugins-release/')) { project.logger.lifecycle "Repository ${repo.url} replaced by $spring_plugin_URL." remove repo // 这里是安卓相关下载的加速,本地没有出现下载慢的情况,所以这个就屏蔽了 //}else if (url.startsWith('https://dl.google.com/dl/android/maven2/')) { // project.logger.lifecycle "Repository ${repo.url} replaced by $GOOGLE_URL." // println("buildscript ${repo.url} replaced by $GOOGLE_URL.") // remove repo } } } maven { url 'https://maven.aliyun.com/repository/public' } maven { url 'https://maven.aliyun.com/repository/spring' } maven { url 'https://maven.aliyun.com/repository/spring-plugin' } maven { url "https://maven.aliyun.com/repository/grails-core" } maven { url "https://maven.aliyun.com/repository/apache-snapshots" } maven { url "https://maven.aliyun.com/repository/gradle-plugin" } maven { url 'https://maven.aliyun.com/repository/google' } jcenter { url jcenter_URL } maven { url NEXUS_URL } } } repositories { mavenLocal() def NEXUS_URL = 'https://maven.aliyun.com/repository/public' def jcenter_URL = 'https://maven.aliyun.com/repository/jcenter' def m2_URL = 'https://maven.aliyun.com/repository/gradle-plugin' def spring_plugin_URL = 'https://maven.aliyun.com/repository/spring-plugin' def spring_URL = 'https://maven.aliyun.com/repository/spring' def GOOGLE_URL = 'https://maven.aliyun.com/repository/google' all { ArtifactRepository repo -> if(repo instanceof MavenArtifactRepository){ def url = repo.url.toString() if (url.startsWith('https://repo1.maven.org/maven2') || url.startsWith('https://jcenter.bintray.com') || url.startsWith('http://mirrors.ibiblio.org')) { project.logger.lifecycle "Repository ${repo.url} replaced by $jcenter_URL." remove repo } else if (url.startsWith('https://plugins.gradle.org/m2/')) { project.logger.lifecycle "Repository ${repo.url} replaced by $m2_URL." remove repo } else if (url.startsWith('http://repo.spring.io/libs-milestone/')) { project.logger.lifecycle "Repository ${repo.url} replaced by $spring_URL." remove repo } else if (url.startsWith('http://repo.spring.io/plugins-release/')) { project.logger.lifecycle "Repository ${repo.url} replaced by $spring_plugin_URL." remove repo // 这里是安卓相关下载的加速,本地没有出现下载慢的情况,所以这个就屏蔽了 //}else if (url.startsWith('https://dl.google.com/dl/android/maven2/')) { // project.logger.lifecycle "Repository ${repo.url} replaced by $GOOGLE_URL." // println("buildscript ${repo.url} replaced by $GOOGLE_URL.") // remove repo } } } maven { url 'https://maven.aliyun.com/repository/public' } maven { url 'https://maven.aliyun.com/repository/spring' } maven { url 'https://maven.aliyun.com/repository/spring-plugin' } maven { url "https://maven.aliyun.com/repository/grails-core" } maven { url "https://maven.aliyun.com/repository/apache-snapshots" } maven { url "https://maven.aliyun.com/repository/gradle-plugin" } maven { url 'https://maven.aliyun.com/repository/google' } jcenter { url jcenter_URL } maven { url NEXUS_URL } } }
- python 安装
- windows 系统安装,直接下载安装包
- linux 系统默认自带python,需要单独安装新版本,linux系统镜像配置请参考linux系统镜像源
- ubuntu
sudo apt-get update sudo apt-cache search python3* sudo apt-get install python3.8 # python3.5 python3.6 python3.7 等,python3.8是当前书写的时候最新稳定版本
- centos
sudo yum install epel-release -y sudo yum -y update sudo yum list python3* # 使用此命令查看当前支持的python3版本 sudo yum install python37 # python35 python36 python37 等,python38是当前书写的时候最新稳定版本
- pip 安装 python 安装成功后,默认自带pip
- 阿里云镜像说明,https://developer.aliyun.com/mirror/pypi
- windows 下配置
mkdir %USERPROFILE%\.pip\ start %USERPROFILE%\.pip\
- 在这个目录下创建pip.conf文件(推荐使用notepad++) 写入内容如下:
[global] index-url = https://mirrors.aliyun.com/pypi/simple/ [install] trusted-host=mirrors.aliyun.com
- linux
写入内容如下:
mkdir -p ~/.pip # ubuntu 桌面下可以使用 gedit ~/.pip/pip.conf # vi 入门可以参考 https://github.com/wsdjeg/vim-galore-zh_cn vi ~/.pip/pip.conf
[global] index-url = https://mirrors.aliyun.com/pypi/simple/ [install] trusted-host=mirrors.aliyun.com
- windows 下配置
- (一般使用miniAnaconda,anaconda占用空间大,土豪可以直接忽略)清华镜像源,这里包括了anaconda的安装配置说明,https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/
- 安装 https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/ 下载对应的文件执行
- windows安装 下载最新的exe文件安装
- linux安装
wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/Miniconda3-py38_4.8.3-Linux-x86_64.sh sh Miniconda3-py38_4.8.3-Linux-x86_64.sh.sh
- 配置镜像
- windows 下配置
conda config --set show_channel_urls yes start %USERPROFILE%\
- 在这个目录下编辑.condarc文件(推荐使用notepad++编辑,如果看不到这个文件,请打开windows系统的隐藏文件选项) 写入内容如下:
channels: - defaults show_channel_urls: true channel_alias: https://mirrors.tuna.tsinghua.edu.cn/anaconda default_channels: - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2 custom_channels: conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
- linux
写入内容如下:
conda config --set show_channel_urls yes # ubuntu 桌面下可以使用 gedit ~/.condarc # vi 入门可以参考 https://github.com/wsdjeg/vim-galore-zh_cn vi ~/.condarc
channels: - defaults show_channel_urls: true channel_alias: https://mirrors.tuna.tsinghua.edu.cn/anaconda default_channels: - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2 custom_channels: conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
- windows 下配置
- elasticsearch 安装
- kibana (elasticsearch管理工具) 安装,需要下载与elasticsearch版本一致
- 安装和配置参考,https://pkg.phpcomposer.com/#how-to-install-composer
- 国内镜像用法参考,https://pkg.phpcomposer.com/#how-to-use-packagist-mirror
- msys2 安装,清华镜像,https://mirror.tuna.tsinghua.edu.cn/help/msys2/
- 配置镜像源
- 修改C:\msys64\etc\pacman.d(默认安装在c盘下面)下面得mirrorlist.*文件,把清华镜像相关得移动到最前面
- 安装
# 更新系统包 pacman -Syu # 基础包 pacman -S --needed base-devel mingw-w64-x86_64-toolchain mingw-w64-x86_64-cmake bash wget p7zip pacman pacman-mirrors msys2-runtime # qt5 pacman -S mingw-w64-x86_64-clang mingw-w64-x86_64-clang-tools-extra mingw-w64-x86_64-clang-analyzer mingw-w64-x86_64-qt5 mingw-w64-x86_64-qt-creator
- goproxy.io七牛镜像
- 环境设置
- windows对应的设置环境变量即可(也可以自己手动设置环境变量,以下需要管理员运行命令行)
setx /m GOPROXY https://goproxy.io,direct setx /m GO111MODULE auto
- linux 环境 编辑~/.bashrc(bash)或者~/.zshrc(zsh)
export GOPROXY=https://goproxy.io,direct export GO111MODULE=auto
- rust 清华镜像 https://mirrors.tuna.tsinghua.edu.cn/rustup/
- windows 下安装
- 下载 https://static.rust-lang.org/rustup/dist/x86_64-pc-windows-msvc/rustup-init.exe
- 设置环境变量(请以管理员运行)
setx /m RUSTUP_DIST_SERVER https://mirrors.tuna.tsinghua.edu.cn/rustup setx /m RUSTUP_UPDATE_ROOT https://mirrors.tuna.tsinghua.edu.cn/rustup/rustup
- 执行rustup-init.exe安装
- linux 下安装
- 设置环境变量 编辑~/.bashrc(bash)或者~/.zshrc(zsh)
export RUSTUP_DIST_SERVER=https://mirrors.tuna.tsinghua.edu.cn/rustup export export RUSTUP_UPDATE_ROOT=https://mirrors.tuna.tsinghua.edu.cn/rustup/rustup
- 安装
curl https://sh.rustup.rs -sSf | sh # 这里也可以下载对应的数据,直接安装 https://mirrors.ustc.edu.cn/rust-static/rustup/dist/ # wget https://mirrors.ustc.edu.cn/rust-static/rustup/dist/x86_64-apple-darwin/rustup-init # ./rustup-init
- 设置环境变量 编辑~/.bashrc(bash)或者~/.zshrc(zsh)
- windows 下安装
- rust 官方下载速度还可以 https://www.rust-lang.org/
- windows 下安装
- linux 下安装
- linux安装
curl https://sh.rustup.rs -sSf | sh
- wsl安装
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
- linux安装
- 环境设置
- windows 到 %USERPROFILE%.cargo 当前用户的.cargo目录下,新建或者修改config,内容如下
[source.crates-io]
registry = "https://github.com/rust-lang/crates.io-index"
# 替换成你偏好的镜像源
replace-with = 'tuna'
# 清华大学
[source.tuna]
registry = "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git"
# **科学技术大学
[source.ustc]
registry = "git://mirrors.ustc.edu.cn/crates.io-index"
# 上海交通大学
[source.sjtu]
registry = "https://mirrors.sjtug.sjtu.edu.cn/git/crates.io-index"
# rustcc社区
[source.rustcc]
registry = "git://crates.rustcc.cn/crates.io-index"
- linux 环境 编辑
vi ~/.cargo/config
[source.crates-io]
registry = "https://github.com/rust-lang/crates.io-index"
# 替换成你偏好的镜像源
replace-with = 'tuna'
# 清华大学
[source.tuna]
registry = "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git"
# **科学技术大学
[source.ustc]
registry = "git://mirrors.ustc.edu.cn/crates.io-index"
# 上海交通大学
[source.sjtu]
registry = "https://mirrors.sjtug.sjtu.edu.cn/git/crates.io-index"
# rustcc社区
[source.rustcc]
registry = "git://crates.rustcc.cn/crates.io-index"
备注:github clone的时候使用git方式下载基本不出问题
- 环境设置
- windows 到 %USERPROFILE%.gitconfig 当前用户的.gitconfig文件,内容如下
[url "[email protected]:"]
insteadOf = https://github.com/