Linux config

全局

vi /etc/profile
#无用户名密码
export http_proxy=http://proxy_ip:prot
export https_proxy=https://proxy_ip:prot
 
#有用户名密码
export http_proxy=http://username:password@proxy_ip:prot
export https_proxy=https://username:password@proxy_ip:port
export ftp_proxy=http://username:password@proxyserver:port

export http_proxy=http://192.168.64.1:1080
export https_proxy=http://192.168.64.1:1080

# 或者建议这样配置
http_proxy=proxy.abc.com:8080  
https_proxy=$http_proxy  
ftp_proxy=user:password@proxy.abc.com:8080  
no_proxy=*.abc.com,10.*.*.*,192.168.*.*,*.local,localhost,127.0.0.1  
export http_proxy https_proxy ftp_proxy no_proxy  

其中:

  • http_proxy:http协议使用服务器地址;
  • https_proxy:https协议使用安全地址;
  • ftp_proxy:ftp协议使用服务器地址;
  • user:使用的用户名;
  • password:使用用户名的密码;
  • proxy.abc.com:地址,可以是IP,也可以是域名;
  • 8080:使用的端口;
  • no_proxy:不使用主机或IP。

备注:

环境变量描述值示例
http_proxy为http变量设置;默认不填开头以http协议传输10.0.0.51:8080
user:pass@10.0.0.10:8080
socks4://10.0.0.51:1080
socks5://192.168.1.1:1080
https_proxy为https变量设置;同上
ftp_proxy为ftp变量设置;同上
all_proxy全部变量设置,设置了这个时候上面的不用设置同上
no_proxy无需主机或域名;
可以使用通配符;
多个时使用“,”号分隔;
*.aiezu.com,10.*.*.*,
192.168.*.*,*.local,localhost,127.0.0.1
1、在/etc/profile文件
2、在~/.bashrc
3、在~/.zshrc
4、在/etc/profile.d/文件夹下新建一个文件xxx.sh

写入如下配置:

export proxy="http://192.168.5.14:8118"
export http_proxy=$proxy
export https_proxy=$proxy
export ftp_proxy=$proxy
export no_proxy="localhost, 127.0.0.1, ::1"

而对于要取消设置可以使用如下命令,其实也就是取消环境变量的设置:

unset http_proxy
unset https_proxy
unset ftp_proxy
unset no_proxy

生效配置文件

source /etc/profile
. /etc/profile
echo $http_proxy
echo $https_proxy

测试

因为

subversion的服务器配置

要配置subversion的服务器,需要修改$HOME/.subversion/servers文件,在此文件的[global]段加上:

http-proxy-host = 192.168.1.1
http-proxy-port = 8080 
http-proxy-username = easwy
http-proxy-password = 123456 

现在svn就可以使用服务器访问版本库了。

yum的服务器配置

针对yum配置:
经过测试其实只要设置上面的变量之后已经可以,但如果要单独设置,可以设置如下文件的变量:

echo "proxy=http://127.0.0.1:8080/" >> /etc/yum.conf

如果想让CentOS中的yum可以通过服务器更新程序,则需要修改文件/etc/yum.conf,在此文件中加上:

proxy=http://easwy:123456@192.168.1.1:8080
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

骆言

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值