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

在公司的電腦只能經過設置代理訪問外網時,須要設置代理git

 

命令行CMD代理設置

代理不須要密碼時,在命令行界面輸入:npm

set http_proxy=http://proxy_ip_or_fqdn:8080

代理須要用戶密碼時,在命令行界面輸入:緩存

若是代理服務器須要用戶名和密碼的話,那麼須要作以下設置:
   set http_proxy_user=
   set http_proxy_pass=

或者ruby

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:8080spa

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.proxycode

 

NPM代理設置

npm設置代理方法以下:ip

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 的問題。

相關文章
相關標籤/搜索