sa03 18e05cc43a bug fix | преди 9 години | |
---|---|---|
cjms | преди 9 години | |
nodebase | преди 9 години | |
.gitignore | преди 9 години | |
LICENSE | преди 9 години | |
README.md | преди 9 години |
###安装nodejs
https://nodejs.org/
###安装express 及其项目生成器
npm install -g express
npm install -g express-generator
然后在项目根目录下执行 npm install
###启动服务
先安装nodejs自动重启服务
https://github.com/remy/nodemon
再执行命令:nodemon ./bin/www
###Nginx 反向代理Nodejs
upstream local_node {
server 127.0.0.1:3000;
#server 127.0.0.1:3001;
keepalive 64;
}
server {
listen 80;
server_name local.node.ouj.com;
#autoindex on;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://local_node;
proxy_redirect off;
}
#静态文件拦截,直接由Nginx提供服务
location ~ .*\.(html|css|js|eot|svg|ttf|woff|woff2|map)$ {
root /Users/sa/O+/nodejs/cjms/public;
expires off;
add_header Cache-Control no-cache;
}
}
###第三方库依赖
Node操作Redis https://github.com/luin/ioredis
Node操作MySQL https://github.com/felixge/node-mysql
自动重启Node服务 https://github.com/remy/nodemon