各种开发语言项目环境国内(中国国内加速镜像)配置教程和部分实践经验,包括github.com, nodejs,npm,nvm, yarn, java, maven, gradle, python, m

awesome-env-config-cn

各种开发语言项目环境国内(中国国内加速镜像)配置教程和部分实践经验,包括github.com, nodejs,npm,nvm, yarn, java, maven, gradle, python, mysys2, elasticsearch, php等等,更多正在加入中

源码地址:https://github.com/yunchaoq/awesome-env-config-cn

TODO 待补充的

欢迎大家一起补充

  • ruby
  • pod
  • ...

目录


linux

github

nodejs

nvm

yarn

  • yarn 安装

    官方地址:https://yarnpkg.com/

    • 需要首先安装nodejs
    • 然后使用npm安装yarn或者更新
      npm i -g yarn 
      或者
      npm install -g yarn 
      
  • 配置国内源

    yarn config set registry https://registry.npm.taobao.org
    

npm

  • npm 默认安装nodejs后就已经有了,使用以下命令查看
    npm -v
    
  • npm更新,一下不适用于nvm安装的node
    npm i -g npm 
    
  • 配置国内源,最简单的一种方式,自动配置淘宝源中多个配置
    npm install -g mirror-config-china
    

jdk

maven

gradle

  • 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

  • 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

  • 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
      

miniAnaconda

  • (一般使用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
      

elasticsearch

kibana

php

composer

msys2

msys2-qt5

  • msys2 安装,清华镜像,https://mirror.tuna.tsinghua.edu.cn/help/msys2/
  • 配置镜像源
    1. 修改C:\msys64\etc\pacman.d(默认安装在c盘下面)下面得mirrorlist.*文件,把清华镜像相关得移动到最前面
    2. 安装
    # 更新系统包
    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 
    
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。