打开MobaXterm,登录进去之后,通过路径 ../usr/local/nginx/html/ 进入放项目的地方。
新建一个文件夹,命名为你的项目名,然后在你新建的文件夹里放入打包之后的项目文件。
接着:
1、在命令行输入 cd .. 回车(注意cd后面要有一个空格再..)
2、cd usr/ 回车
3、cd local/ 回车
4、cd nginx/ 回车
5、cd conf 回车
6、vi nginx.conf 回车
7、进入端口配置:
(1) Press ENTER or type command to continue(这里直接按回车);
(2) 在键盘按下字母键 i ,进入编辑模式;
(3) 这里假设我的项目名为charge,配置端口号为88,项目里跨域配置的路径重写为'/api',
数据请求的地址为http://47.92.34.130:8080/chargeSub/。
#gzip on;
upstream servercharge{
server localhost:88;
}
server {
listen 88;
server_name localhost;
location / {
root html/charge;
index index.html index.htm;
}
location /api {
# rewrite ^/apis/(.*)$ /$1 break;
proxy_pass http://47.92.34.130:8080/chargeSub/;
}
}
(4) 在键盘按下 Esc 键,退出编辑模式,接着 Shift + ; ,然后是输入命令 wq! ,
回车,保存并退出。
8、cd .. 回车
9、cd sbin/ 回车
10、 ./nginx -s reload 回车
完成!