环境配置快速复制

奕吉烨
奕吉烨
发布于 2023-11-25 / 241 阅读
2
0

环境配置快速复制

本人开发环境:ubuntu/debian

环境配置

换源

啥?换源?哪有比这个更好用的?USTC源配置快速生成器

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
sudo sed -i 's@//.*archive.ubuntu.com@//mirrors.ustc.edu.cn@g' /etc/apt/sources.list
sudo sed -i 's/security.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
sudo sed -i 's/http:/https:/g' /etc/apt/sources.list

LXC 语言修复

dpkg-reconfigure locales

zh_CN 该选的选

中文?

export LANG=zh_CN.UTF-8

NPM的安装

  1. 下载并导入 Nodesource GPG 密钥

sudo apt-get update
sudo apt-get install -y ca-certificates curl gnupg
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
  1. 创建 deb 存储库

NODE_MAJOR=20
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list

可选:NODE_MAJOR 可以根据您需要的版本进行更改。

NODE_MAJOR=16
NODE_MAJOR=18
NODE_MAJOR=20
NODE_MAJOR=21
  1. 运行更新并安装

sudo apt-get update
sudo apt-get install nodejs -y

NPM的卸载

apt-get purge nodejs &&\
rm -r /etc/apt/sources.list.d/nodesource.list &&\
rm -r /etc/apt/keyrings/nodesource.gpg

Git

git config --global user.name "***"  #名称
git config --global user.email ****@foxmail.com   #邮箱

Python 安装及换源

sudo apt-get install python3.10
sudo apt-get install python3-pip 
ll which python
sudo rm /usr/bin/python
sudo ln -s python3.10 /usr/bin/python
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple # 清华源
pip config set global.index-url https://mirror.baidu.com/pypi/simple # 百度源

代理配置

Npm

npm config set proxy http://127.0.0.1:10810
npm config set https-proxy http://127.0.0.1:10810

npm config delete proxy
npm config delete https-proxy

Yarn

yarn config set proxy http://127.0.0.1:10810
yarn config set https-proxy http://127.0.0.1:10810

yarn config delete proxy
yarn config delete https-proxy

Git

git config --global http.proxy http://127.0.0.1:10810  # 配置全局代理
git config --global https.proxy http://127.0.0.1:10810 # 配置全局代理

git config --global http.https://github.com/.proxy http://127.0.0.1:10810 # 配置 Github 代理
git config --global https.https://github.com/.proxy http://127.0.0.1:10810 # 配置 Github 代理

git config --global --unset http.proxy 
git config --global --unset https.proxy 

杂项

开机自启动 systemd 脚本的编写

  1. 安装 systemd

apt install systemd
  1. 创建 xxx.service 文件

使用文本编辑器(如 vim/nano)在 /etc/systemd/system 目录下创建一个 xxx.service 文件,用于配置 xxx 服务。

nano /etc/systemd/system/xxx.service
  1. 写入内容

[Unit]
# 服务名称,可自定义
Description = xxx server
After = network.target syslog.target
Wants = network.target

[Service]
Type = simple
WorkingDirectory = /path/to
ExecStart = /path/to/xxx

[Install]
WantedBy = multi-user.target
  1. 使用 systemd 命令管理 xxx 服务

# 启动xxx
systemctl start xxx
# 停止xxx
systemctl stop xxx
# 重启xxx
systemctl restart xxx
# 查看xxx状态
systemctl status xxx
# 开机自启动
systemctl enable xxx
# 取消开机自启动
systemctl disable xxx

windows11启停打印服务

net stop spooler
net start spooler

windows 下 vscode python 输出窗口中文乱码

环境变量- 新建环境变量- PYTHONIOENCODING- UTF8

PVE LXC 运行 docker

nano /etc/pve/lxc/容器id.conf 添加下面几行

lxc.apparmor.profile: unconfined
lxc.cgroup.devices.allow: a
lxc.cap.drop:

Nginx反代去除路径的做法

location ^~ /xxx {
    rewrite ^/xxx(?:/(.*))?$ /$1 break;
    proxy_pass http://127.0.0.1:18080;
}

PVE LXC ubuntu修改ssh端口后开机自启动sshd失效

很抽象的一个问题

systemctl mask ssh.socket
systemctl mask sshd.socket
systemctl enable ssh

生成SSH密钥

ssh-keygen -t ed25519 -C "your_email@example.com"

windows开机自启动文件夹

win+R 运行输入 shell:startup

PVE更换LXC源

cp /usr/share/perl5/PVE/APLInfo.pm /usr/share/perl5/PVE/APLInfo.pm.bak
sed -i 's|http://download.proxmox.com|https://mirrors.ustc.edu.cn/proxmox|g' /usr/share/perl5/PVE/APLInfo.pm
systemctl restart pvedaemon.service


评论