项目部署
方式一: nginx 部署
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| 24 cd services/ 25 curl -o nginx-1.24.0.tar.gz https://nginx.org/download/nginx-1.24.0.tar.gz
26 tar -zxvf nginx-1.24.0.tar.gz 27 ls
28 cd nginx-1.24.0/ 29 ls
30 ./configure
31 apt-get install libpcre3 libpcre3-dev 32 ./configure
sudo apt install zlib1g-dev
33 apt-get install openssl libssl-dev 34 ./configure
37 ./configure --with-http_ssl_module --with-http_v2_module --with-stream
39 make
40 make install
vim /etc/profile
|
新增环境变量
1 2 3 4 5 6 7
| export PATH=$PATH:/usr/local/nginx/sbin
source /etc/profile
nginx
netstat -ntlp
|
部署前端项目
1 2 3 4 5 6 7 8 9 10 11 12
|
82 apt install unzip
83 unzip dist.zip -d user_center_b
84 cd user_center_b/dist 85 mv * ../ 86 cd ../ 87 rm -r dist
88 vim /usr/local/nginx/conf/nginx.conf
|
修改配置文件
1 2 3 4
| location/{ root /root/services/user_center_b; index index.html index.htm; }
|
修改权限
1 2 3 4 5
| user root;
nginx -s reload
ps -ef|grep 'nginx'
|
访问公网IP响应
403 Forbidden
部署宝塔
1 2 3 4
| 外网面板地址: https://47.92.126.51:29319/4e1eb856 内网面板地址: https://172.17.144.26:29319/4e1eb856 username: qysqtvoz password: f27640e0
|
后端部署
java、maven
1 2 3 4 5 6 7 8
| apt install -y openjdk-8-jdk
curl -o apache-maven-3.9.4-bin.tar.gz https://dlcdn.apache.org/maven/maven-3/3.9.4/binaries/apache-maven-3.9.4-bin.tar.gz
tar -zxvf apache-maven-3.9.4-bin.tar.gz
vim /etc/profile
|
最后一行添加为maven文件路径
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| export PATH=$PATH:/usr/local/nginx/sbin:/root/services/apache-maven-3.9.4/bin
source /etc/profile
mvn -v $ Apache Maven 3.9.4 (dfbb324ad4a7c8fb0bf182e6d91b0ae20e3d2dd9) $ Maven home: /root/services/apache-maven-3.9.4 $ Java version: 1.8.0_362, vendor: Private Build, runtime: /usr/lib/jvm/java-8-openjdk-amd64/jre $ Default locale: en_US, platform encoding: UTF-8 $ OS name: "linux", version: "4.15.0-213-generic", arch: "amd64", family: "unix"
apt install -y git
git clone https://gitee.com/znxs159357/user_center_c.git
username: password:
chmod a+x user_center_c-0.0.1-SNAPSHOT.jar
java -jar user-center-c-0.0.1-SNAPSHOT.jar --spring.profiles.active=pord
nohup java -jar user-center-c-0.0.1-SNAPSHOT.jar --spring.profiles.active=pord & root@VM-4-7-ubuntu:~/services/user_center_c [1] 29853 nohup: ignoring input and appending output to 'nohup.out' root@VM-4-7-ubuntu:~/services/user_center_c [1]+ Running nohup java -jar user-center-c-0.0.1-SNAPSHOT.jar --spring.profiles.active=pord & root@VM-4-7-ubuntu:~/services/user_center_c Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 821/rpcbind tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 1469/nginx: worker tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN 1223/systemd-resolv tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 14364/sshd tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN 12081/sshd: root@pt tcp 0 0 127.0.0.1:6011 0.0.0.0:* LISTEN 32447/sshd: root@pt tcp6 0 0 :::111 :::* LISTEN 821/rpcbind tcp6 0 0 :::8080 :::* LISTEN 29853/java root@VM-4-7-ubuntu:~/services/user_center_c 30225 Jps 29853 jar
|
到这里,项目的部署就完成了,虽然没有数据库,但是前后端都已经部署完成了
方式二:宝塔部署
宝塔linux
直接在服务器里面安装宝塔
1 2 3 4
| 外网面板地址: http://101.35.50.21:8888/tencentcloud 内网面板地址: http://10.0.4.7:8888/tencentcloud username: norwtlt4 password: d2102b31f9ca
|
安装完宝塔记得关闭tomcat服务器
方式三:Docker部署
宝塔下载Docker
后端 Dockerfile
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| FROM maven:3.5-jdk-8-alpine as builder
WORKDIR /app
COPY pom.xml .
COPY src ./src
RUN mvn package -DskipTests
CMD ["java","-jar","/app/target/father-backend-0.0.1-SNAPSHOT.jar","--spring.profiles.active=prod"]
|
dockerfile 文件名记得别取错了
拉取项目到
创建docker镜像
1
| docker build -t user_center_c:v0.0.1 .
|
前端Dockerfile
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| FROM nginx
WORKDIR /usr/share/nginx/html/ USER root
COPY ./docker/nginx.conf /etc/nginx/conf.d/default.conf
COPY ./dist /usr/share/nginx/html/
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"] nginx.conf server { listen 80;
gzip on; gzip_min_length 1k; gzip_comp_level 9; gzip_types text/plain text/css text/javascript application/json application/javascript application/x-javascript application/xml; gzip_vary on; gzip_disable "MSIE [1-6]\.";
root /usr/share/nginx/html; include /etc/nginx/mime.types;
location / { try_files $uri /index.html; }
}
|
拉取项目到
创建docker镜像
1
| docker build -t user_center_b:v0.0.1 .
|