码迷,mamicode.com
首页 > 其他好文 > 详细

环境准备

时间:2019-06-07 23:20:56      阅读:237      评论:0      收藏:0      [点我收藏+]

标签:prefix   配置   后台   软件的安装   web   nodejs   lis   install   sbin   

环境准备

  • 操作系统:支持 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系统为例
  • 如果启动报错请注意各种应用否安装成功

环境准备

标签:prefix   配置   后台   软件的安装   web   nodejs   lis   install   sbin   

原文地址:https://www.cnblogs.com/se7enjean/p/10989401.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!