首页 专题 文章 代码 归档

【配置】无道所有常用的环境变量-国内源配置汇总

1. 环境变量配置

1.1. Maven

下载地址:http://maven.apache.org/download.cgi

两个变量:

M2_HOME=F:\Maven3.6.2
MAVEN_HOME=F:\Maven3.6.2

编辑Path,新建:%M2_HOME%\bin


配置

本地仓库地址:

<localRepository>F:\Maven3.6.2\repository</localRepository>

阿里镜像:

<mirror>
    <id>nexus-aliyun</id>
    <mirrorOf>central</mirrorOf>
    <name>Nexus aliyun</name>
    <url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>

1.2. Npm(Node)

配置:

npm config set prefix "F:\nodejs\node_global"
npm config set cache "F:\nodejs\node_cache"

添加环境变量:

NODE_HOME="F:\nodejs"

添加path:

%NODE_HOME%\node_global
%NODE_HOME%\node_cache

设置淘宝镜像:

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

1.3. Yarn(Node)

1、新建两个目录

globalcache

2、设置

修改全局安装目录, 先创建好目录(global)

注意,这目录还需要添加到全局环境变量中

yarn config set global-folder "D:\Env\Yarn\global"

修改全局缓存目录, 先创建好目录(cache)

yarn config set cache-folder "D:\Env\Yarn\cache"

一些其他命令:

查看所有配置

yarn config list

查看当前yarn的bin的位置

yarn global bin

查看当前yarn的全局安装位置

yarn global dir

1.4. Java

jdk11:

https://pan.baidu.com/s/1YhapCffe6MLadASFasZvag

密码:【安装懒盘脚本吧,这里不知道】


jdk8:

https://pan.baidu.com/s/13XpqPa8rn2U5Lr0VXfLChQ

密码:ss5r


jdk11配置简单:

新建环境变量:

JAVA_HOME=D:\Env\Java\java11

然后把bin目录添加到path即可:D:\Env\Java\java11\bin

jdk8的话,还要配置其他东西【当然,也许jdk11也需要配置,但是如果仅仅是用IDEA的话,这两样已经足够了】

2. 国内源

2.1. Composer

阿里终于提供了php的composer源了,毕竟大厂,值得信赖:

配置

composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/

取消配置

composer config -g --unset repos.packagist

2.2. Docker

用法:

vi /etc/docker/daemon.json # 编辑配置文件

添加下面内容:

{
    "registry-mirrors": ["http://hub-mirror.c.163.com"]
}

重启:

systemctl restart docker.service # 你也可以用service命令,必要的话

其中,http://hub-mirror.c.163.com可换成

1、Docker中国区官方镜像:https://registry.docker-cn.com

2、网易:http://hub-mirror.c.163.com

3、USTC:https://docker.mirrors.ustc.edu.cn

4、中国科技大学:https://docker.mirrors.ustc.edu.cn

5、阿里云容器 服务:https://cr.console.aliyun.com/ 首页点击“创建我的容器镜像” 得到一个专属的镜像加速地址,类似于“https://1234abcd.mirror.aliyuncs.com

2.3. Pip(Python)

如下内容:

Linux:

vim ~/.pip/pip.conf

添加如下内容:

[global]
timeout = 6000
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host = https://pypi.tuna.tsinghua.edu.cn

windows:

在用户(看自己windows登录的用户名)目录中创建一个pip目录,如:C:\Users\xxx\pip,然后新建文件pip.ini,即 %HOMEPATH%\pip\pip.ini

同样保存上面的内容

2.4. Centos

先备份:

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

下面是Centos7:

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
\# 或者
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

然后生成缓存:yum makecache

2.5. Go

go proxy:

https://goproxy.io/zh/

go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.io,direct
# 启用 Go Modules 功能
$env:GO111MODULE="on"
# 配置 GOPROXY 环境变量
$env:GOPROXY="https://goproxy.io"

3. 其他配置

3.1. git用户名

git config --global user.name "username"

git config --global user.email "email"

4. 配置网络

4.1. Centos7

vim /etc/sysconfig/network-scripts/ifcgxxx

BOOTPROTO=static
ONBOOT=yes

IPADDR=192.168.184.10
NETMASK=255.255.255.0
GATEWAY=192.168.184.2
DNS1=114.114.114.114

有几个关键地方:

1、BOOTPROTO设置为静态(static)

2、ONBOOT设置为yes

3、其外就是IPADDR、NETMASK、GATEWAY、DNS1要设置好,就行了。

修改此文件,可以使用命令:service network restart来重启,而不用关机而使其生效!


要配置局域网内电脑都可以访问,就需要设置网络为桥接模式,然后另一个主机找到默认网关和ip

4.2. Ubuntu 20.04

1、先更换阿里云源:

sudo cp /etc/apt/source.list /etc/apt/source.list.backup #备份
sudo vim /etc/apt/sources.list

添加如下内容:

# deb cdrom:[Ubuntu 20.04 LTS _Focal Fossa_ - Release amd64 (20200423)]/ focal main restricted

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted
# deb-src http://us.archive.ubuntu.com/ubuntu/ focal main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted
# deb-src http://us.archive.ubuntu.com/ubuntu/ focal-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://mirrors.aliyun.com/ubuntu/ focal universe
# deb-src http://us.archive.ubuntu.com/ubuntu/ focal universe
deb http://mirrors.aliyun.com/ubuntu/ focal-updates universe
# deb-src http://us.archive.ubuntu.com/ubuntu/ focal-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu 
## team, and may not be under a free licence. Please satisfy yourself as to 
## your rights to use the software. Also, please note that software in 
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://mirrors.aliyun.com/ubuntu/ focal multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ focal multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ focal-updates multiverse

## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse

## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu focal partner
# deb-src http://archive.canonical.com/ubuntu focal partner

deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted
# deb-src http://security.ubuntu.com/ubuntu focal-security main restricted
deb http://mirrors.aliyun.com/ubuntu/ focal-security universe
# deb-src http://security.ubuntu.com/ubuntu focal-security universe
deb http://mirrors.aliyun.com/ubuntu/ focal-security multiverse
# deb-src http://security.ubuntu.com/ubuntu focal-security multiverse

# This system was installed using small removable media
# (e.g. netinst, live or single CD). The matching "deb cdrom"
# entries were disabled at the end of the installation process.
# For information about how to configure apt package sources,
# see the sources.list(5) manual.

更新:

sudo apt-get update
sudo apt-get upgrade

2、重新安装ssh服务(这里时想ssh连接wsl)

#先删掉原有的ssh
$ sudo apt-get remove --purge openssh-server

#重新安装ssh服务
$ sudo apt-get install openssh-server ssh  

#编辑sshd_config文件,修改几处配置才能正常使用用户名/密码的方式连接
$ sudo vi /etc/ssh/sshd_config

#需要找到并修改以下几项(其他博客有修改其他项成功的,但是我只改了这两项就OK了)
Port 223  #默认的是22,Windows自己的SSH服务也是的22端口,所以我改成了223
PermitRootLogin yes #默认是PermitRootLogin prohibit-password

#启动ssh服务
sudo service ssh --full-restart
此文阅读完毕,您可以:分享
二维码图片 扫描关注我们哟