在學習工作中使用vagrant作為開發環境已經有很長一段時間了,使用ubuntu 作為開發系統 在使用中發現,即使修改了apt的source.list源文件,在面對一些開發中需要的軟件工具的時候,不可 避免的還是會遇到卡頓的問題,於是就查了一下資料,修改apt的proxy代理,來加快速度,最后又把git的也修改了
apt git npm composer 等使用遇到的問題
apt git npm composer 由於GFW的存在,對於國內的程序員來說,經常卡住不動,無法使用,即使有鏡像源,但由於存在 同步更新的問題,不能及時解決,所以需要進行proxy設置
設置proxy
1.git
git config --global http.proxy <your proxy ip>:<your proxy port>
git config --global https.proxy <your proxyip>:<your proxy port>
# socks
git config --global http.proxy socks5h://<your proxy ip>:<your proxy port>
git config --global https.proxy socks5h://<your proxy ip>:<your proxy port>
2.apt
sudo echo 'Acquire::http::Proxy "http://<your proxy ip>:<your proxy port>";' >> /etc/apt/apt.conf
sudo apt update
#下面可以體驗飛一 大專欄 ubuntu 代理設置般的感覺了
sudo apt install <some packages>
...
3.npm
npm config set proxy http://<your proxy ip>:<your proxy port>
npm config set proxy-https https://<your proxy ip>:<your proxy port>
4.composer
方法一:
composer config -g repo.packagist composer https://packagist.phpcomposer.com
方法二:
export HTTP_PROXY=http://<your proxy ip>:<your proxy port>
export HTTPS_PROXY=http://<your proxy ip>:<your proxy port>
上面這種方法臨時用一下,每次登錄terminal之后需要重新設置,如果不想每次設置,可以保存在~/.profile
中
echo "# proxy setting" >> ~/.profile
echo "export HTTP_PROXY='http://<your proxy ip>:<your proxy port>'" >> ~/.profile
echo "export HTTPS_PROXY='https://<your proxy ip>:<your proxy port>'" >> ~/.profile
source ~/.profile
實際效果
git npm apt composer 快了不是一點點 :) !