下载teaching-pen 2.7项目资料压缩包,包含文件如下
CSDN文件下载地址:https://download.csdn.net/download/qq_29434571/88622706
html:前端页面
application-prod.yml:项目配置
teachingopen2.7.jar:后端jar包
nginx.conf:nginx配置,配置页面路径和证书一级后端接口访问地址
tachingopen2.7.sql:SQL文件
win系统启动:
- 安装mysql 创建数据库teachopen并执行脚本
- 如果需要数据库操作软件可以下载免费的DBeaver,也可以使用体验更好的navcat(破街版)
- 安装java配置环境变量 比较简单自行搜索
1. nginx 下载解压如图
-
- 下载地址 nginx https://nginx.org/download/nginx-1.18.0.zip
2. html 资源覆盖nginx目录下html
3. nginx.conf 配置只需要添加下面两个server
注意只需要修改域名,如果不需要开启证书直接注释点第5行跳转代码只留80端口的服务
server
{
listen 80 ;
server_name localhost; #改成你的域名
rewrite ^(.*)$ https://$host permanent; #如果开启了https,则把所有http进行调整https
location / {
index index.html index.htm;
root html; #网站前端位置
if (!-e $request_filename) {
rewrite ^(.*)$ /index.html?s=$1 last;
break;
}
gzip on;
gzip_min_length 1k;
gzip_comp_level 9;
gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
gzip_vary on;
gzip_disable "MSIE [1-6]\.";
}
location ^~ /api
{
expires 0;
proxy_pass http://127.0.0.1:8081/api/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header domain localhost;
#持久化连接相关配置
proxy_connect_timeout 30s;
proxy_read_timeout 600s;
proxy_send_timeout 30s;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade"; #Set Nginx Cache}
}
}
#如果暂时没有证书可以删除
server {
listen 443 ssl;
server_name liziit.com ;
root /usr/share/nginx/html; #网站前端位置
index index.html index.htm;
# SSL
ssl_certificate /etc/nginx/ssl/liziit.com.pem;
ssl_certificate_key /etc/nginx/ssl/liziit.com.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
location / {
root /usr/share/nginx/html; #网站前端位置
index index.html index.htm;
if (!-e $request_filename) {
rewrite ^(.*)$ /index.html?s=$1 last;
break;
}
gzip on;
gzip_min_length 1k;
gzip_comp_level 9;
gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
gzip_vary on;
gzip_disable "MSIE [1-6]\.";
}
location ^~ /api
{
expires 0;
proxy_pass http://127.0.0.1:8081/api/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header domain localhost;
#持久化连接相关配置
proxy_connect_timeout 30s;
proxy_read_timeout 600s;
proxy_send_timeout 30s;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade"; #Set Nginx Cache}
}
}
4. 后端配置修改 application-prod.yml
- 数据库、redis、数据存储方式本地还是七牛,七牛就需要创建七牛账号,创建空间,个人信息找到秘钥,一开始使用测试域名就可以,上线了添加自定义域名开启https以及防盗链
server:
port: 8081
tomcat:
max-swallow-size: -1
servlet:
context-path: /api
compression:
enabled: true
min-response-size: 1024
mime-types: application/javascript,application/json,application/xml,text/html,text/xml,text/plain,text/css,image/*
management:
endpoints:
web:
exposure:
include: metrics,httptrace
spring:
servlet:
multipart:
max-file-size: 2000MB
max-request-size: 2000MB
mail:
host: smtp.qq.com
username: ??
password: ??
properties:
mail:
smtp:
auth: true
starttls:
enable: true
required: true
## quartz定时任务,采用数据库方式
quartz:
job-store-type: jdbc
initialize-schema: embedded
#设置自动启动,默认为 true
auto-startup: true
#启动时更新己存在的Job
overwrite-existing-jobs: true
properties:
org:
quartz:
scheduler:
instanceName: MyScheduler
instanceId: AUTO
jobStore:
class: org.quartz.impl.jdbcjobstore.JobStoreTX
driverDelegateClass: org.quartz.impl.jdbcjobstore.StdJDBCDelegate
tablePrefix: QRTZ_
isClustered: true
misfireThreshold: 60000
clusterCheckinInterval: 10000
threadPool:
class: org.quartz.simpl.SimpleThreadPool
threadCount: 10
threadPriority: 5
threadsInheritContextClassLoaderOfInitializingThread: true
#json 时间戳统一转换
jackson:
date-format: yyyy-MM-dd HH:mm:ss
time-zone: GMT+8
aop:
proxy-target-class: true
activiti:
check-process-definitions: false
#启用作业执行器
async-executor-activate: false
#启用异步执行器
job-executor-activate: false
jpa:
open-in-view: false
#配置freemarker
freemarker:
# 设置模板后缀名
suffix: .ftl
# 设置文档类型
content-type: text/html
# 设置页面编码格式
charset: UTF-8
# 设置页面缓存
cache: false
prefer-file-system-access: false
# 设置ftl文件路径
template-loader-path:
- classpath:/templates
# 设置静态文件路径,js,css等
mvc:
static-path-pattern: /**
resource:
static-locations: classpath:/static/,classpath:/public/
autoconfigure:
exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
datasource:
druid:
stat-view-servlet:
enabled: true
loginUsername: root
loginPassword: 123456
allow:
web-stat-filter:
enabled: true
dynamic:
druid: # 全局druid参数,绝大部分值和默认保持一致。(现已支持的参数如下,不清楚含义不要乱设置)
initial-size: 5
min-idle: 5
maxActive: 20
# 配置获取连接等待超时的时间
maxWait: 60000
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
timeBetweenEvictionRunsMillis: 60000
# 配置一个连接在池中最小生存的时间,单位是毫秒
minEvictableIdleTimeMillis: 300000
validationQuery: SELECT 1 FROM DUAL
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
# 打开PSCache,并且指定每个连接上PSCache的大小
poolPreparedStatements: true
maxPoolPreparedStatementPerConnectionSize: 20
# 配置监控统计拦截的filters,去掉后监控界面sql无法统计,'wall'用于防火墙
filters: stat,wall,slf4j
# 通过connectProperties属性来打开mergeSql功能;慢SQL记录
connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
datasource:
master:
url: jdbc:mysql://127.0.0.1:3306/teachopen?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true
username: root
password: 123456
driver-class-name: com.mysql.jdbc.Driver
#redis 配置
redis:
database: 1
host: 127.0.0.1
lettuce:
pool:
max-active: 8 #最大连接数据库连接数,设 0 为没有限制
max-idle: 8 #最大等待连接中的数量,设 0 为没有限制
max-wait: -1ms #最大建立连接等待时间。如果超过此时间将接到异常。设为-1表示无限制。
min-idle: 0 #最小等待连接中的数量,设 0 为没有限制
shutdown-timeout: 100ms
password: 123456
port: 6379
#mybatis plus 设置
mybatis-plus:
mapper-locations: classpath*:org/jeecg/modules/**/xml/*Mapper.xml
global-config:
banner: false
db-config:
id-type: 4
table-underline: true
configuration:
call-setters-on-nulls: true
#jeecg专用配置
jeecg :
# 是否允许多端登录
multiLogin: false
# 站点域名
domain: localhost
# 本地:local 七牛云:qiniu
uploadType: qiniu
path :
#文件上传根目录 设置
upload: D://opt//upFiles
#webapp文件路径
webapp: D://opt//webapp
# 文件访问地址
staticDomain: /api/sys/common/static
#短信秘钥
sms:
accessKeyId: ??
accessKeySecret: ??
templateCode: ??
signName: ??
keys:
shiro:
excludeUrls: /test/jeecgDemo/demo3,/test/jeecgDemo/redisDemo/**
#阿里云oss存储配置
oss:
endpoint: oss-cn-beijing.aliyuncs.com
accessKey: ??
secretKey: ??
bucketName: jeecgos
staticDomain: ??
#七牛云存储配置
qiniu:
accessKey: xx
secretKey: xx
bucketName: teachingtest
staticDomain: //cdn.xx.cn
# 七牛存储区域 z0:华东 z1:华北 z2:华南 na0:北美 as0:东南亚 cn-east-2:华东-浙江2
area: z0
# 表单设计器配置
desform:
# 主题颜色(仅支持 16进制颜色代码)
theme-color: "#1890ff"
# 在线预览文件服务器地址配置
file-view-domain: http://fileview.jeecg.com
# minio文件上传
minio:
minio_url: http://minio.jeecg.com
minio_name: ??
minio_pass: ??
bucketName: otatest
#Mybatis输出sql日志
logging:
level:
org.jeecg.modules.system.mapper : debug
org.jeecg.modules.teaching.mapper: debug
org.jeecg.modules.wechat.mapper: debug
#enable swagger
swagger:
enable: true
5. 后端指定配置文件启动jar:
找到jar所在目录,地址栏输入cmd按回车打开命令行输入以下命令启动
指定配置文件启动:
java -jar -Dspring.config.location=./application-prod.yml teachingopen2.7.jar
如果想长期在win上使用则需要后台启动并设置重启,可以参考这篇文章【Windows、Linux 直接启动Jar包程序】_windows nohup java -jar-CSDN博客
6. 启动nginx
访问: localhost
需要注意的是,启动会一闪而过,后台运行的,如果需要重新启动请先杀掉后台资源nginx再启动
linux系统部署:
redis和数据库,java安装自行百度,执行数据库脚本
linux连接工具很多,这里推荐免费的 FinalShell
1. nginx安装
apt-get install nginx
nginx -v
service nginx start
或者
systemctl start nginx
查看状态
systemctl status nginx
重启
systemctl restart nginx
nginx文件安装完成之后的文件位置:
- /usr/sbin/nginx:主程序
- /etc/nginx:存放配置文件
- /usr/share/nginx:存放静态文件
- /var/log/nginx:存放日志
2. 上传文件
- html → /usr/share/nginx
- nginx.conf → /etc/nginx
如果用localhost域名就得用ip访问,换成域名要解析后访问
- 创建文件夹mkdir teach,cd /teach 然后上传后台配置文件和jar在同一目录
3. 启动后端
后端配置文件改动的内容和win一样,数据库,redis 的ip和端口一级七牛相关配置
nohup java -jar -Dspring.config.location=./application-prod.yml teachingopen2.7.jar > start1.log 2>&1 &
4. 访问域名或者ip即可看到页面
账号密码:admin 123456
5. 注意
- 本地部署启动如果遇到头像不显示或者文件问题可发送具体报错信息请留言,理论上提供的配置模板没有问题
- 等后台启动成功后访问前端,否则报接口响应错误
- 配置文件都是优化后的,只需要按要求修改,别的地方不要动
体验地址:liziit.com