前言
首先是需要在服务器安装环境的如,JDK、Mysql、nginx。把环境都配置好之后开始下一步。
Nginx部署Vue打包的dist
先说一下nginx在linux中的一些简单命令吧。
nginx命令
进入nginx目录下 nginx -v 查看版本号
nginx 开启nginx
nginx -t 检查配置文件语法
systemctl restart nginx
nginx配置
在linxu中nginx目录下有一个nginx.conf的文件windos可能在conf目录下
使用vim/vi打开 vi/vim nginx.conf 如图所示
如图注释 listen 写服务器对外的端口号、server_name写当前服务器的ip地址
location后面接匹配的url 路径现在是匹配/, 可以使用通配*等,如/ossupload/** 在携带一个参数proxy_pass就可以请求转发了,proxy_pass {server_name}:{listen}/xxx/xxx;其中{}都为参数
root 为路径名称 使用绝对路径和相对路径尝试一下吧,指向我们那个dist文件。
index 指定访问那个文件
退出保存后 先检测语法问题,没有报错重启即可。
部署Springboot项目
在pom.xml文件下添加如下打包插件
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <includeSystemScope>true</includeSystemScope> </configuration> </plugin> </plugins> </build>
这个比较简单先使用用maven命令 clean package 会把程序打包在target目录下成一个jar包
,直接放入linux文件中
输入 java -jar ******.jar 这个是在命令行运行,删除后就停止运行。我们采用后台运行
nohup java -jar *****.jar 不过这个我们没有日志
nohup java -jar ******.jar > 1.file > 2>&1 & 指定文件输出日志
然后我们可以用 cat 1.file查看日志。