首先去jenkins官网下载最新LTS war版本https://www.jenkins.io/download/
准备sdk包 、nginx配置文件 、已配置的maven文件
查看系统架构
cat /etc/redhat-release
uname -a
uname -m
lscpu
安装常用工具
yum install jq -y
yum install git -y
yum install nginx -y
systemctl enable nginx
systemctl start nginx
yum install fontconfig -y
yum install zip -y
配置环境变量
vim /etc/profile
export JAVA_HOME=/root/server/jdk-21.0.3
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
export MAVEN_HOME=/root/server/maven3.9.6
export PATH=$PATH:$MAVEN_HOME/bin
export NODE_HOME=/root/server/nodejs18.19.0
export PATH=$PATH:$NODE_HOME/bin
source /etc/profile
启动jenkins
java项目访问前缀必须加方便nginx配置
--prefix=/jenkins
nohup java -jar -Xms3g -Xmx3g jenkins-2.452.3.war --prefix=/jenkins > jenkins.log &
配置nginx
server {
listen 80;
listen [::]:80;
server_name _;
location /jenkins {
proxy_pass http://localhost:8080;
}
}
查看jenkins初始密码 并访问 http://服务器ip:80/jenkins
tail -f -n 1000 jenkins.log
访问jenkins登录之后会提示错误无法安装插件等 需要关闭csrf 跨域问题
访问http://服务器 ip:80/jenkins/manage/script 并输入一下命令执行
hudson.security.csrf.GlobalCrumbIssuerConfiguration.DISABLE_CSRF_PROTECTION = true