#1 ,home目录下 下载nodejs安装包,解压 并修改文件夹名称
wget https://nodejs.org/dist/v8.11.4/node-v8.11.4-linux-x64.tar.xz
tar xvf node-v8.11.4-linux-x64.tar.xz
mv node-v8.11.4-linux-x64 node-v8
# 2,做软连接配置node 命令 和 npm
[[email protected]]# ln -s /home/wwwroot/node/node-v8/bin/node /usr/local/bin/
[[email protected] node]# ln -s /home/wwwroot/node/node-v8/bin/npm /usr/local/bin/
[[email protected] node]# node -v
v8.11.4
#3,更改node模块文件夹的权限
[[email protected] node]# chgrp www node_modules/
[[email protected] node]# chown www node_modules/
#4,配置nginx
upstream nodejs{
server 127.0.0.1:8001;
keepalive 64;
}
server {
listen 80;
server_name node.domain.com;
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_set_header Connection "";
proxy_pass http://nodejs;
}
}
#5,重新加载nginx 配置文件
service nginx reload
原文地址:https://www.cnblogs.com/fslnet/p/11597959.html