标签:cat ack try 镜像 ssi conf func 服务 require
nginx ,node 配置项目
1.安装好node,npm
2.安装cnpm,-g是全局的
sudo npm install -g cnpm --registry=https://registry.npm.taobao.org
3.通过cnpm安装扩展(淘宝镜像安装会很快)
cnpm install
4.安装pm2
sudo cnpm install -g pm2
5.开启服务
npm run server
server.js
var express = require('express');
var app = express();
var path = require('path');
var compression = require('compression')
app.use(compression());
app.use("/", express.static(path.join(__dirname, 'Public')));
app.use("/", express.static(__dirname));
app.use("*", function (req, res) {
res.sendFile(path.join(__dirname, 'html/index.html'));
});
app.listen(7002);
6.编译项目
npm run start
$ npm run start
> snake@1.1.0 start /home/wwwroot/default/taiqi/snake
> export NODE_ENV=dev && atool-build --config webpack.config.dev.js -w --no-compress --devtool "#source-map" -o ./wx_build
?? 1378/1378 build modules
webpack: bundle build is now finished.
7.访问项目
http://localhost:7002
8.配置nginx
server {
listen 80;
server_name jiqing.snake.com;
access_log /home/wwwlogs/access.log;
location / {
if ($request_uri ~ ^/api.php/) {
proxy_pass http://xxx.snake.com;
}
if ($request_uri !~ ^/api.php/) {
proxy_pass http://localhost:7002;
}
}
}
再配置个域名指向服务器,或者配置个hosts
sudo vim /etc/hosts
标签:cat ack try 镜像 ssi conf func 服务 require
原文地址:https://www.cnblogs.com/jiqing9006/p/9269959.html