windows环境下设置命令行CMD、Git、NPM、Bower和Gem代理设置

在公司的电脑只能通过设置代理访问外网时,需要设置代理

 

命令行CMD代理设置

代理不需要密码时,在命令行界面输入:

set http_proxy=http://proxy_ip_or_fqdn:8080

代理需要用户密码时,在命令行界面输入:

如果代理服务器需要用户名和密码的话,那么需要做如下设置:
   set http_proxy_user=
   set http_proxy_pass=

或者

set http_proxy=http://proxy_user:proxy_password@proxy_ip_or_fqdn:8080

Git代理设置

类似,git设置代理如下:

git config --global http.proxy http://proxy_ip_or_fqdn:8080

git config --global http.proxy http://proxy_user:proxy_password@proxy_ip_or_fqdn:8080

设置完成后,可以通过如下命令来查看设置是否生效:
git config --get --global http.proxy

删除代理设置,使用:
git config --global --unset http.proxy

 

NPM代理设置

npm设置代理方法如下:

npm config set proxy=http://proxy_ip_or_fqdn:8080

npm config set proxy=http://proxy_user:proxy_password@proxy_ip_or_fqdn:8080

 

Bower代理设置

编辑.bowerrc文件

{   "proxy": "http://proxy_ip_or_fqdn:8080",   "https-proxy": "http://proxy_ip_or_fqdn:8080"
}

 

Ruby Gem代理设置&已经变更Gem源

Ruby Gem的代理设置和命令行CMD代理设置的方法一样。

但是,默认的 rubygems.org的源被墙掉了,因此需要变更默认的gem源,此外国内的淘宝镜像"ruby.taobao.org"也停止维护了,现在需要使用ruby-china提供的镜像服务(传送门)。

RubyGems 镜像- Ruby China

更改Gem源方法:

 
查看当前源 
# gem sources -l
*** CURRENT SOURCES ***
https://rubygems.org/
 
移除rubygems的源
# gem sources --remove https://rubygems.org/
 
增加ruby-china源
# gem sources --add https://gems.ruby-china.org/
 
确保只有gems.ruby-china.org源
# gem sources -l
 
更新缓存
# gem sources -u 

 

如果遇到 SSL 证书问题,你又无法解决,请直接用 http://gems.ruby-china.org 替换https://gems.ruby-china.org 避免 SSL 的问题。

转载于:https://my.oschina.net/u/658505/blog/663846

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值