1、安装node.js
cd /usr/local/src
// 安装node
wget https://nodejs.org/dist/v14.17.1/node-v14.17.1-linux-x64.tar.gz
// 解压文件
tar xzf node-v14.17.1-linux-x64.tar.gz
// 重命名
mv node-v14.17.1-linux-x64 nodejs
// 全局配置npm和node
ln -sf /usr/local/src/nodejs/bin/node /usr/local/bin/node
ln -sf /usr/local/src/nodejs/bin/npm /usr/local/bin/npm
2、安装Nginx
// 安装C语言环境
yum install gcc-c++
// 安装Nginx相关依赖
yum -y install pcre pcre-devel zlib zlib-devel openssl openssl-devel
// 创建nginx目录并进入
cd /usr/local
mkdir nginx
cd nginx
// 安装Nginx并解压
wget http://nginx.org/download/nginx-1.13.7.tar.gz
tar -xvf nginx-1.13.7.tar.gz
// 进入目录
cd /usr/local/nginx/nginx-1.13.7
// 安装证书
./configure --with-http_stub_status_module --with-http_ssl_module
make
make install
// 到此安装完成,启动/停止 Nginx
进入nginx的sbin目录:
cd /usr/local/nginx/sbin
./nginx 启动
./nginx -s stop 停止
./nginx -s reload 重启
3、配置Nginx的反向代理
修改nginx的配置文件
进入nginx配置文件的命令:cd /usr/local/nginx/conf
查看文件命令:vim nginx.conf
编辑文件命令:i
修改为如下配置:
```
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 8083;
server_name localhost;
location / {
root /home/front/dist;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
location ^~/api/ {
rewrite ^/api/(.*)$ /$1 break;
proxy_pass http://106.13.xx.xxx:8888;
}
location = /50x.html {
root html;
}
}
}
```
参考:blog.csdn.net/weixin_4646…