日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > linux >内容正文

linux

linux下Nginx部署前后端项目

發(fā)布時(shí)間:2023/12/20 linux 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 linux下Nginx部署前后端项目 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

Nginx 常用命令(Linux)

cd/usr/local/nginx/sbin ./nginx //啟動(dòng) ./nginx -s stop //停止 ./nginx -s quit //安全退出 ./nginx -s reload //重新加載配置文件 ./ps aux|grep nginx //查看nginx進(jìn)程

nginx的http配置

server {listen 8888;server_name localhost;location / {root html;index index.html index.htm;}location /mobile {alias /usr/local/nginx/html/mobile;index index.html;}#nginx部署vue項(xiàng)目出現(xiàn)404查找不到j(luò)s,css文件解決方法location ~* \.(gif|jpg|jpeg|png|css|js|ico|css|eot|svg|ttf|woff|mov)$ {root /usr/local/nginx/html/mobile;expires 48h;access_log off;}location /pc {alias /usr/local/nginx/html/pc;index index.html;}# apk下載location /apk{alias /usr/local/src/apk/;autoindex on;default_type application/octet-stream;}# 瀏覽器圖片預(yù)覽location /images{alias /usr/local/src/img/;autoindex on;}# 前后端不分離項(xiàng)目 jar包項(xiàng)目端口轉(zhuǎn)發(fā)location /visitor/{proxy_set_header Host $host:$server_port;proxy_set_header X-Real-Ip $remote_addr; # 允許IP訪問proxy_set_header X-Forwarded-For $remote_addr;# 反向代理proxy_pass http://127.0.0.1:8083/;}# 前后端分離項(xiàng)目 部署location /cdsm/{proxy_set_header Host $host:$server_port;proxy_set_header X-Real-Ip $remote_addr;proxy_set_header X-Forwarded-For $remote_addr;proxy_pass http://localhost:8082/;}}

nginx 部署多個(gè)前端項(xiàng)目

一 : 首先 , 在服務(wù)器/usr/local/nginx/html中新建前端項(xiàng)目文件夾(這里取名pc和mobile),用于存放vue打的包.

二 : vue.config.js文件修改publicPath 屬性 , 使index.html文件link到css文件時(shí)的路徑如下圖.

module.exports = {publicPath:'/pc/',... }


三 : 將vue項(xiàng)目打好的包 分別上傳到 對(duì)象的項(xiàng)目文件夾下(pc和mobile)
四 : 配置nginx的前端代理

listen 8888;server_name localhost;location / {root html;index index.html index.htm;}location /pc/{root html;index index.html index.htm;try_files $uri $uri/ /index.html; # 這個(gè)是方式前端頁面刷新404}location /mobile/{root html;index index.html index.htm;try_files $uri $uri/ /index.html; # 這個(gè)是方式前端頁面刷新404}

五 : 將java項(xiàng)目jar 包長(zhǎng)傳到服務(wù)器 , 并且運(yùn)行.

nohup java -jar ***.jar &

總結(jié)

以上是生活随笔為你收集整理的linux下Nginx部署前后端项目的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。