WeAir

GitLab配置GitLab Pages

前期准备

准备好单独的域名并设置泛域名解析,以及安装zipunzip,配置HTTPS需提供域名的通配符证书。

安装GitLab Pages

1
2
3
4
5
cd /home/git
sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-pages.git
cd gitlab-pages
sudo -u git -H git checkout v$(</home/git/gitlab/GITLAB_PAGES_VERSION)
sudo -u git -H make

启用GitLab Pages

1
echo "gitlab_pages_enabled=true" >> /etc/default/gitlab

生成API密钥

1
sudo -u git -H openssl rand -base64 32 > /home/git/gitlab/gitlab-pages-secret

编辑配置文件

进入/home/git/gitlab/conf目录并编辑gitlab.yml文件。

HTTP配置如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
## GitLab Pages
pages:
enabled: true
access_control: false
# The location where pages are stored (default: shared/pages).
# path: shared/pages

host: pages.domain.name
port: 80 # Set to 443 if you serve the pages with HTTPS
https: false # Set to true if you serve the pages with HTTPS
artifacts_server: false # Set to false if you want to disable online view of HTML artifacts
external_http: ["127.0.0.1:8090"]
secret_file: /home/git/gitlab/gitlab-pages-secret

HTTPS配置如下:

1
2
3
4
5
6
7
8
9
10
11
12
## GitLab Pages
pages:
enabled: true
access_control: false
# The location where pages are stored (default: shared/pages).
# path: shared/pages

host: pages.domain.name
port: 443 # Set to 443 if you serve the pages with HTTPS
https: true # Set to true if you serve the pages with HTTPS
artifacts_server: true # Set to false if you want to disable online view of HTML artifacts
secret_file: /home/git/gitlab/gitlab-pages-secret

进入/home/git/gitlab/gitlab-pages目录并编辑gitlab-pages.conf文件。

HTTP配置如下:

1
2
3
4
5
listen-http=:8090
pages-root=/home/git/gitlab/shared/pages
api-secret-key=/home/git/gitlab/gitlab-pages-secret
pages-domain=pages.domain.name
internal-gitlab-server=https://gitlab.domain.name

HTTPS配置如下:

1
2
3
4
5
listen-proxy=:8090
pages-root=/home/git/gitlab/shared/pages
api-secret-key=/home/git/gitlab/gitlab-pages-secret
pages-domain=pages.domain.name
internal-gitlab-server=https://gitlab.domain.name

配置NGINX

复制/home/git/gitlab/lib/support/nginx目录下的相应的配置文件到NGINX的配置文件目录中并编辑,重启NGINX。

重启GitLab

1
2
3
sudo service gitlab restart
#或
sudo /etc/init.d/gitlab restart