Blog 项目是我参照 TyCoding 大神的 Tumo 项目写的一个个人博客。项目采用 SpringBoort
+ Shiro
+ MyBatis
+ Vue
+ Thymeleaf
技术开发,数据存储方面使用了 MySQL
和 Redis
。项目采用 Github Webhooks
推送触发 jenkins
自动打包 Docker
镜像部署。默认主题使用了漂亮的 pinghsu ,简洁大方。
JDK
网上资料很多
MySQL
rpm -qa | grep -i mysql
或
yum list installed | grep mysql
yum -y remove myql......
MySQL
YUM
源wget -i -c http://repo.mysql.com/mysql57-community-release-el7-11.noarch.rpm
YUM
源rpm -ivh mysql57-community-release-el7-11.noarch.rpm
MySQL
yum install mysql-server
一路
Y
到底。
MySQL
systemctl start mysqld
查看启动状态
systemctl status mysqld
grep password /var/log/mysqld.log
mysql -uroot -p
// 输入零时密码
# 更新密码
alter user 'root'@'localhost' identified by '新密码';
# 设置密码永不过期
ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;
git
yum install git // 这个不行 版本太旧
https://blog.csdn.net/zxy987872674/article/details/79220469
jenkins
下载jenkins.war
下载网址:https://www.jenkins.io/download/
java -jar jenkins.war --httpPort=6080
端口号任意
nginx
网上教程很多
nginx
购买域名,并解析到当前服务器。
https://www.kkrepo.com 这个域名做博客域名
https://jenkins.kkrepo.com 这个域名做
jenkins
域名
申请域名对应的免费证书
/etc/nginx
.
| - nginx.conf
| - conf.d
| - ssl // 存放证书的文件夹
| - www.kkrepo.com_bundle.crt
| - www.kkrepo.com.key
| - jenkins.kkrepo.com_bundle.crt
| - jenkins.kkrepo.com.key
| - www.conf // www.kkrepo.com 域名配置
| - jenkins.conf // jenkins.kkrepo.com 域名配置
nginx.conf
配置user nginx;
worker_processes 2;
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;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
# 引入 conf.d 文件夹中的配置文件
include /etc/nginx/conf.d/*.conf;
}
www.conf
配置server {
listen 80;
server_name kkrepo.com;
rewrite ^(.*)$ https://www.kkrepo.com$1 permanent;
}
server {
listen 80;
server_name www.kkrepo.com;
rewrite ^(.*)$ https://${server_name}$1 permanent;
}
server {
listen 443;
server_name kkrepo.com;
rewrite ^(.*)$ https://www.kkrepo.com$1 permanent;
}
server {
listen 443 ssl http2 default_server;
server_name www.kkrepo.com;
ssl_certificate /etc/nginx/conf.d/ssl/www.kkrepo.com_bundle.crt;
ssl_certificate_key /etc/nginx/conf.d/ssl/www.kkrepo.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.2;
ssl_prefer_server_ciphers on;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:8080;
}
access_log logs/www.log main;
}
jenkins.conf
配置upstream jenkins {
server 127.0.0.1:6080;
}
server {
listen 80;
server_name jenkins.kkrepo.com;
rewrite ^(.*)$ https://${server_name}$1 permanent;
}
server {
listen 443 ssl http2;
server_name jenkins.kkrepo.com;
root /usr/share/nginx/html;
ssl_certificate /etc/nginx/conf.d/ssl/jenkins.kkrepo.com_bundle.crt;
ssl_certificate_key /etc/nginx/conf.d/ssl/jenkins.kkrepo.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.2;
ssl_prefer_server_ciphers on;
location / {
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_redirect http:// https://;
proxy_pass http://jenkins;
# Required for new HTTP-based CLI
proxy_http_version 1.1;
proxy_request_buffering off;
proxy_buffering off; # Required for HTTP-based CLI to work over SSL
# workaround for https://issues.jenkins-ci.org/browse/JENKINS-45651
# add_header 'X-SSH-Endpoint' 'jenkins.domain.tld:50022' always;
}
access_log logs/jenkins.log main;
}
nginx
配置生效nginx -s reload
docker
及 docker-compose
docker
官网安装指导:https://docs.docker.com/engine/install/centos/
docker-compose
epel
源yum install -y epel-release
docker-compose
yum install -y docker-compose
Maven
官网复制安装包链接
官网:https://maven.apache.org/download.cgi
安装包链接:apache-maven-3.6.3-bin.tar.gz
将安装包解压,放到 /usr/local
目录下
tar -xvf apache-maven-3.6.3-bin.tar.gz -C /usr/local/
vi /etc/profile
export JAVA_HOME=/usr/local/jdk1.8.0_221 export MVN_HOME=/usr/local/apache-maven-3.6.3 export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib export PATH=$JAVA_HOME/bin:$MAVEN_HOME/bin:$JAVA_HOME/jre/bin:$PATH:$HOME/bin:$MVN_HOME/bin
source /etc/profile
mvn -v
如果服务器速度慢的话,可以配置阿里云的
maven
仓库地址。
github
配置SSH
配置在服务器上生成 ssh
,并将 pub key
配置到 github
(Settings -> SSH and GPG keys)上。
Webhooks
配置access tokens
配置[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-psUZP1Mq-1616478928918)(https://cdn.kkrepo.com/uPic/2020-10-11/image-20200711115455633-d1ElXQ.png)]
Jenkins
配置及持续集成[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-wEEyJpN2-1616478928926)(https://cdn.kkrepo.com/uPic/2020-10-11/image-20200711115029870-qGt0ct.png)]
Blog
项目配置freestyle project
General
配置[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-o5dCzunV-1616478928933)(https://cdn.kkrepo.com/uPic/2020-10-11/image-20200711120248468-gxCWfo.png)]
无
mvn
命令未找到+ cd /root/.jenkins/workspace/Blog + mvn clean package /tmp/jenkins3465102471897029074.sh:行5: mvn: 未找到命令 Build step 'Execute shell' marked build as failure Finished: FAILURE
在 jenkins
的 构建
过程中,需要使用 maven
给项目打包,但是打包的时候,报找不到 mvn
命令异常。
由于 Java
和 maven
的环境变量都是放在 /etc/profile
中的,而 /etc/profile
只有在用户登录的时候才会被 load, jenkins
在运行命令时,使用的是 no-login
的方式,这种方式在运行命令的时候, /etc/profile
是不会被 load 进来的,jenkins
只能在当前路径下寻找可执行文件。
在 jenkins
的设置中,可以设置全局变量。
Manage Jenkins -> Configure System -> 全局属性 -> Environment variables
jenkins
拉取代码速度慢jenkins
每次拉取代码都需要十几分钟,但是我在服务器上自己 clone
代码的时候却很快(基本可以排除网络问题)。
job
中做如下配置清除该勾选项,或者 在删除策略里面 忽略掉
.git
目录。