alinode在centos 7.2服务器安装试用记录

#1 安装zsh | oh-my-zsh

1
2
yum install -y zsh
chsh -s /bin/zsh // 切换到zsh

#2 安装最新版git

1
2
3
4
5
yum install -y epel-release  
rpm -ivh https://centos7.iuscommunity.org/ius-release.rpm
yum list git2u
yum install -y git2u
git --version

#3 安装 oh-my-zsh

1
2
wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh
vim ~/.zshrc // 修改theme为ys

#3.1 安装nginx

1
2
3
4
yum install -y nginx
systemctl enable nginx
systemctl start nginx
// /etc/nginx/nginx.conf

开端口

1
2
3
4
systemctl start firewalld // 很多没开,所以需要开
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --reload

#3.2 安装mariadb 以10.1老版本为例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//先去https://downloads.mariadb.org/mariadb/repositories/ 生成一坨东西

# MariaDB 10.1 CentOS repository list - created 2019-05-10 16:05 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.1/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

// 替换网址成阿里云的
# MariaDB 10.1 CentOS repository list - created 2019-05-10 16:05 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://mirrors.ustc.edu.cn/mariadb/yum/10.1/centos7-amd64/
gpgkey= http://mirrors.ustc.edu.cn/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck=1

// 在 /etc/yum.repos.d/ 下新建MariaDB.repo
cd /etc/yum.repos.d/
vim MariaDB.repo
// 把那坨东西复制进去,保存。然后运行安装命令
yum install -y MariaDB-server MariaDB-client
# 马上启动MariaDB
systemctl start mariadb

# 设置开机自动启动
systemctl enable mariadb
#初始化
/usr/bin/mysql_secure_installation
# 输入root账号密码(没有请直接回车)
Enter current password for root (enter for none):
# 为root设置密码? 按Y
Set root password? [Y/n]
// mimapassword
# 删除匿名用户,按Y
Remove anonymous users? [Y/n]
# 禁止root远程访问,需要远程管理,请按n
Disallow root login remotely? [Y/n]
# 删除test数据库及其访问权限,按Y
Remove test database and access to it? [Y/n]
# 重新加载访问权限,按Y
Reload privilege tables now? [Y/n]
# 修改授权
mysql -uroot -p
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'mimapassword' WITH GRANT OPTION;
FLUSH PRIVILEGES;

#4 安装nvm

1
2
3
4
5
6
7
8
9
10
11
12
13
14
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash

vim ~/.zshrc

// 把下面写入到最后一行
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion

// 还有这一堆,添加淘宝源的
# nvm
export NVM_NODEJS_ORG_MIRROR=https://npm.taobao.org/mirrors/node

source ~/.zshrc // 刷新配置文件

5 安装tmux

1
2
3
4
5
6
7
8
9
10
# 安装更新
yum update
# 下载rpm源
wget https://centos7.iuscommunity.org/ius-release.rpm
# 安装rpm源
rpm -Uvh ius-release*rpm
# 使用yum 安装软件
yum install tmux2u
# 显示tmux 版本
tmux -V

#5 安装tnvm 看冲突不

1
2
3
4
5
6
7
8
9
10
11
12
13
14
wget -O- https://raw.githubusercontent.com/aliyun-node/tnvm/master/install.sh | bash
// 在zshrc加入
vim ~/.zshrc

export TNVM_DIR="/root/.tnvm"
[ -s "$TNVM_DIR/tnvm.sh" ] && . "$TNVM_DIR/tnvm.sh" # This loads tnvm
// 然后
source ~/.zshrc

// 然后
tnvm install alinode-v4.7.2 (相当于10.15.3lts)
tnvm use alinode-v4.7.2

// 貌似没问题

#6 阿里云的性能平台

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

// 安装专用
npm install @alicloud/agenthub -g # 安装 agenthub

// 创建 alinode.json
{
"appid":"*****",
"secret":"dec02***********e886b324f17ed75"
}
// 写入保存,然后启动
agenthub start ~/alinode.json

agenthub list
// 然后启动项目

ENABLE_NODE_LOG=YES pm2 start /data/node/project-test/www/production.js --name project8080

商务洽谈