Skip to content

2. Centos 初始化

bash
export https_proxy=http://192.168.123.119:1080 http_proxy=http://192.168.123.119:1080 all_proxy=socks5://192.168.123.119:1080
# 换源
bash <(curl -sSL https://cdn.jsdelivr.net/gh/SuperManito/LinuxMirrors@main/ChangeMirrors.sh)
bash <(curl -sSL https://linuxmirrors.cn/main.sh)


# bt遇见过不会自动安装libatomic, mysql又依赖这个包,造成mysqld启动失败, 再安装几个常用工具
dnf install -y libatomic git zsh tar zip unzip vim curl wget openssh-server
systemctl enable --now sshd
# bt在某些情况下会安装php失败,fatal error: netinet/sctp.h: No such file or directory
# 需要手动安装下边这个包
dnf install lksctp-tools-devel -y

# 如果希望默认shell是 bash 而不是zsh的话, 放在最后安装这个, 如果安装ohmyzsh时选错的默认shell的话,使用 chsh 改回bash/sh/ash
dnf install -y util-linux-user

mkdir -p /usr/local/nvm

sed -i '$a\
 # NVM 环境变量\
export NVM_BIN="/usr/local/nvm/versions/node" # node安装地址\
export NVM_DIR="/usr/local/nvm" # nvm安装地址\
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # 加载nvm\
# End NVM 环境变量' /etc/profile


# ohmyzsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# ohmyzsh 国内
sh -c "$(curl -fsSL https://gitee.com/mirrors/oh-my-zsh/raw/master/tools/install.sh \
   | sed 's|^REPO=.*|REPO=${REPO:-mirrors/oh-my-zsh}|g' \
   | sed 's|^REMOTE=.*|REMOTE=${REMOTE:-https://gitee.com/${REPO}.git}|g')"

sed -i 's/^ZSH_THEME=.*/ZSH_THEME="ys"/' ~/.zshrc
# 禁止ohmyzsh自动更新
sed -i "s/^# \?zstyle ':omz:update' mode disabled/zstyle ':omz:update' mode disabled/" ~/.zshrc
#禁止ohmyzsh自动更新-旧版本用下边这个,两个都操作一下比较好
sed -i 's/^#\?\s*DISABLE_AUTO_UPDATE=.*/DISABLE_AUTO_UPDATE="true"/' ~/.zshrc

# 使zsh加载/etc/profile
sed -i '$a\
if [ -f /etc/profile ]; then\
    source /etc/profile\
fi'  ~/.zshrc

# 先合 环境变量生效,然后安装nvm
source ~/.zshrc

# nvm
# curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.2/install.sh | bash

# nvm gitlab
# 改用gitlab来安装nvm githubusercontent.com在国内被墙,安装起来比较麻烦一点
export NVM_SOURCE=https://gitlab.com/mirrorx/nvm.git
curl -o- https://gitlab.com/mirrorx/nvm/-/raw/master/install.sh | bash

source ~/.zshrc

nvm install v22.14.0
# 设置命令行默认node版本
nvm alias default v22.14.0

# 更新 npm 并安装常用运行时
npm i -g npm@latest yarn bun deno pm2

# 如果需要bt

url=https://download.bt.cn/install/install_panel.sh;if [ -f /usr/bin/curl ];then curl -sSO $url;else wget -O install_panel.sh $url;fi;bash install_panel.sh ed8484bec

url=https://download.bt.cn/install/install_panel.sh;if [ -f /usr/bin/curl ];then curl -sSO $url;else wget -O install_panel.sh $url;fi;bash install_panel.sh la1027112
bash
rm -f /www/server/panel/data/admin_path.pl