nodejs探索与开发

sa03 18e05cc43a bug fix 8 år sedan
cjms 18e05cc43a bug fix 8 år sedan
nodebase 6fa123e141 完善参数检查 9 år sedan
.gitignore f1b31a0cfa 移动项目 8 år sedan
LICENSE e3583ddf43 Init commit 9 år sedan
README.md 59fc1ed867 1 9 år sedan

README.md

nodejs探索与开发

###安装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