服务器Centos:新的服务器基本环境搭建,新的linux环境搭建/MiniBash/.bashrc
自己遇到的新的服务器,以Centos为例,常用的环境搭建
Mini bashrc(For ubuntu)
alias ..='cd ..'
alias ...='cd ../..'
alias acme.sh='~/.acme.sh/acme.sh'
alias alo7='cd ~/alo7i'
alias b='npm run build'
alias c-='cd -'
alias cls='clear'
alias cmod='chmod +x * .*'
alias count='ls | wc -l'
alias cwd='pwd | tr -d '\''\n'\'' | pbcopy'
alias d='cd /home/aric.zheng/aric-docify/docify-rails'
alias da='cd ~/alo7i/daily-works'
alias di='cd ~/github/diary'
alias e-hosts='sudo vim /etc/hosts'
alias e-npmrc='vim ~/.npmrc'
alias e-vimrc='vim ~/.vimrc'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias g='cd ~/github'
alias g-='git checkout -'
alias ga='git add '
alias gaa='git add -A'
alias gam='git commit -am '
alias gb='git branch '
alias gbh='git branch -h'
alias gc='git clone'
alias gc1='git clone --depth=1'
alias gcf='git clean -f'
alias gck='git checkout '
alias gckd='git checkout develop'
alias gckdev='git checkout dev'
alias gckm='git checkout master'
alias gckr='git checkout release'
alias gcm='git commit -m '
alias gcy='git cherry-pick'
alias gd='git diff'
alias ggg='gaa && gcm "wip" && gp'
alias git-size='git count-objects -vH'
alias gk='gitk --all&'
alias gl='git pull'
alias glb='git pull --rebase'
alias glo='git pull origin '
alias gm='git merge '
alias gmd='git merge develop'
alias gmdev='git merge dev'
alias gmm='git merge master'
alias goo='git checkout origin '
alias gp='git push'
alias gpa='git push --all -u'
alias gpd='git push origin --delete '
alias gpo='git push origin '
alias gpt='git push origin --tags'
alias gr='git checkout -f'
alias grb='git rebase '
alias grbd='git rebase develop'
alias grbdev='git rebase dev'
alias grbm='git rebase master'
alias grep='grep --color=auto'
alias gs='git status '
alias gx='gitx --all'
alias h='ssh'
alias i='npm i'
alias info='npm info --registry=https://registry.npmjs.org'
alias l='ls -al'
alias la='ls -A'
alias ll='ls -alF'
alias ls='ls --color=auto'
alias lv='lnav'
alias lwb='cd ~/aric-lwb'
alias m='cd /root/aric-server/monitor'
alias ng-list='npm list -g --depth 0'
alias ngx-reload='nginx -s reload'
alias ngx-start='nginx'
alias ngx-status='ps aux | grep nginx'
alias ngx-stop='nginx -s stop'
alias ngx-test='nginx -t'
alias ni='npm install --registry=https://registry.npm.taobao.org'
alias ni-d='npm install --save-dev'
alias ni-g='npm install -g'
alias ni-n='npm install --no-save'
alias ni-s='npm install --save'
alias ni-ug='npm uninstall -g'
alias ni7='npm install --registry=https://repos.saybot.net/repository/alo7npm/'
alias nii='npm install --registry=https://registry.npmjs.org'
alias nip='install-peers'
alias nipp='npm i && npm-install-peers'
alias nir='npm init release-it'
alias nl='npm link'
alias notes='cd ~/aric-notes'
alias np='npm publish'
alias np-clean='rm -rf node_modules'
alias np-remove='npm cache clean && rm -rf node_modules'
alias npp='npm publish --access=public'
alias nppc='npm publish --access=public && cnpm sync'
alias nr='npm run'
alias nrci='npm run release -- --ci --npm.skipChecks'
alias nrp='npm run publish'
alias nrr='npm run release'
alias nrrv='npm run release -- --only-version'
alias nu='npm update'
alias nv='npm version'
alias nvma='npm version major && git push --tags'
alias nvmi='npm version minor && git push --tags'
alias nvp='npm version patch'
alias nvpn='npm version patch --no-git-tag-version'
alias nvpp='npm version patch && git push --tags'
alias o='open .'
alias offline-site='wget -m -k -K -E '
alias offline-site-bg='wget -m -k -K -E -bqc'
alias op='open $(guc -u)'
alias opa='open $(guc -a)'
alias opm='open $(guc -m)'
alias opp='open $(guc -p)'
alias pbcopy='xclip -selection clipboard'
alias pbpaste='xclip -selection clipboard -o'
alias ppv='pubview'
alias pypi='cd ~/aric-pypi'
alias rbenv-global='rbenv global'
alias rbenv-i='rbenv install'
alias rbenv-list='rbenv install --list'
alias rbenv-update='brew upgrade rbenv; brew upgrade ruby-build'
alias rbenv-vers='rbenv versions'
alias reload='source $BASH_BASE_PATH/src/index.sh'
alias saybot='cd ~/saybot'
alias server='cd ~/aric-server'
alias sources-reload='sudo apt-get update && sudo apt-get upgrade'
alias spider='cd ~/aric-spider'
alias spj='sort-package-json'
alias sv='serve'
alias svv='serve .'
alias sys-hostname='sudo vim /etc/sysconfig/network'
alias sys-info='uname -a'
alias sys-issue='cat /etc/issue'
alias sys-memory='free -m'
alias sys-release='lsb_release -a'
alias sys-version='cat /proc/version'
alias sz='du -hs *'
alias szz='du -hks'
alias t='tmux'
alias t-close='tmux detach'
alias t-go='tmux switch -t'
alias t-kill='tmux kill-session -t'
alias t-ls='tmux ls'
alias t-mv='tmux rename-session -t'
alias t-open='tmux attach -t'
alias t-touch='tmux new -s'
alias tar-all='for file in *.tgz; do tar -zxf $file; done'
alias tar-ugz='tar *.tar.gz'
alias tbsync='cnpm sync'
alias tf='tail -f'
alias v='vim'
alias vim-init='git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim'
alias vim-install='vim +BundleInstall +qall'
alias vim-install-spf13='curl https://j.mp/spf13-vim3 -L > spf13-vim.sh && sh spf13-vim.sh'
alias vv='cd /tmp/ssh-4lLXa97ejBqj'
alias when-clear='whenever -c'
alias when-init='wheneverize .'
alias when-list='whenever'
alias when-list-all='crontab -l'
alias when-update='whenever --update-crontab'
alias x='exit'
alias y='yarn'
alias ya='yarn add '
alias ya-d='yarn add -D '
alias ya-g='yarn global add '
alias yarn-install='curl -o- -L https://yarnpkg.com/install.sh | bash'
alias yb='yarn build'
alias yd='yarn dev'
alias yg='yarn global add '
alias yi='yarn install'
alias yl='npm run logs'
alias yp='yarn publish'
alias ypp='yarn run publish'
alias ypr='yarn run release'
alias ypt='yarn run tagging'
alias yr='yarn remove '
alias ys='yarn start'
alias yst='yarn storybook'
alias yt='yarn test'
alias ytp='yarn run trypublish'
alias yu='npm run upgrade'
alias yv='npm run version'
alias yvp='yarn version patch'
# pyenv
export PYENV_ROOT="$HOME/.pyenv"
command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
# pm2
alias pm2-logs='pm2 logs'
alias pm22='pm2 start ecosystem.config.js'
alias pm2d='pm2 delete'
alias pm2dd='pm2 delete all'
alias pm2l='pm2 list'
alias pm2p='pm2 stop'
alias pm2pp='pm2 stop all'
alias pm2r='pm2 restart'
alias pm2rr='pm2 restart all'
alias pm2rt='pm2 reset all'
alias pm2s='pm2 start'
alias pm2ss='pm2 start all'
系统源替换
- centos7.x
- centos8.x
获取外网IP
# curl命令
curl icanhazip.com
# 利用wget在线设置
ip=`wget -qO- ipecho.net/plain`
# 利用ip命令
export SERVER_IP=$(ip a s dev eth0 | grep -oP 'inet\s+\K[^/]+')
添加 .netrc
有时候,有一些私有的项目,需要安装到服务器上去
修改 hostname
# 修改
hostnamectl set-hostname lwb-server
# 显示
hostname
# 退出、再进来验证
> [root@lwb-server:~]
系统基本包升级
yum -y update:升级所有包同时也升级软件和系统内核;
yum -y upgrade:只升级所有包,不升级软件和系统内核
常用必备软件
yum install vim ncdu tree lnav
yum install docker docker-compose -y
nodejs环境搭建
# 安装
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get install -y nodejs
# 确认
node -v && npm -v
# 安装必备包
npm i -g ntl pm2
安装 .dotfiles + centos-settings
# 安装 .dotifles
cd $HOME
git clone https://github.com/afeiship/dotfiles.git .dotfiles
./.dotfiles/bin/dfm install # creates symlinks to install files
# 安装 centos-settings
git clone git@github.com:afeiship/centos-settings.git
cd centos-settings && npm i
常用路径添加
DIR_BACKUP_HOME="/root/aric-server/backup-lwb"
python环境搭建
- 安装 pyenv
- 安装 python 3.10.0
- https://js.work/posts/30a4612b37c3d
- https://github.com/pyenv/pyenv
# 如果是在mac下,安装记得挂代理
curl https://pyenv.run | bash
# 测试(pyenv 2.2.4)
pyenv --version
# 安装python
pyenv install 3.10.0
ruby环境搭建
- 安装 rbenv
- 安装 ruby2.6.5
- https://js.work/posts/2c4fe637227b6
https 证书生成
# 安装
yum install certbot -y
# 确认
certbot --version
# 生成
certbot certonly --standalone --email 1290657123@qq.com -d js.work -d www.js.work -d api.js.work