Linux上部署前后端項目詳細攻略

一、安裝Linux系統(tǒng)

1,使用UItralSO軟件制作U盤

https://www.cnblogs.com/coxiseed/p/9851459.html

2,U盤制作好了之后在需要安裝的主機上插入U盤,進入boos界面,選擇U盤啟動

3,設(shè)定管理員賬號密碼:管理員賬號root,密碼設(shè)置為admin2020

4,配置網(wǎng)絡:使用nmtui命令配置靜態(tài)IP地址,設(shè)置好網(wǎng)絡之后重啟服務器;

5,至此,服務器安裝Linux系統(tǒng)結(jié)束。

二、在Linux服務器上搭建Springboot-vue前后端分離項目的運行環(huán)境

1,查看Linux系統(tǒng)中yum下載安裝命令、wget下載命令是否齊全

2,下載Java運行環(huán)境(yum install java )

3,下載nginx并修改nginx配置文件(nginx.conf)

注意:

下載nginx

下載nginx使用 yum install nginx 命令會提示沒有可用的軟件包

使用命令sudo yum install epel-release安裝epel

使用yum update命令更新升級

從新使用yum install -y

nginx 安裝nginx

nginx配置文件

nginx.conf? 文件

user? nginx;

worker_processes? 1;

error_log? /var/log/nginx/error.log warn;

pid??????? /var/run/nginx.pid;

events {

??? worker_connections? 1024;

}

http {

??? include?????? /etc/nginx/mime.types;

??? default_type? application/octet-stream;

??? log_format?main? '$remote_addr - $remote_user[$time_local] "$request" '

????????????????????? '$status $body_bytes_sent"$http_referer" '

?????????????????????'"$http_user_agent" "$http_x_forwarded_for"';

??? access_log?/var/log/nginx/access.log? main;

??? client_max_body_size 1024M;

??? sendfile??????? on;

??? #tcp_nopush???? on;

??? keepalive_timeout? 1800;

??? #gzip?on;

??? include /etc/nginx/conf.d/*.conf;

}

default.conf???? 文件

server {

??? listen??????80;

??? server_name?localhost;

??? #charset koi8-r;

??? #access_log?/var/log/nginx/host.access.log?main;

??? location / {

??????? root??/usr/share/nginx/water;

??????? index?index.html index.htm;

??? }

??? location /water-api {

??????? proxy_set_header X-Real-IP$remote_addr;

??????? proxy_set_header REMOTE-HOST$remote_addr;

??????? proxy_set_header X-Forwarded-For$proxy_add_x_forwarded_for;

proxy_pass

http://localhost:8080/water-api;

??? }

??? #error_page?404????????????? /404.html;

??? # redirect server error pages to the staticpage /50x.html

??? error_page??500 502 503 504? /50x.html;

??? location = /50x.html {

??????? root??/usr/share/nginx/water;

??? }

}

開啟80和8080端口

查看已開啟的端口

firewall-cmd --list-ports

查看防火墻狀態(tài)

firewall-cmd --state

開啟防火墻

systemctl start firewalld

開啟端口

firewall-cmd --zone=public --add-port=8080/tcp --permanent

firewall-cmd --zone=public --add-port=80/tcp --permanent

重啟防火墻

firewall-cmd --reload

創(chuàng)建一個后端文件夾

mkdir -p /opt/iowater創(chuàng)建一個iowater文件夾用于存放后端文件

三、前后端項目打包發(fā)布

前端打包命令:npm run

build:stage

后端打包命令:mvn clean

package

將打包文件放入nginx指定文件夾下面,

前端放入cd /usr/share/nginx文件夾下面

后端放入cd /opt/iowater文件夾下面

后端使用命令啟動water-api.jar

(nohup?java?-server?-jar?-Dspring.profiles.active=prod?-Dserver.port=8080?water-api.jar?&)

Test:打開網(wǎng)頁直接輸入IP地址就可以訪問該系統(tǒng)了

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容