西安 医疗网站制作,php做网站项目的流程,坂田建设网站,红河做网站的公司在 MacOS 操作系统中#xff0c;默认情况下#xff0c;终端命令行不会通过代理进行网络连接。这导致在应用软件研发过程中#xff0c;许多需要通过命令行下载安装的软件或依赖包无法成功安装。经常出现Failed to connect to xxx port 443 after 75329 ms: Couldnt connect t…在 MacOS 操作系统中默认情况下终端命令行不会通过代理进行网络连接。这导致在应用软件研发过程中许多需要通过命令行下载安装的软件或依赖包无法成功安装。经常出现Failed to connect to xxx port 443 after 75329 ms: Couldnt connect to server错误提醒。 如果您需要让 Mac终端命令行走代理可以按照以下步骤进行设置
一、配置bash_profile文件
首先在当前用户根目录找到新建一个文件名为 .bash_profile 的文件然后输入以下代码
function proxy_off(){unset http_proxyunset https_proxyunset ftp_proxyunset rsync_proxyecho -e 已关闭代理
}function proxy_on() {export no_proxylocalhost,127.0.0.1,localaddress,.localdomain.comexport http_proxyhttp://127.0.0.1:7890export https_proxy$http_proxyexport ftp_proxy$http_proxyexport rsync_proxy$http_proxyexport HTTP_PROXY$http_proxyexport HTTPS_PROXY$http_proxyexport FTP_PROXY$http_proxyexport RSYNC_PROXY$http_proxyecho -e 已开启代理
}函数中的 http_proxyhttp://127.0.0.1:7890就是你代理的端口和IP比方说我用的代理默认端口就是7890。
然后 当让终端走代理的时候输入 source ~/.bash_profile proxy_on 当想关闭代理的时候输入source ~/.bash_profile proxy_off
二、实操
首先打开终端输入
source ~/.bash_profile
proxy_on然后测试是否开启成功
curl www.google.com当安装相应软件后关闭代理输入
source ~/.bash_profile
proxy_off #或者直接关闭终端窗口