#!/bin/bash
## 初始化机器脚本
## centos 6
## 添加用户&修改密码
adduser hooke
passwd hooke
# By default, on CentOS, members of the wheel group have sudo privileges.
usermod -aG wheel hooke
# 切换用户
su - hooke
# 验证root权限
sudo ls -la /root
## 安装环境包
yum install git
## 安装node和node包
# 安装简单,但依赖外网
curl -sL https://rpm.nodesource.com/setup_12.x
sudo yum install -y nodejs
## nvm安装node
https://github.com/nvm-sh/nvm/blob/master/README.md#installing-and-updating
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
nvm install 11
nvm use 11
# 本地安装node,需手动安装
cd /pluto/apps/download/
tar -xvf node-v8.4.0-linux-x64.tar.xz
mv node-v8.4.0-linux-x64 /usr/local/node
rm /usr/local/bin/node /usr/local/bin/npm
ln -s /usr/local/node/bin/npm /usr/local/bin
ln -s /usr/local/node/bin/node /usr/local/bin
export NODE_HOME=/usr/local/node
export PATH=$PATH:$NODE_HOME/bin
export NODE_PATH=$NODE_HOME/lib/node_modules
echo "#####NODE######" >> /etc/profile
echo "export NODE_HOME=/usr/local/node" >> /etc/profile
echo "export PATH=$PATH:$NODE_HOME/bin" >> /etc/profile
echo "export NODE_PATH=$NODE_HOME/lib/node_modules" >> /etc/profile
source /etc/profile
# 安装npm包
# npm config set https://registry.npm.taobao.org
npm install -g n
npm install -g yarn
npm install -g cnpm
npm install -g pm2
## 换源
npm install -g nrm
nrm use taobao
nrm add jdb http://100.73.16.43:4873/
nrm use jdb
yarn config set registry http://100.73.16.43:4873/
# yum 安装nginx
# https://segmentfault.com/a/1190000007116797
rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
yum install nginx
yum info nginx
service nginx start
/etc/nginx/
sudo chown -R nginx:root /home/hooke/
## 设置权限
chmod -R 777 /data/pluto/
## 安装netdata&启动
## 教程: https://github.com/firehol/netdata/wiki/Installation
## visit: http://this.machine.ip:19999/
yum install autoconf automake curl gcc git libmnl-devel libuuid-devel lm-sensors make MySQL-python nc pkgconfig python python-psycopg2 PyYAML zlib-devel
cd /data/pluto/apps/download/netdata
unzip netdata-master.zip
cd netdata-master
./netdata-installer.sh && service netdata start
## One line installation
bash <(curl -Ss https://my-netdata.io/kickstart.sh)
# yum 安装nginx
# https://segmentfault.com/a/1190000007116797
rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
yum install nginx
yum info nginx
service nginx start
/etc/nginx/
sudo chown -R nginx:root /home/hooke/
# pip
sudo yum -y install epel-release
sudo yum -y install python-pip
查看状态
systemctl status nginx
systemctl status nginx.service
# 查看错误
sudo nginx -t
# 开启
sudo systemctl start nginx
# 关闭
sudo systemctl stop nginx
#重启
sudo systemctl restart nginx
# 杀死nginx进程
sudo pkill -9 nginx
/usr/sbin/nginx -c /etc/nginx/nginx.conf
# 修复静态资源权限错误
nginx.conf
user hooke
# 查看文件夹大小,清理
cd www/
du -h --max-depth=1
# 打包
tar -cvf www.tar www/
# 直传输文件夹
scp -r . root@118.24.23.94:/home/hooke/www/
# 传输压缩包
scp -r www.tar root@118.24.23.94:/home/hooke/
# download rpm file
wget *.rpm
# install local rpm
sudo rpm –i *.rpm