CENTOS7常规初始化

更新系统

# 更换系统源
cd /etc/yum.repos.d
mv CentOS-Base.repo CentOS-Base.repo.old
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

yum clean all
yum makecache
yum update -y

# 修改 hostname
hostnamectl set-hostname yourhostname

常规环境配置

yum install zsh git lrzsz unzip tree -y

oh-my-zsh

# via curl
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

# via wget
sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

# oh-my-zsh 推荐使用主题 pygmalion
# sed -i '11s/|/ /' ~/.oh-my-zsh/themes/pygmalion.zsh-theme
# sed -i '12s/⇒/➜/' ~/.oh-my-zsh/themes/pygmalion.zsh-theme

sed -i '11s/ZSH_THEME="robbyrussell"/ZSH_THEME="pygmalion"/' ~/.zshrc
source ~/.zshrc

oh-my-zsh -- from gitee

git clone https://gitee.com/mirrors/oh-my-zsh.git ~/.oh-my-zsh
cp ~/.zshrc ~/.zshrc.orig
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
chsh -s $(which zsh)

nodejs

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

# 原生安装
mkdir -p /usr/local/lib/pkg && cd /usr/local/lib/pkg
wget https://nodejs.org/dist/v14.17.6/node-v14.17.6-linux-x64.tar.xz
xz -d node-v14.17.6-linux-x64.tar.xz
tar xf node-v14.17.6-linux-x64.tar
mv node-v14.17.6-linux-x64 ../node

cd /usr/local/bin
ln -s ../lib/node/bin/npm npm
ln -s ../lib/node/bin/npx npx
ln -s ../lib/node/bin/node node


# debian安装
curl -sL https://deb.nodesource.com/setup_10.x | bash -
# or
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -

apt install nodejs -y


# yum安装
curl  -sL https://rpm.nodesource.com/setup_lts.x | bash -
# or
curl  -sL https://rpm.nodesource.com/setup_18.x | bash -

yum install nodejs -y

nginx

yum info nginx
yum install nginx -y

nginx -t

systemctl status nginx
systemctl start nginx

# nginx default work dir: /usr/share/nginx/html

常见问题

# vim异常报错
_arguments:451: _vim_files: function definition file not found

# 解决方法
rm ~/.zcompdump*
exec zsh

make: g++: Command not found

yum install gcc-c++

SSH登录断线时间:服务端修改 etc/ssh/sshd_config

# server每隔60秒发送一次请求给client,然后client响应,从而保持连接
ClientAliveInterval 60 

# server发出请求后,客户端没有响应得次数达到3,就自动断开连接,正常情况下,client不会不响应
ClientAliveCountMax 15 

生成sshkey

ssh-keygen -t rsa -b 2048 -C "<comment>"

配置自定义指定sshkey ~/.ssh/config

Host gitlab.com
    hostname gitlab.com
    User git
    IdentityFile ~/.ssh/deploy