所需环境

1、mysql
2、redis
3、nginx安装
4、npm/nodejs环境
5、rap2-delos端安装
6、客户端dolores环境搭建

1、mysql安装

CentOS7的yum源中默认好像是没有mysql的。为了解决这个问题,我们要先下载mysql的repo源。

1. 下载mysql的repo源

$ wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm

2. 安装mysql-community-release-el7-5.noarch.rpm包

   $ sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm

安装这个包后,会获得两个mysql的yum repo源:/etc/yum.repos.d/mysql-community.repo,/etc/yum.repos.d/mysql-community-source.repo。

3. 安装mysql

$ sudo yum install mysql-server

根据步骤安装就可以了,不过安装完成后,没有密码,需要重置密码。

4. 重置密码

重置密码前,首先要登录

$ mysql -u root

登录时有可能报这样的错:ERROR 2002 (HY000): Can‘t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock‘ (2),原因是/var/lib/mysql的访问权限问题。下面的命令把/var/lib/mysql的拥有者改为当前用户:

$ sudo chown -R root:root /var/lib/mysql

5、修改my.cnf
vim /etc/my.cnf,修改的内容是:

[mysqld]
basedir=/home/mysql
datadir=/home/mysql/data
port=3306
skip-grant-tables
character_set_server=utf8
init_connect='SET NAMES utf8'
max_connections=500
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
#socket=/var/lib/mysql/mysql.sock# Disabling symbolic-links is recommended to prevent assorted security risks
#symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemdmax_allowed_packet=256M[client]
default-character-set=utf8#[mysqld_safe]
#log-error=/home/mysql/log/mariadb.log
#pid-file=/home/mysql/run/mariadb/mariadb.pid#
# include all files from the config directory
#
!includedir /etc/my.cnf.d

然后,重启服务:

$ service mysqld restart

6、接下来登录重置密码:

$ mysql -u root      (直接Enter进入)
修改root的密码
mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -ADatabase changed
mysql> update user set authentication_string = PASSWORD('123456') where user = 'root';
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 1mysql> \s
--------------
mysql  Ver 14.14 Distrib 5.7.21, for linux-glibc2.12 (x86_64) using  EditLine wrapperConnection id:     2
Current database:   mysql
Current user:       root@
SSL:            Not in use
Current pager:      stdout
Using outfile:      ''
Using delimiter:    ;
Server version:     5.7.21 MySQL Community Server (GPL)
Protocol version:   10
Connection:     Localhost via UNIX socket
Server characterset:    utf8
Db     characterset:    latin1
Client characterset:    utf8
Conn.  characterset:    utf8
UNIX socket:        /tmp/mysql.sock
Uptime:         4 min 43 secThreads: 1  Questions: 42  Slow queries: 0  Opens: 127  Flush tables: 1  Open tables: 122  Queries per second avg: 0.148
--------------mysql>

修改完成密码之后将/etc/my.cnf中的skip-grant-tables注释掉
然后重启mysql,执行命令:service mysqld restart

7. 需要更改权限才能实现远程连接MYSQL数据库

可以通过以下方式来确认:

mysql -u root –p     #接下来输入密码:123456
mysql> alter user 'root'@'localhost' identified by '123456';
Query OK, 0 rows affected (0.00 sec)mysql> grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
Query OK, 0 rows affected, 1 warning (0.00 sec)mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)mysql>

如果在上面步骤出现类似如下的错误:

ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql'

解决办法是:

service mysqld stop
mysqld_safe --user=mysql --skip-grant-tables --skip-networking &mysql -u root mysql
mysql>use mysql ;
mysql> UPDATE user SET Password=PASSWORD('123456') where USER='root' and host='127.0.0.l' or host='bigdata1' or host='localhost';//把空的用户密码都修改成非空的密码就行了。(我将此处的newpassword 改成了123456)
mysql> FLUSH PRIVILEGES;
mysql> quit然后service mysqld start
再次输入以下,发现已经需要输入密码了
mysql -uroot -p
[root@bigdata1 ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.6.43 MySQL Community Server (GPL)Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)
mysql> use mysql
mysql> grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
mysql> flush privileges;

可以查看密码信息

mysql> select host, user, password from user;
+-----------+------+-------------------------------------------+
| host      | user | password                                  |
+-----------+------+-------------------------------------------+
| localhost | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| bigdata1  | root | 123456                                    |
| 127.0.0.1 | root | 123456                                    |
| ::1       | root | 123456                                    |
| localhost |      | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| bigdata1  |      |                                           |
| %         | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
+-----------+------+-------------------------------------------+
7 rows in set (0.00 sec)mysql>

至此mysql安装完毕

2、安装redis

参考地址:https://www.cnblogs.com/zuidongfeng/p/8032505.html

3、nginx安装

安装方式:https://blog.csdn.net/tototuzuoquan/article/details/78155700
3.1 安装所需环境
Nginx 是 C语言 开发,建议在 Linux 上运行,当然,也可以安装 Windows 版本,本篇则使用 CentOS 7 作为安装环境。
一. gcc 安装
安装 nginx 需要先将官网下载的源码进行编译,编译依赖 gcc 环境,如果没有 gcc 环境,则需要安装:

yum install gcc-c++

二. PCRE pcre-devel 安装
PCRE(Perl Compatible Regular Expressions) 是一个Perl库,包括 perl 兼容的正则表达式库。nginx 的 http 模块使用 pcre 来解析正则表达式,所以需要在 linux 上安装 pcre 库,pcre-devel 是使用 pcre 开发的一个二次开发库。nginx也需要此库。命令:

yum install -y pcre pcre-devel

三. zlib 安装
zlib 库提供了很多种压缩和解压缩的方式, nginx 使用 zlib 对 http 包的内容进行 gzip ,所以需要在 Centos 上安装 zlib 库。

yum install -y zlib zlib-devel

四. OpenSSL 安装
OpenSSL 是一个强大的安全套接字层密码库,囊括主要的密码算法、常用的密钥和证书封装管理功能及 SSL 协议,并提供丰富的应用程序供测试或其它目的使用。
nginx 不仅支持 http 协议,还支持 https(即在ssl协议上传输http),所以需要在 Centos 安装 OpenSSL 库。
yum install -y openssl openssl-devel
3.2 官网下载
1.直接下载.tar.gz安装包,地址:https://nginx.org/en/download.html

2.使用wget命令下载(推荐)。
wget -c https://nginx.org/download/nginx-1.10.1.tar.gz

我下载的是1.10.1版本,这个是目前的稳定版。
3.3 解压
依然是直接命令:

tar -zxvf nginx-1.10.1.tar.gz -C /home/bigdata/installed/
cd nginx-1.10.1

3.4 配置
其实在 nginx-1.10.1 版本中你就不需要去配置相关东西,默认就可以了。当然,如果你要自己配置目录也是可以的。
1.使用默认配置

./configure

2.自定义配置(不推荐)

./configure \
--prefix=/usr/local/nginx \
--conf-path=/usr/local/nginx/conf/nginx.conf \
--pid-path=/usr/local/nginx/conf/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--with-http_gzip_static_module \
--http-client-body-temp-path=/var/temp/nginx/client \
--http-proxy-temp-path=/var/temp/nginx/proxy \
--http-fastcgi-temp-path=/var/temp/nginx/fastcgi \
--http-uwsgi-temp-path=/var/temp/nginx/uwsgi \
--http-scgi-temp-path=/var/temp/nginx/scgi

注:将临时文件目录指定为/var/temp/nginx,需要在/var下创建temp及nginx目录
3.5 编译安装

make
make install

查找安装路径:

whereis nginx


3.6 启动、停止nginx
cd /usr/local/nginx/sbin/
./nginx
./nginx -s stop
./nginx -s quit
./nginx -s reload
./nginx -s quit:此方式停止步骤是待nginx进程处理任务完毕进行停止。
./nginx -s stop:此方式相当于先查出nginx进程id再使用kill命令强制杀掉进程。
查询nginx进程:
ps aux|grep nginx
3.7 重启 nginx
1.先停止再启动(推荐):
对 nginx 进行重启相当于先停止再启动,即先执行停止命令再执行启动命令。如下:
./nginx -s quit
./nginx
2.重新加载配置文件:
当 ngin x的配置文件 nginx.conf 修改后,要想让配置生效需要重启 nginx,使用-s reload不用先停止 ngin x再启动 nginx 即可将配置信息在 nginx 中生效,如下:
./nginx -s reload
启动成功后,在浏览器可以看到这样的页面:

3.8 开机自启动
即在rc.local增加启动代码就可以了。
vi /etc/rc.local
增加一行 /usr/local/nginx/sbin/nginx (这里在实际的机器上已经注释掉了)
设置执行权限:
chmod 755 rc.local

到这里,nginx就安装完毕了,启动、停止、重启操作也都完成了,当然,你也可以添加为系统服务,我这里就不在演示了。

4、安装npm/nodejs环境

参考地址:https://blog.csdn.net/micarlxm/article/details/81091284
下载的版本是:wget https://nodejs.org/dist/latest-v8.x/node-v8.15.1-linux-x64.tar.gz

5、安装rap2-delos

1、下载服务端代码
git clone https://github.com/thx/rap2-delos.git

配置文件

目录:rap2-delos/src/config
文件:config.dev.ts;config.local.ts;config.prod.ts 请把三个文件都修改  请看下面注释
修改:config.dev.ts文件中db对象中username,password参数与本地或者开发环境的数据库信息匹配

上面三个 配置文件 config.*.tx 都要修改 主要是针对 mysql 做修改

import { IConfigOptions } from "../types";let config: IConfigOptions = {version: '2.3',serve: {port: 8080,},keys: ['some secret hurr'],session: {key: 'rap2:sess',},db: {dialect: 'mysql',host: 'localhost',port: 3306,username: 'root',password: '123456',database: 'db_rap2_delos_app',pool: {max: 5,min: 0,idle: 10000,},logging: false,},redis: {host: '127.0.0.1',port: 6379}
}export default config

三个文件都按照上面的文件进行配置

2、创建数据库
自己根据上面定义的数据名字创建 我的是 RAP2_DELOS_APP

CREATE DATABASE IF NOT EXISTS db_rap2_delos_app
DEFAULT CHARSET utf8
COLLATE utf8_general_ci;

3、安装依赖包

进入项目根目录
# cd rap2-delos
安装项目所需依赖
# npm install
全局安装PM2   这是用来启动服务端代码的
# npm install -g pm2
安装 TypeScript 编译包
# npm install typescript -g

4、初始化数据库

执行编译
# npm run build
如果上面编译报错  rimraf: command not found  则执行 npm install rimraf --save-dev -g  其他错误根据具体去处理初始化数据库  如果不执行上面的编译 直接执行初始化数据库会报错
# npm run create-db
如果上面报错 sh: cross-env: command not found  则先执行 npm install --save-dev cross-env -g

5、代码规范检查

# npm run check
如果上面报错 sh: tslint: command not found  则先执行 npm install -g tslint typescript

6、启动项目 下面两种不同的启动方式

开发模式 启动开发模式的服务器 监视并在发生代码变更时自动重启 (第一次运行比较慢,请耐心等待)
# npm run dev生产模式 启动生产模式服务器
# npm start没报错代表启动了起来   如果启动失败,请确认node 已经是10版本以上,如果不是 请先切换版本  nvm use v10.15.0

7、查看是否正常启动

1、执行命令 如下显示则代表数据库连接正常
pm2 log

DATABASE √
HOST localhost
PORT 3306
DATABASE RAP2_DELOS_APP

2、浏览器查看 ip:8080 请记得开放 8080 端口[下面代表启动正常]

1、执行命令 如下显示则代表数据库连接正常
pm2 log

DATABASE √
HOST localhost
PORT 3306
DATABASE RAP2_DELOS_APP

2、浏览器查看 ip:8080 请记得开放 8080 端口[下面代表启动正常]

RAP2后端服务已启动,请从前端服务(rap2-dolores)访问。 RAP2 back-end server is started, please visit via front-end service (rap2-dolores).

8、常见问题

1、执行npm run create-db命令,提示Unable to connect to the database:{ SequelizeAccessDeniedError: Access denied for user 'root'@'localhost' (using password:NO)}原因:未修改rap2-delos/src/config目录下数据库配置文件,或者是与文件中的数据库信息与之连接的数据库信息不匹配
解决方法:修改config.dev.ts文件数据库配置信息如果修改正确无误后,执行npm run create-db依旧出错,那么查看该项目中是否已经存在dist目录,如果有,请按照如上修改对应的数据库配置信息2、执行npm run dev命令,提示Error: listen EADDRINUSE :::8080原因:8080 端口被占用解决方法:杀掉占用 8080 端口的应用3、执行npm install 命令,提示hiredis 编译无法通过原因:无权限操作rap2-delos/node_modules/hiredis路径解决方法:sudo npm install如果提示sudo: npm: command not found,请参考 stackoverflow-npm,stackoverflow-node4、执行npm run dev可以正常启动,npm start命令无法正常启动服务原因:请使用pm2 logs查看日志具体定位5、示例:由于 Redis 的安全模式,不能正常使用ReplyError: Ready check failed: DENIED Redis is running in protected mode because protected mode is enabled, no bind address was specified, no authentication password is requested to clients. In this mode connections are only accepted from the loopback interface. If you want to connect from external computers to Redis you may adopt one of the following solutions: 1) Just disable protected mode sending the command 'CONFIG SET protected-mode no' from the loopback interface by connecting to Redis from the same host the server is running, however MAKE SURE Redis is not publicly accessible from internet if you do so. Use CONFIG REWRITE to make this change permanent. 2) Alternatively you can just disable the protected mode by editing the Redis configuration file, and setting the protected mode option to 'no', and then restarting the server. 3) If you started the server manually just for testing, restart it with the '--protected-mode no' option. 4) Setup a bind address or an authentication password. NOTE: You only need to do one of the above things in order for the server to start accepting connections from the outside.
解决方法: 使用--protected-mode no方式启动
---------------------
作者:清悟
来源:CSDN
原文:https://blog.csdn.net/qq_16142851/article/details/85198925
版权声明:本文为博主原创文章,转载请附上博文链接!

7、客户端dolores环境搭建

1、获取源代码

git clone https://github.com/thx/rap2-dolores.git
执行不成功 多执行几次,或者直接在浏览器打开 https://github.com/thx/rap2-dolores.git 去下载压缩包回来

2、配置文件

目录:rap2-dolores/src/config
文件:config.dev.ts; 其中 dev,表示开发环境,其他同理
修改:config.dev.ts文件,serve地址是 服务端 rap2-delos 部署成功后的地址,默认:'http://localhost:8080'   可以不做修改

最终修改如下 配置文件如下 请注意 ip 那里 不能使用 127.0.0.1 请使用服务器ip (可以尝试使用localhost试试)
module.exports = {
serve: ‘http://ip:8080’,
keys: [‘some secret hurr’],
session: {
key: ‘koa:sess’
}
}
3、安装项目依赖包

# npm install  【如果报下面错误】错误gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/data/wwwroot/rap2-dolores/node_modules/node-sass/.node-gyp'错误解决1、在项目根目录创建.npmrc文件,复制下面代码到该文件
phantomjs_cdnurl=http://cnpmjs.org/downloads
sass_binary_site=https://npm.taobao.org/mirrors/node-sass/
registry=https://registry.npm.taobao.org2、删除之前安装node-sass包
# npm uninstall node-sass
3、重新安装
# npm install -g node-sass如果上面还是不成功还是报错
ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/data/wwwroot/rap2-dolores/node_modules/node-sass/.node-gyp'安装淘宝 npm
# npm install -g cnpm --registry=https://registry.npm.taobao.org
使用cnpm 安装node-sass
# cnpm install -g node-sass执行成功后 再执行npm install

4、编译启动项目

01、开发模式 自动监视改变后重新编译
# npm run dev
备注:测试用例
# npm run test02、生产模式 编译 React 生产包
# npm run build

5、配置服务器 我使用的是nginx

使用 nginx 服务器路由到编译产出的 build 文件夹作为静态服务器即可配置如下   8181 是我的前端页面端口server {listen 8181;server_name _;root /data/wwwroot/rap2-dolores/build;index index.html index.htm;location / {try_files $uri /index.html;}error_page 500 502 503 504 /500.html;
}重新加载配置文件
# systemctl reload nginx访问服务 ip:8181  成功如果不成功 一直有圈圈在转 请查看 rap2-dolores/src/config/config.dev.ts 文件 ip 必须是服务器的ip 不能是127.0.0.1module.exports = {serve: 'http://ip:8080',keys: ['some secret hurr'],session: {key: 'koa:sess'}
}配置完成后 重新运行 npm run build  即可

rap2搭建,mysql,redis,nginx安装,node环境安装,rap2安装相关推荐

  1. Unbuntu 下安装node 环境

    在Unbuntu下安装node环境: 步骤命令: $ sudo apt-get install build-essential $ sudo apt-get install gcc $ sudo ap ...

  2. linux安装node环境

    1.服务器node环境安装 nvm安装 nvm是目前主流的node版本管理工具,可以快速安装node环境不需要下载包安装包,配置环境等一下一系列的繁琐步骤 执行以下命令 curl -o- https: ...

  3. 安装Node环境遇到的问题

    安装Node环境 遇到的问题 a later version of node.js has installed Vue项目中sass-loader版本踩坑 下载地址 遇到的问题 a later ver ...

  4. centos7 安装node环境(一遍过)

    centos7 安装node环境 前言: 查看当前系统架构 uname -n -r -p -o 在node官网有很版本的linux安装包,要选择对应的架构,不然可能会出错 node 所有版本的下载地址 ...

  5. Mac 下安装 ruby 环境解决 brew 安装 yarn 问题

    Mac 下安装 ruby 环境解决 brew 安装 yarn 问题 参考文章: (1)Mac 下安装 ruby 环境解决 brew 安装 yarn 问题 (2)https://www.cnblogs. ...

  6. 安装宝塔 linux centos7.5 mysql redis nginx 安装环境

    安装宝塔工具: yum install -y wget && wget -O install.sh http://download.bt.cn/install/install_6.0. ...

  7. centos搭建mysql、nginx、nodejs、screen

    从零开始配置centos服务器(mysql,nginx,nodejs,screen) 前言 需要的环境 mysql,node,nginx 一 centos系统源更新 yum update 二 安装上传 ...

  8. 企业实战_07_MyCat 搭建Mysql 一主一从复制环境

    接上一篇:企业实战_06_MyCat 常用的分片算法 https://gblfy.blog.csdn.net/article/details/118770261 文章目录 一. 环境准备 1. 主从复 ...

  9. php7.0康乐安装_Linux环境PHP7.0安装

    PHP7和HHVM比较 PHP7的在真实场景的性能确实已经和HHVM相当, 在一些场景甚至超过了HHVM.HHVM的运维复杂, 是多线程模型, 这就代表着如果一个线程导致crash了, 那么整个服务就 ...

最新文章

  1. 构建弹性架构组件—ELB和ASG
  2. vim win装_VIM的代码补全工具YouCompleteMe在Windows上的安装攻略
  3. 无线传感网3-2.高效率目标物监控
  4. mysql错误修改数据_使用正则表达式快速修改mysql中错误的varchar类型数据
  5. DeepMind 的马尔可夫决策过程(MDP)课堂笔记
  6. Linux编程手册读书笔记第二章(20140330)
  7. 【转】JMeter学习(十三)分布式部署
  8. Jsoup消除不受信任的HTML(用于防止XSS的攻击)
  9. ExcelManager--基于.Net的Excel读写管理类库(一)
  10. Python使用最小二乘法求解回归直线案例一则
  11. Python DButils
  12. Asp.Net Mvc3.0(MEF依赖注入理论)
  13. Kettle 简介和实例
  14. linux 设置自动定时清理日志
  15. Java httpClient 发送http请求
  16. JAVA读注册表获取My Document等目录
  17. python3装饰器例子_python3装饰器用法示例
  18. 【源码部署】Linux系统部署suricata
  19. 昌平二中2021高考成绩查询喜报,北京2021高考成绩排名榜单,北京各高中高考成绩喜报...
  20. Java集成融云服务端

热门文章

  1. Python爬虫实战:分析《战狼2》豆瓣影评
  2. Leetcode 1647. Minimum Deletions to Make Character Frequencies Unique [Python]
  3. cygwin+编译php,Windows 下:cygwin编译 HTS 安装
  4. 周易八卦——数字卦预测的程序实现
  5. yolov5 tensorrt 精度对齐总结
  6. PCL入门系列 —— PassThrough 直通滤波、点云裁剪
  7. PHPcurl请求很慢解决办法
  8. iOS 内购提示不允许App内购买项目,打开内购方式和检测不允许内购的方法。
  9. iOS内购项目的接入与审核问题
  10. 创业团队:太极图形团队