*先决条件系统已安装Docker
1、查询GitLab镜像
docker search gitlab
2、现在GitLab镜像
3、创建文件夹
mkdir -p /software/gitlab/config
mkdir -p /software/gitlab/logs
mkdir -p /software/gitlab/data
4、启动
docker run -d -p 9443:443 -p 9080:80 -p 9022:22
--name gitlab --restart always
--volume /software/gitlab/config:/etc/gitlab
--volume /software/gitlab/logs:/var/log/gitlab
--volume /software/gitlab/data:/var/opt/gitlab
gitlab/gitlab-ce:lates
5、修改配置文件
vi gitlab/config/gitlab.rb
external_url 'http://gitlab.xxx.co'
gitlab_rails['gitlab_ssh_host'] = 'gitlab.xxx.co'
gitlab_rails['gitlab_shell_ssh_port'] = 9022
6、配置nginx
upstream gitlab {
server xxx.xxx.xxx.xxx:9080;
}
server {
listen 80;
server_name gitlab.xxx.co;
location / {
client_max_body_size 10m;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://gitlab;
}
}
7、进入gitlab
首次进入要修改默认管理员密码 (管理员root)
优化
如果是docker
进入容器
docker exec -it gitlab /bin/bash
然后
修改配置文件/etc/gitlab/gitlab.rb中的worker_processes:
去掉下面的注释
unicorn[‘worker_processes’] = 2 #官方推荐 CPU核心+1
还有其它优化项可改可不改
docker exec -it gitlab gitlab-ctl reconfigure
docker exec -it gitlab gitlab-ctl restart
如果不是docker直接修改后,再即可
gitlab-ctl reconfigure
gitlab-ctl restart
完