【每日阅读】2020年10月8日-树莓派的gitlab开启gitlab pages,实现个人wiki

步骤说明

  1. 安装gitlab-runner
  2. 注册gitlab-runner
  3. 开启gitlab pages
  4. 创建项目,也就是包含供外部访问页面的项目
  5. 走一遍流水线,打包生成供gitlab pages使用的页面内容

安装gitlab-runner

目的:gitlab-runner是为了跑自动化的进程,要存在gitlab-runner,后续自动化才能跑起来。跑自动化是为了生成供gitlab pages展示的页面内容。

https://docs.gitlab.com/runner/install/linux-manually.html#install-1

# Linux arm
sudo curl -L --output /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-arm
sudo chmod +x /usr/local/bin/gitlab-runner
# gitlab跑自动化默认全部使用gitlab-runner
sudo useradd --comment 'GitLab Runner' --create-home gitlab-runner --shell /bin/bash
sudo gitlab-runner install --user=gitlab-runner --working-directory=/home/gitlab-runner
sudo gitlab-runner start

注册gitlab-runner

目的:每个项目需要注册上gitlab-runner才能使用gitlab-runner,也可以使用共享的gitlab-runner,下图就是创建了一个共享的gitlab-runner,所有项目跑自动化都可以使用它。

【每日阅读】2020年10月8日-树莓派的gitlab开启gitlab pages,实现个人wiki

https://docs.gitlab.com/runner/register/index.html#linux

# 有好几个步骤
# 第一步写域名就写为了gitlab pages专门准备的域名(搞域名是最简单的,不要为了不使用域名把问题搞复杂了)
# 最后一步选executor就写上shell就行了
gitlab-runner register --tls-ca-file=gitlab.geekgao.cn_public.crt
​
# 后续gitlab跑自动化时,会使用gitlab-runner用户访问这两个目录,所以要开写权限
chmod a+w /usr/local/bin/ /usr/local/bin/

后续跑自动化可能会报错:“prepare environment: exit status 1” 参考:https://gitlab.com/gitlab-org/gitlab-runner/-/issues/26605 问题解决方法:所以这里提前先注释掉/home/gitlab-runner/.bash_logout的内容

【每日阅读】2020年10月8日-树莓派的gitlab开启gitlab pages,实现个人wiki

开启gitlab pages

参考:

https://docs.gitlab.com/ee/administration/pages/index.html#configuration

https://www.youtube.com/watch?v=dD8c7WNcc6s

# 开启https,不开启https可以写成http
pages_external_url "https://yourwebsite.com"
# 开启https需要的密钥和证书,不开启https不需要配置
pages_nginx['ssl_certificate'] = "yourwebsite.com.pem"
pages_nginx['ssl_certificate_key'] = "yourwebsite.com.key"

创建项目

下面这些项目都内置了产出供gitlab pages使用内容的流水线,直接创建出来然后点击运行流水线即可

【每日阅读】2020年10月8日-树莓派的gitlab开启gitlab pages,实现个人wiki
【每日阅读】2020年10月8日-树莓派的gitlab开启gitlab pages,实现个人wiki

访问效果如下

【每日阅读】2020年10月8日-树莓派的gitlab开启gitlab pages,实现个人wiki

访问控制

为了实现如下的权限控制,需要开启权限的配置

gitlab_pages['access_control'] = true

然后gitlab-ctl reconfigure即可。(但是我这里发现开启权限控制后,开通权限时,会包503,未解决。我就改成了所有人可访问)

后补充:上面说的503问题,貌似是在已经有了这个项目pages访问权限后再去开会有503问题。所以总归来说是OK的,能拦住那些没有权限的人。

原创文章,作者:geekgao,如若转载,请注明出处:https://www.geekgao.cn/archives/2576

(0)
geekgaogeekgao博主
上一篇 2020年10月8日 上午3:51
下一篇 2020年10月9日 下午9:48

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

GitHub
分享本页
返回顶部

Warning: error_log(/usr/local/lighthouse/softwares/wordpress/wp-content/plugins/spider-analyser/#log/log-2717.txt): failed to open stream: No such file or directory in /usr/local/lighthouse/softwares/wordpress/wp-content/plugins/spider-analyser/spider.class.php on line 2900