Mac安装aws-cli全过程,通过命令行上传文件到aws s3协议服务器

第一次使用aws,首先查询了各种资料,我第一步需要做的是安装aws-cli,而安装aws-cli之前需要安装python3,当然你安装python3之前你还需要安装homebrew,当然我正在安装的过程中还遇到了其他的问题,接下来用一个个步骤来描述安装过程

  一、安装homebrew

 镜像更换为国内的,这样安装应该是顺畅的

1、将brew的install文件下载本地
      终端输入 curl -fsSL [https://raw.githubusercontent.com/Homebrew/install/master/install](https://raw.githubusercontent.com/Homebrew/install/master/install) >> brew_install 2、修改install文件的镜像源 终端输入 vim brew_install 将下面两行进行修改 #BREW_REPO = "[https://github.com/Homebrew/brew”.freeze](https://github.com/Homebrew/brew%E2%80%9D.freeze) #CORE_TAP_REPO = “[https://github.com/Homebrew/homebrew-core](https://github.com/Homebrew/homebrew-core)”.freeze 替换成下面两句 BREW_REPO = “[https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git](https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git)”.freeze CORE_TAP_REPO = "[https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git”.freeze](https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git%E2%80%9D.freeze) #就是“BREW_REPO”和“CORE_TAP_REPO”这两项,将其修改为清华的镜像 3、安装 ruby ~/brew_install
  二、安装Python3

brew install python3

假如网络没问题的话,应该能够安装成功,但是在我们执行python3 --version的时候却会报错,提示你使用brew link python,当然你就算执行也会继续报权限错误

假如出现以上出错的可以执行以下指令:

sudo mkdir /usr/local/Frameworks

sudo chown $(whoami):admin /usr/local/Frameworks

brew link python3 

接下来可以查看python的版本信息,以确认安装成功

python --version

python3 --version

  三、安装Aws-cli
curl -O https://bootstrap.pypa.io/get-pip.py
python3 get-pip.py --user
安装成功之后可以验证下pip3 --version,假如报错找不到指令的话,那么手动链接指令 

  cd /

   ln -s /Users/guxuelong/Library/Python/3.7/bin/pip3 /usr/local/bin/pip3

pip3 install awscli --upgrade --user
安装成功之后可以验证下pip3 --version,假如报错找不到指令的话,那么手动链接指令 
 cd /
 ln -s /Users/guxuelong/Library/Python/3.7/bin/aws /usr/local/bin/aws
验证aws --version
 
  四、上传文件

 第一步修改默认配置:aws configure 依次设置access key、secret key、后面两个可以不用设置

$ aws configure
AWS Access Key ID [None]: AKIAIOSFODNN7EXAMPLE
AWS Secret Access Key [None]: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY Default region name [None]: us-east-2 Default output format [None]: json

第二步上传查看,注意设置endpoint-ur
  • 列出存储桶
    $ aws s3 ls --endpoint-url=https://xxx.com

  • 列出某个存储桶中的内容
    $ aws s3 ls s3://my-bucket --endpoint-url=https://xxx.com

  • 上传文件到s3存储桶
    $ aws s3 cp my-file s3://my-bucket/my-folder --endpoint-url=https://xxx.com

猜你喜欢

转载自www.cnblogs.com/guxuelong/p/12787623.html