Linux 环境基础搭建记录

安装brew

安装命令

第一步

$ export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/brew.git"

第一步

$ export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.ustc.edu.cn/homebrew-core.git/"

第三步 开始安装

$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

安装后配置 环境变量

第一步

$ (echo; echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"') >> /home/User/.bashrc 

第二步

$ eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"

第三步

$ echo '# Set PATH, MANPATH, etc., for Homebrew.' >> /home/Helix/.bashrc

第四步

$ echo '# Set PATH, MANPATH, etc., for Homebrew.' >> /home/Helix/.bashrc

第五步

$ echo 'export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/brew.git"' >> /home/Helix/.bashrc 
$ echo 'export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.ustc.edu.cn/homebrew-core.git/"' >> /home/Helix/.bashrc 
$ export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/brew.git"
$ export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.ustc.edu.cn/homebrew-core.git/"

$ brew 
// 如果命令成功出来 那么就安装成功

$ brew update

第六步 设置镜像地址

阿里云镜像

$ cd "$(brew --repo)"
$ git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git

中科大镜像

$ echo 'export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles"' >> ~/.bashrc 
$ echo 'export HOMEBREW_API_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles/api"' >> ~/.bashrc 

source ~/.bashrc

brew update

到这里我们的brew已经安装好了

安装 docker

安装命令

// 先查询一下 docker 
$ apt search docker-ce

// 执行 安装命令
$ sudo apt-get install docker-ce

设置用户权限

$ sudo groupadd docker
$ sudo gpasswd -a ${user} docker
$ sudo service docker restart
$ sudo chmod a+rw /var/run/docker.sock

安装 docker-compose

$ apt search docker-compose
$ sudo apt-get install docker-compose

安装PHP

安装命令

brew search php
brew install php@8.1

安装后执行命令

$ echo 'export PATH="/home/linuxbrew/.linuxbrew/opt/php@8.1/bin:$PATH"' >> /home/Helix/.bashrc
$ echo 'export PATH="/home/linuxbrew/.linuxbrew/opt/php@8.1/sbin:$PATH"' >> /home/Helix/.bashrc
$ export LDFLAGS="-L/home/linuxbrew/.linuxbrew/opt/php@8.1/lib"
$ export CPPFLAGS="-I/home/linuxbrew/.linuxbrew/opt/php@8.1/include"
$ source ~/.bashrc

在使用 docker 的情况下最好 composer 是在 docker 容器里面来执行,而不是在宿主机执行,宿主机安装 php 是用于编辑器 质检工具

安装 composer

$ brew search composer
$ brew install composer

安装 node

brew install node

shell 链接工具

termius 支持全平台哦

本作品采用《CC 协议》,转载必须注明作者和本文链接
自由与温暖是遥不可及的梦想
讨论数量: 1
自由与温暖是遥不可及的梦想

20230413 安装错误记录

// 重点看这句  这个是你要删除的文件 绝对路径
Already downloaded: /home/User/.cache/Homebrew/portable-ruby-2.6.10_1.x86_64_linux.bottle.tar.gz

Error: Checksum mismatch.
Expected: 68923daf3e139482b977c3deba63a3b54ea37bb5f716482948878819ef911bad
  Actual: 7fbec6fbfbb1723c60211bd0a2abfbec60b8cde1982734fd477c8be35ace44c3
 Archive: /home/User/.cache/Homebrew/portable-ruby-2.6.10_1.x86_64_linux.bottle.tar.gz
To retry an incomplete download, remove the file above.
Error: Failed to install Homebrew Portable Ruby and cannot find another Ruby 2.6.10!
If there's no Homebrew Portable Ruby available for your processor:
- install Ruby 2.6.10 with your system package manager (or rbenv/ruby-build)
- make it first in your PATH
- try again

解决方案

$ cd ~/.cache/Homebrew 
$ ll # 查看 是否存在这个文件 `portable-ruby-2.6.10_1.x86_64_linux.bottle.tar.gz`
// 果存在 
$ rm -rf portable-ruby-2.6.10_1.x86_64_linux.bottle.tar.gz
1年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!