【MAC】brew privoxy安装和配置

一、privoxy安装

brew install privoxy

问题:

1、brew install privoxy报错

2、brew update 报错

报错信息:

curl: (22) The requested URL returned error: 502 Bad Gateway

curl: (7) Failed to connect to raw.githubusercontent.com port 443: Operation timed out

解决:

0、vi /etc/hosts

把原来的IP改成这4个

查询地址:https://ipaddress.com/

【MAC】brew privoxy安装和配置_第1张图片

#199.232.28.133 raw.githubusercontent.com
185.199.108.133 githubusercontent.com
185.199.109.133 githubusercontent.com
185.199.110.133 githubusercontent.com
185.199.111.133 githubusercontent.com

1、执行下面这句命令,更换为中科院的镜像:

git clone git://mirrors.ustc.edu.cn/homebrew-core.git/ /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core --depth=1

2、把homebrew-core的镜像地址也设为中科院的国内镜像

cd "$(brew --repo)" 

git remote set-url origin https://mirrors.ustc.edu.cn/brew.git

cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"

git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git

3、brew update,更新brew

zhengxiaofang@localhost homebrew-core % brew update

^Cerror: https://mirrors.ustc.edu.cn/homebrew-core.git did not send all necessary objects

/usr/local/Homebrew/Library/Homebrew/cmd/update.sh: line 301: 61268 Terminated: 15          ( UPSTREAM_REPOSITORY_URL="$(git config remote.origin.url)"; if [[ "$UPSTREAM_REPOSITORY_URL" = "https://github.com/"* ]]; then
    UPSTREAM_REPOSITORY="${UPSTREAM_REPOSITORY_URL#https://github.com/}"; UPSTREAM_REPOSITORY="${UPSTREAM_REPOSITORY%.git}"; if [[ "$DIR" = "$HOMEBREW_REPOSITORY" && -n "$HOMEBREW_UPDATE_TO_TAG" ]]; then
        GITHUB_API_ETAG="$(sed -n 's/^ETag: "\([a-f0-9]\{32\}\)".*/\1/p' ".git/GITHUB_HEADERS" 2>/dev/null)"; GITHUB_API_ACCEPT="application/vnd.github.v3+json"; GITHUB_API_ENDPOINT="tags";
    else
        GITHUB_API_ETAG="$(git rev-parse "refs/remotes/origin/$UPSTREAM_BRANCH_DIR")"; GITHUB_API_ACCEPT="application/vnd.github.v3.sha"; GITHUB_API_ENDPOINT="commits/$UPSTREAM_BRANCH_DIR";
    fi; UPSTREAM_SHA_HTTP_CODE="$("$HOMEBREW_CURL"            "${CURL_DISABLE_CURLRC_ARGS[@]}"            --silent --max-time 3            --location --output /dev/null --write-out "%{http_code}"            --dump-header "$DIR/.git/GITHUB_HEADERS"            --user-agent "$HOMEBREW_USER_AGENT_CURL"            --header "Accept: $GITHUB_API_ACCEPT"            --header "If-None-Match: \"$GITHUB_API_ETAG\""            "https://api.github.com/repos/$UPSTREAM_REPOSITORY/$GITHUB_API_ENDPOINT")"; [[ -f "$DIR/.git/FETCH_HEAD" ]] && touch "$DIR/.git/FETCH_HEAD"; [[ -z "$HOMEBREW_UPDATE_FORCE" ]] && [[ "$UPSTREAM_SHA_HTTP_CODE" = "304" ]] && exit;
else
    if [[ -n "$HOMEBREW_UPDATE_PREINSTALL" ]]; then
        FORCE_AUTO_UPDATE="$(git config homebrew.forceautoupdate 2>/dev/null || echo "false")"; if [[ "$FORCE_AUTO_UPDATE" != "true" ]]; then
            exit;
        fi;
    fi;
fi; if [[ -n "$HOMEBREW_VERBOSE" ]]; then
    echo "Fetching $DIR...";
fi; if [[ -n "$HOMEBREW_UPDATE_PREINSTALL" ]]; then
    git fetch --tags --force "${QUIET_ARGS[@]}" origin "refs/heads/$UPSTREAM_BRANCH_DIR:refs/remotes/origin/$UPSTREAM_BRANCH_DIR" 2> /dev/null;
else
    if ! git fetch --tags --force "${QUIET_ARGS[@]}" origin "refs/heads/$UPSTREAM_BRANCH_DIR:refs/remotes/origin/$UPSTREAM_BRANCH_DIR"; then
        if [[ "$UPSTREAM_SHA_HTTP_CODE" = "404" ]]; then
            TAP="${DIR#$HOMEBREW_LIBRARY/Taps/}"; echo "$TAP does not exist! Run \`brew untap $TAP\` to remove it." >> "$update_failed_file";
        else
            echo "Fetching $DIR failed!" >> "$update_failed_file";
        fi;
    fi;
fi )  (wd: /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core)
zhengxiaofang@localhost homebrew-core % brew update
==> Downloading https://ghcr.io/v2/homebrew/portable-ruby/portable-ruby/blobs/sha256:1f50bf80583bd436c9542d4fa5ad47df0ef0f0bea22ae710c4f04c42d7560bca
#=#=-  #       #                                                                                                                                                                                                                                               #=O=#     #        #                                                                                                                                                                                                                                           -#O=- #      #          #                                                                                                                                                                                                                                      -=O#-   #        #           #                                                                                                                                                                                                                                 -=O=-#      #         #           #                                                                                                                                                                                                                            -=O=-  #       #          #             #                                                                                                                                                                                                                      -=O=-     #        #            #             #                                                       ######################################################################################################################################################################################################################################################### 100.0%
==> Pouring portable-ruby-2.6.8_1.el_capitan.bottle.tar.gz
Updated 2 taps (homebrew/core and homebrew/services).
==> Outdated Formulae
coreutils       jpeg            krb5            leptonica       libidn2         libtiff         libunistring    little-cms2     mysql           nettle          openjpeg        [email protected]     protobuf        telnet          tesseract       webp            wget

You have 17 outdated formulae installed.
You can upgrade them with brew upgrade
or list them with brew outdated.
zhengxiaofang@localhost homebrew-core % brew list
==> Formulae
coreutils	giflib		krb5		libidn2		libtiff		little-cms2	mysql		openjpeg	protobuf	tesseract	wget
gettext		jpeg		leptonica	libpng		libunistring	lrzsz		nettle		[email protected]	telnet		webp
zhengxiaofang@localhost homebrew-core % brew -v
Homebrew 3.5.1
Homebrew/homebrew-core (git revision f32c115b61; last commit 2022-06-13)
zhengxiaofang@localhost homebrew-core %

4、再次尝试安装代理工具,成功

zhengxiaofang@localhost homebrew-core % brew install privoxy
==> Downloading https://ghcr.io/v2/homebrew/core/pcre/manifests/8.45
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/pcre/blobs/sha256:180d88dc2230e98162685b86d00436903db4349aac701f9769997d61adb78418
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:180d88dc2230e98162685b86d00436903db4349aac701f9769997d61adb78418?se=2022-06-13T09%3A25%3A00Z&sig=qusOJTO88nyx8XTFlkMhd6gKJs%2BI%2FcKRuzI%2BoAmJFWU%3D&sp=r&spr=https&sr=b&sv=2019-12-12
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/privoxy/manifests/3.0.33
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/privoxy/blobs/sha256:b19e5234b39ad38c70ab95f9763da0ee02e5b7978067f9662d2d15f3341a1e53
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:b19e5234b39ad38c70ab95f9763da0ee02e5b7978067f9662d2d15f3341a1e53?se=2022-06-13T09%3A25%3A00Z&sig=Z18drVBMDujP1zxmXK6Ycse%2BRORueAF6t3DhLoImzkQ%3D&sp=r&spr=https&sr=b&sv=2019-12-12
######################################################################## 100.0%
==> Installing dependencies for privoxy: pcre
==> Installing privoxy dependency: pcre
==> Pouring pcre--8.45.catalina.bottle.tar.gz
  /usr/local/Cellar/pcre/8.45: 204 files, 5.8MB
==> Installing privoxy
==> Pouring privoxy--3.0.33.catalina.bottle.tar.gz
==> Caveats
To restart privoxy after an upgrade:
  brew services restart privoxy
Or, if you don't want/need a background service you can just run:
  /usr/local/opt/privoxy/sbin/privoxy --no-daemon /usr/local/etc/privoxy/config
==> Summary
  /usr/local/Cellar/privoxy/3.0.33: 103 files, 2.4MB
==> Running `brew cleanup privoxy`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
==> Caveats
==> privoxy
To restart privoxy after an upgrade:
  brew services restart privoxy
Or, if you don't want/need a background service you can just run:
  /usr/local/opt/privoxy/sbin/privoxy --no-daemon /usr/local/etc/privoxy/config

另:安装中文版Homebrew,直接执行,按中文提示操作

/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
zhengxiaofang@localhost ~ % /bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"

               开始执行Brew自动安装程序
              [[email protected]]
           ['2022-06-13 16:48:30']['10.15']
        https://zhuanlan.zhihu.com/p/111014448


请选择一个下载brew本体的序号,例如中科大,输入1回车。
源有时候不稳定,如果git克隆报错重新运行脚本选择源。
1、中科大下载源
2、清华大学下载源
3、北京外国语大学下载源
4、腾讯下载源
5、阿里巴巴下载源
请输入序号: 1


  你选择了中国科学技术大学brew本体下载源

!!!此脚本将要删除之前的brew(包括它下载的软件),请自行备份。
->是否现在开始执行脚本(N/Y) Y

--> 脚本开始执行
 Mac os设置开机密码方法:
  (设置开机密码:在左上角苹果图标->系统偏好设置->用户与群组->更改密码)
  (如果提示This incident will be reported. 在用户与群组中查看是否管理员)
==> 通过命令删除之前的brew、创建一个新的Homebrew文件夹
请输入开机密码,输入过程不显示,输入完后回车
Password:

 二、privoxy配置

vi /usr/local/etc/privoxy/config

# 在文件末尾添加以下代码

listen-address 0.0.0.0:8118

forward-socks5 / localhost:1080 .

 三、手动启动privoxy

​​​​​​​sudo /usr/local/sbin/privoxy /usr/local/etc/privoxy/config

# 查看端口是否被监听

netstat -na | grep 8118

【MAC】brew privoxy安装和配置_第2张图片

 四、配置环境变量

vi ~/.zshrc

# 添加以下内容

# 端口信息需查询

export http_proxy='http://ip:port'

export https_proxy=$http_proxy

# 重载配置文件

source ~/.zshrc

你可能感兴趣的:(Mac常用软件的使用方法,git,github,privoxy,ios)