只记录软件安装与简单配置
linux
安装 ubuntu server
https://iso.mirrors.ustc.edu.cn/ubuntu-releases/22.04.2/ubuntu-22.04.2-live-server-amd64.iso
http://ftp.sjtu.edu.cn/ubuntu-cd/22.04.2/ubuntu-22.04.2-live-server-amd64.iso
如果用 Virtual Box 安装完后, 克隆出一个测试机器 (假设叫 ubuntu-test)
sudo hostnamectl set-hostname ubuntu-test
sudo rm -f /etc/machine-id
sudo dbus-uuidgen --ensure=/etc/machine-id
reboot
安装 linux mint
TODO
解决 windows / linux 双系统时间不同问题
linux 下执行:
timedatectl set-local-rtc 1 --adjust-system-clock
参考这篇
linux mint 常用快捷键
ctrl + shift + w关闭窗口shitf + win + [<- / ->]将某个窗口移动到另一个显示屏 (monitor)ctrl + alt + [<- / ->]切换工作空间 (workspace)
apt
删除无用软件
sudo apt-get remove --purge ‘libreoffice*’
sudo apt-get clean
sudo apt-get autoremove
# zsh
sudo apt-get remove --purge libreoffice\*
参考: https://askubuntu.com/questions/180403/how-to-uninstall-libreoffice
获得版本信息 && 安装特定版本软件
apt-cache policy mysql-server # 版本信息
apt install mysql-server=5.7x # 安装 5.7 版本
修改 ubuntu 镜像源
备份
sudo cp /etc/apt/sources.list /etc/apt/sources.list.back
打开 /etc/apt/sources.list
SJTUG 镜像源
deb https://mirror.sjtu.edu.cn/ubuntu/ jammy main restricted universe multiverse
# deb-src https://mirror.sjtu.edu.cn/ubuntu/ jammy main restricted universe multiverse
deb https://mirror.sjtu.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
# deb-src https://mirror.sjtu.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
deb https://mirror.sjtu.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
# deb-src https://mirror.sjtu.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
deb https://mirror.sjtu.edu.cn/ubuntu/ jammy-security main restricted universe multiverse
# deb-src https://mirror.sjtu.edu.cn/ubuntu/ jammy-security main restricted universe multiverse
# deb https://mirror.sjtu.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse
# deb-src https://mirror.sjtu.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse
修改 linux mint 镜像源
TODO
输入法
TODO
命令行工具
sudo apt install -y build-essential vim htop git neofetch zsh tree openssh-server wget
oh-my-zsh
下载 install.sh
bash install.sh
或者
sh -c "$(wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"
禁止更新
vim ~/.zshrc
DISABLE_AUTO_UPDATE="true"
插件配置
-
zsh-autosuggestions
git clone https://gitee.com/pyq19/zsh-autosuggestions.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions -
zsh-syntax-highlighting
git clone https://gitee.com/pyq19/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
vim ~/.zshrc
plugins=(
git
zsh-autosuggestions
zsh-syntax-highlighting
)
go (golang)
下载地址: https://go.dev/dl/
go1.20.6.linux-amd64.tar.gz
安装: https://go.dev/doc/install
解压缩到 /usr/local/lib/go 目录下
sudo rm -rf /usr/local/lib/go && sudo tar -C /usr/local/lib -xzf ~/Downloads/go1.20.6.linux-amd64.tar.gz
环境变量
# vim ~/.zshrc
export GO=/usr/local/lib/go/bin
# export GOPROXY=https://mirrors.aliyun.com/goproxy/
export GOPROXY=https://goproxy.io,direct
export PATH=$GO:$PATH
python pip (PyPI)
apt install -y python3-pip
修改 ~/.zshrc 添加 bin 路径
export LOCAL_BIN=~/.local/bin
export PATH=$LOCAL_BIN:$PATH
阿里源: https://mirrors.aliyun.com/pypi/
新建 ~/.pip/pip.conf
mkdir ~/.pip
touch ~/.pip/pip.conf
内容
[global]
index-url = https://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com
python3 使用 venv 创建虚拟环境 (python2 使用 virtualenv)
# python3 -V
# 输出: Python 3.10.12
apt install python3.10-venv
使用 venv 在当前文件夹新建 env 环境
python3 -m venv env
激活虚拟环境
source env/bin/activate
vscode
https://code.visualstudio.com/
多光标: 选中一个单词, ctrl + d 会多选重复的单词
vim 插件
"vim.handleKeys": {
"<C-d>": false,
"<C-s>": false,
"<C-z>": false,
"<C-w>": false
}
go 插件
vscode-icon 图标
File -> Preferences -> Settings
在 User 标签页的 Extensions - vscode-icons configurations 找到
Folders All Default Icon 选项, 打勾, 使用默认图标
运行测试用例时, 显示 t.Log() 日志
在 .vscode/settings.json 中增加
{
"go.testFlags": ["-v"]
}
mariaDB
Server version: 10.6.12-MariaDB-0ubuntu0.22.04.1 Ubuntu 22.04
参考:
- How To Install MariaDB on Ubuntu 20.04
- How To Install MariaDB 10.6 on Ubuntu 20.04|18.04
- ERROR 1372 (HY000): Password hash should be a 41-digit hexadecimal number
安装
sudo apt update
sudo apt install mariadb-server -y
sudo systemctl status mariadb.service # 确保服务运行
设置
sudo mysql_secure_installation
# 注意是大写的 Y
# Enter current password for root (enter for none): 直接回车
# Switch to unix_socket authentication [Y/n] Y
# Change the root password? [Y/n] Y 然后输入 root 密码
# Remove anonymous users? [Y/n] Y
# Disallow root login remotely? [Y/n] n 允许远程访问
# Remove test database and access to it? [Y/n] Y
# Reload privilege tables now? [Y/n] Y
远程 root 登录
sudo vim /etc/mysql/mariadb.conf.d/50-server.cnf
# 将 bind-address = 127.0.0.1
# 改为 bind-address = 0.0.0.0
systemctl restart mariadb # 重启
连接
mysql -uroot -p'密码'
本地机器 (192.168.31.192):
MariaDB [(none)]> select password('asd');
# 生成密码
# +-------------------------------------------+
# | password('asd') |
# +-------------------------------------------+
# | *F6DD0C0AC75395CB5BFC12C46B8880CD156B4799 |
# +-------------------------------------------+
MariaDB [(none)]> grant all privileges on *.* to 'root'@'%' identified by password '*F6DD0C0AC75395CB5BFC12C46B8880CD156B4799' with grant option;
MariaDB [(none)]> flush privileges;
远程机器 (192.168.31.224) 连接:
mysql -uroot -h192.168.31.192 -p'asd'
备份数据库
从 mysql#1 导出
mysqldump 数据库名 -u'用户名' -p'密码' -h'地址' > 数据库名.sql
在 mysql#2 新建同名数据库
CREATE DATABASE 数据库名 CHARACTER SET utf8 COLLATE utf8_general_ci;
数据库文件往 mysql#2 中导入
mysql 数据库名 -u'用户名' -p'密码' < 数据库名.sql
参考:
- https://stackoverflow.com/questions/5551301/clone-mysql-database
- https://dba.stackexchange.com/questions/174/how-can-i-move-a-database-from-one-server-to-another
code-server
-
release 页面:
https://github.com/coder/code-server/releases/ -
上传到远程服务器
~目录:scp ~/Downloads/code-server-4.16.1-linux-amd64.tar.gz root@<远程主机IP>:~/ -
(远程服务器) 解压缩
mkdir /opt/code-server tar -C /opt/code-server/ -xvzf code-server-4.16.1-linux-amd64.tar.gz -
新建 code-server 配置文件
touch ~/.config/code-server/config.yamlbind-addr: 127.0.0.1:5001 auth: password password: <密码> cert: false -
supervisor
touch /etc/supervisor/conf.d/code-server.conf[program:code-server] directory=/opt/code-server command=/opt/code-server/code-server-4.16.1-linux-amd64/bin/code-server stdout_logfile=/var/log/supervisor/code-server-stdout.log stderr_logfile=/var/log/supervisor/code-server-stderr.log启动
supervisorctl reread supervisorctl update -
nginx
/etc/nginx/conf.d/code-server.conf:server { listen 80; charset utf-8; server_name code-server.impyq.com; location / { proxy_pass http://127.0.0.1:5001; proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header X-Real-Ip $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } }nginx -s reload
supervisor
在 /etc/supervisor/conf.d 目录下新建配置文件 appname.conf
[program:appname]
directory=/opt/appname
command=/opt/appname/bin/appname
stdout_logfile=/var/log/supervisor/appname-stdout.log
stderr_logfile=/var/log/supervisor/appname-stderr.log
ssh
允许 root 连接
打开 /etc/ssh/sshd_config
把 PermitRootLogin prohibit-password
改为 PermitRootLogin yes
连接不需要密码
ssh-copy-id -i ~/.ssh/id_rsa.pub 用户名@目标主机
nginx
配置目录 /etc/nginx/conf.d
新建文件 team.conf
server {
listen 80;
charset utf-8;
server_name team.impyq.com;
location /
{
proxy_pass http://127.0.0.1:5002;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-Ip $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
nginx -t # 测试
nginx -s reload # 重启
超时处理
TODO
参考 nginx 常用超时设置
hugo
地址: https://github.com/gohugoio/hugo/releases
注意下载 hugo_extended 版本, 不然会报错
Error: Error building site: TOCSS: failed to transform "sass/jane.scss" (text/x-scss). Check your Hugo installation; you need the extended version to build SCSS/SASS with transpiler set to 'libsass'.: this feature is not available in your current Hugo version, see https://goo.gl/YMrWcn for more information
下载 hugo_extended_0.111.3_linux-amd64.tar.gz
# 将 .tar.gz 下载到 ~/Downloads 目录下
wget 'https://github.com/gohugoio/hugo/releases/download/v0.111.3/hugo_extended_0.111.3_linux-amd64.tar.gz' -P ~/Downloads
解压缩
cd ~/Downloads
tar -xvzf hugo_extended_0.111.3_linux-amd64.tar.gz
将解压缩出来的可执行文件复制到 /usr/local/bin 目录下
cp ~/Downloads/hugo /usr/local/bin
node
官网: https://nodejs.org/en/download
下载二进制文件: Linux Binaries (x64)
参考: https://github.com/nodejs/help/wiki/Installation
安装:
sudo mkdir /usr/local/lib/nodejs
sudo tar -C /usr/local/lib/nodejs -xJvf ~/Downloads/node-v18.17.0-linux-x64.tar.xz
vim ~/.zshrc
export NODEJS=/usr/local/lib/nodejs/node-v18.17.0-linux-x64/bin
export PATH=$NODEJS:$PATH
lazygit
https://github.com/jesseduffield/lazygit/releases
下载 lazygit_0.40.0_Linux_x86_64.tar.gz
cd ~/Downloads
tar xvzf lazygit_0.40.0_Linux_x86_64.tar.gz
sudo mv lazygit /usr/local/bin