环境准备
Posted se7enjean
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了环境准备相关的知识,希望对你有一定的参考价值。
环境准备
- 操作系统:支持 macOS,Linux,Windows
- 运行环境:node.js 8.9 ~ 10.15.1。
- 应用数据库:mongodb
- 缓存数据库:redis
- web服务器:nginx
Node.js环境安装
#!/bin/bash
# 使用nvm安装node.js
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.1/install.sh | NVM_DIR=/usr/local/nvm bash
export NVM_NODEJS_ORG_MIRROR=https://npm.taobao.org/dist
echo "export NVM_DIR="/usr/local/nvm"" >> /etc/bashrc
echo "[ -s "\$NVM_DIR/nvm.sh" ] && \. "\$NVM_DIR/nvm.sh" " >> /etc/bashrc
echo "export NVM_NODEJS_ORG_MIRROR=https://npm.taobao.org/dist" >> /etc/bashrc
source /etc/bashrc
source ~/.bash_profile
nvm install 10.15.1
nvm alias default v10.15.1
nvm use 10.15.1
Mongodb环境安装
#!/bin/bash
cd /usr/src
wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-4.0.3.tgz
tar xvf mongodb-linux-x86_64-4.0.3.tgz
mv mongodb-linux-x86_64-4.0.3 mongodb
mkdir -p /data/mongodb/data && mkdir -p /data/mongodb/logs
# 启动服务
/usr/src/mongodb/bin/mongod --dbpath /data/mongodb/data --logpath /data/mongodb/logs/logs.log --fork --port 27017
Redis环境安装
#!/bin/bash
cd /usr/src
wget http://download.redis.io/releases/redis-5.0.5.tar.gz
tar xzf redis-5.0.5.tar.gz
cd redis-5.0.5
make
cd src
make install PREFIX=/usr/local/redis
mkdir -p /usr/local/redis/etc/
cp /usr/src/redis-5.0.5/redis.conf /usr/local/redis/etc
#后台启动
sed -i ‘s/daemonize no/daemonize yes/g‘ /usr/local/redis/etc/redis.conf
#启动redis
/usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf
Nginx环境安装
#!/bin/bash
cd /usr/src
wget http://nginx.org/download/nginx-1.12.0.tar.gz
tar xvf nginx-1.12.0.tar.gz
cd nginx-1.12.0
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
yum -y install pcre-devel openssl openssl-devel
make
make install
/usr/local/nginx/sbin/nginx
Nginx反向代理配置
* 80端口配置
upstream apubplat-servers
server 127.0.0.1:18888;
server
listen 80;
server_name xxx.xxx.com;
location /
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_pass http://apubplat-servers;
* 443端口配置
upstream apubplat-servers
server 127.0.0.1:18888;
server
listen 80;
server_name xxx.xxx.com;
add_header Strict-Transport-Security max-age=15768000;
return 301 https://$server_name$request_uri;
server
listen 443 ssl;
server_name xxx.xxx.com;
ssl_certificate /usr/local/nginx/conf/key/1_xxx.com_bundle.crt;
ssl_certificate_key /usr/local/nginx/conf/key/2_xxx.com.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location /
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_pass http://apubplat-servers;
Clone code
git clone https://github.com/wangweianger/APubPlat
Install
npm install
// development
npm run dev
// product
npm start
其它
// egg.js 日志位置
APubPlat/buildlogs/*.log
- 以上软件的安装均以linux系统为例
- 如果启动报错请注意各种应用否安装成功
以上是关于环境准备的主要内容,如果未能解决你的问题,请参考以下文章
环境初始化 Build and Install the Apache Thrift IDL Compiler Install the Platform Development Tools(代码片段