# gitlab **Repository Path**: KangXian/gitlab ## Basic Information - **Project Name**: gitlab - **Description**: 在Debian下搭建gitlab服务器 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2017-11-23 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## 在Debian下gitlab服务器的搭建 * 打开终端,依次运行下列命令 ```bash sudo apt-get update sudo apt-get install -y curl openssh-server ca-certificates curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash sudo EXTERNAL_URL="http://gitlab.example.com" apt-get install gitlab-ce ``` ![](images/gitlab/01.png) ![](images/gitlab/02.png) * 安装完成 * 配置环境,执行以下命令即可: ```bash sudo gitlab-ctl reconfigure ``` * 这时我们可以打开浏览器登陆,在浏览器中输入本机的IP地址即可,登陆后会看到Apache的欢迎界面 ![](images/gitlab/03.png) * 我们可以关闭Apache服务,以便显示我们想要的页面,用root用户执行以下命令 ```bash service apache2 stop ``` ![](images/gitlab/04.png) * 当再次打开时就进入以下界面,在这里修改服务器密码 ![](images/gitlab/05.png) * 接下来注册一个账号 ![](images/gitlab/06.png) * 登陆后我们就可以在服务器上创建组,创建工程了 ![](images/gitlab/07.png) * 我们创建一个工程 ![](images/gitlab/08.png) * 工程创建完成 ![](images/gitlab/09.png) * 配置SSH公钥 * 我们先创建一个目录,用来存放公钥,再执行以下命令创建公钥 ```bash ssh-keygen -t rsa -C "547048715@qq.com" -b 4096 ``` * 查看公钥 ```bash cat ~/.ssh/id_rsa.pub ``` ![](images/gitlab/10.png) * 进入页面,点击头像,在下拉菜单中选择Settings ![](images/gitlab/11.png) * 进入设置页面 ![](images/gitlab/12.png) * 点击 SSH 密钥,将生成的密钥复制到文本框 ![](images/gitlab/13.png) * 点击 Add key,密钥配置完成 ![](images/gitlab/14.png) ## push到服务器仓库 * 打开终端,进入到要push的目录中,依次执行以下命令,可将本地文件push到服务器仓库中 ``` git config --global user.name "krgg" ``` ``` git config --global user.email "547048715@qq.com" ``` ``` git init ``` ``` git remote add origin git@192.168.31.125:krgg/LinuxBook.git ``` ``` git add . ``` ``` git commit -m "hello world" ``` ``` git push -u origin master ``` ![](images/gitlab/15.png)