K-BOlG K-BOlG
Home
  • 前端
  • Http
  • Ajax
  • Node
  • MongoDB
  • Axios
  • Git
  • Webpack
  • React
  • Vue
  • Uni-app
  • 性能优化
  • 移动端
  • 技术
  • Vue3入门
  • TypeScript入门
  • Jenkins-Nginx
  • UI
  • 文本超出隐藏解决
  • 收藏
  • 实用网站
  • 资源库
  • Vue专区
  • 你知道的越多,不知道的也就越多
  • 拥抱生活,拥抱快乐
关于
  • 分类
  • 标签
  • 归档
GitHub (opens new window)

nengkai

大道至简-知易行难
Home
  • 前端
  • Http
  • Ajax
  • Node
  • MongoDB
  • Axios
  • Git
  • Webpack
  • React
  • Vue
  • Uni-app
  • 性能优化
  • 移动端
  • 技术
  • Vue3入门
  • TypeScript入门
  • Jenkins-Nginx
  • UI
  • 文本超出隐藏解决
  • 收藏
  • 实用网站
  • 资源库
  • Vue专区
  • 你知道的越多,不知道的也就越多
  • 拥抱生活,拥抱快乐
关于
  • 分类
  • 标签
  • 归档
GitHub (opens new window)
  • 目录页

  • 前端

  • 技术

    • vue3入门
    • TypeScript入门
    • 在浏览器输入url后都发生了什么
    • 如何保证setTimeout准确性
    • Jenkins+nginx
      • 1-安装JAVA环境
      • 2-安装Jenkins
      • 3-安装nginx
      • 4-配置 nginx
    • 浏览器缓存机制
    • requestAnimationFrame实践
    • git突然连不上github解决方案
    • 让vue3更好用的vite插件
    • Vue3有哪些新特性
    • EvenLoop有哪些
    • win10下关闭进程
    • JS设计模式
    • 谷歌调试快捷键
    • 前端常用设计模式
  • UI

  • 收藏

  • 随笔

  • 关于

  • views
  • 技术
nengkai
2022-05-17
目录

Jenkins+nginx

# 前端自动化部署之 Linux 下部署 Jenkins 及 nginx

# 1 - 安装 JAVA 环境

Ubuntu:
sudo apt-get install openjdk-8-jdk
查看安装是否成功
java -version 有版本信息则为成功否则失败
Centos:
dnf search java-1.8
dnf install java-1.8.0-openjdk.x86_64

1
2
3
4
5
6
7
8

# 2 - 安装 Jenkins

Ubuntu:
sudo apt-get install jenkins
如果没有就更新安装包在进行安装
wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -
sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
sudo apt-get update
sudo apt-get install jenkins
以上是四条命令,确保每条都执行成功了
Centos:
wget –O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat-stable/jenkins.repo

# 导入GPG密钥以确保您的软件合法
rpm --import https://pkg.jenkins.io/redhat/jenkins.io.key
# 或者
rpm --import http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key
编辑一下文件/etc/yum.repos.d/jenkins.repo

- 可以通过vim编辑
[jenkins]

name=Jenkins-stable

baseurl=http://pkg.jenkins.io/redhat

gpgcheck=1
安装Jenkins
dnf install jenkins # --nogpgcheck(可以不加)
启动Jenkins的服务:
systemctl start jenkins
systemctl status jenkins
systemctl enable jenkins

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

### 注意:Jenkins 默认使用 8080 端口提供服务:防火墙打开 8080

手动部署 Jenkins
1-创建部署目录
cd /home/openailab/
mkdir jenkins
2-下载Jenkins
cd jenkins
wget https://mirrors.tuna.tsinghua.edu.cn/jenkins/war/latest/jenkins.war
3-日志存放目录
mkdir logs
4-启动脚本设置
vim run_jenkins.sh
写入内容:
#!/bin/bash
export JENKINS_HOME=/home/openailab/jenkins
cd $JENKINS_HOME
nohup java -Dhudson.model.DownloadService.noSignatureCheck=true -Xmx2g -jar jenkins.war --httpPort=8080 > logs/jenkins.log 2>&1 &
tail -f logs/jenkins.log
5-创建配置文件
vim hudson.model.UpdateCenter.xml
写入内容:
<?xml version='1.1' encoding='UTF-8'?>
<sites>
  <site>
    <id>default</id>
    <url>https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json</url>
  </site>
</sites>
注意:
1-URl内为镜像源,插件系统连不上可以更换源试试,具体百度
2-换源前结束进程 ps -aux | grep jenkins | grep -v grep   ,  pkill -9 jenkins 或 kill -9 进程号
6-运行Jenkins
sudo chmod 777 run_jenkins.sh
sh run_jenkins.sh

完成上述六步恭喜你就可以开始访问了
直接输入你的主机名或域名后面加上后缀:8080
7- 解锁 Jenkins
cat /home/openailab/jenkins/secrets/initialAdminPassword
把这里面的东西粘上去就行
8- 按提示创建账户就行了
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

# 3 - 安装 nginx

ubuntu
安装 sudo apt-get install nginx 
  使用:启动 service nginx start
    查看状态 service nginx status
    重启 service nginx restart
Centos
安装 dnf install nginx
  使用:启动 systemctl start nginx
   查看状态 systemctl status nginx
    重启 systemctl enable nginx

1
2
3
4
5
6
7
8
9
10
11

# 4 - 配置 nginx

cd /etc/nginx/nginx.config
user 哪项改成 urer root;

1
2
3
通过Linux命令创建文件夹和文件:
mkdir /root/mall_cms
cd /root/mall_cms
touch index.html

vi index.html
配置访问目录:
service {
    location / {
    # First attempt to serve request as file, then
    # as directory, then fall back to displaying a 404.
    root /root/mall_cms/dist;
    index index.html;
    try_files $uri $uri/ /index.html;  # 错误重定向
  }

}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
编辑 (opens new window)
#Jenkins#Nginx
上次更新: 5/25/2022, 6:17:07 AM
如何保证setTimeout准确性
浏览器缓存机制

← 如何保证setTimeout准确性 浏览器缓存机制→

最近更新
01
前端常用设计模式
04-01
02
谷歌调试快捷键
06-23
03
JS设计模式
06-02
更多文章>
Theme by Vdoing | Copyright © 2022-2023
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式