@bornkiller
2017-10-31T15:40:58.000000Z
字数 3028
阅读 1615
前端实践
Mariadb
数据库;yum
源
# 推荐命名为 `MariaDB.repo`
# MariaDB 10.2 CentOS repository list - created 2017-10-20 02:54 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.2/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
# 快速安装
yum install -y MariaDB-server MariaDB-client;
同步过程中,遇到 emoji
等特殊字符,会导致无法入库,造成同步失败,问题为数据库编码.
修改配置文件:
[client]
default-character-set = utf8mb4
[mysql]
default-character-set = utf8mb4
[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
# 启动数据库
systemctl start mariadb;
# 设置开机启动
systemctl enable mariadb;
# 设置密码
SET PASSWORD FOR 'root'@'127.0.0.1' = PASSWORD('123456');
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('123456');
# 创建数据库
create database cnpmjs CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
cnpmjs.org
提供初始化脚本 docs/db.sql
,需要调整编码声明:
ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='*******';
可用版本详见 https://gist.github.com/bornkiller/739b60a5eef8d52f52e70b7228297a12
,执行内容即可完成库表初始化。
配置 cnpmjs.org
必要信息:
{
/**
* Cluster mode
*/
enableCluster: true,
// default system admins
admins: {
// name: email
},
database: {
db: 'cnpmjs',
username: 'root',
password: '123456',
// the sql dialect of the database
// - currently supported: 'mysql', 'sqlite', 'postgres', 'mariadb'
dialect: 'mariadb',
dialectOptions: {
charset: 'utf8mb4',
collate: 'utf8mb4_unicode_ci',
socketPath: '/var/lib/mysql/mysql.sock' // 指定套接字文件路径
},
// custom host; default: 127.0.0.1
host: '127.0.0.1'
},
// registry url name
registryHost: 'rn.juxinli.com',
// enable private mode or not
// private mode: only admins can publish, other users just can sync package from source npm
// public mode: all users can publish
enablePrivate: true,
// registry scopes, if don't set, means do not support scopes
scopes: [ '@universal', '@overseas', '@its', '@coco'],
// sync mode select
// none: do not sync any module, proxy all public modules from sourceNpmRegistry
// exist: only sync exist modules
// all: sync all modules
syncModel: 'exist', // 'none', 'all', 'exist'
}
私服启动后,默认为绑定本机,需要安装 nginx
用以代理,对外提供服务:
yum
源
# Nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
Nginx
# 快速安装
yum install -y nginx;
Nginx
server
{
listen 80;
server_name rnw.juxinli.com;
index index.html;
location /
{
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_connect_timeout 60;
proxy_send_timeout 60;
proxy_read_timeout 60;
proxy_pass http://127.0.0.1:7002;
}
}
server
{
listen 80;
server_name rn.juxinli.com;
index index.html;
location /
{
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_connect_timeout 60;
proxy_send_timeout 60;
proxy_read_timeout 60;
proxy_pass http://127.0.0.1:7001;
}
}
启动 nginx
之后,系统防火墙配置可能会导致无法对外服务,配置如下:
firewall-cmd --get-active-zones;
firewall-cmd --zone=public --add-port=80/tcp --permanent;
firewall-cmd --reload;
Email: hjj491229492@hotmail.com