## 安装完成如下

## **修改 gitlab 的配置文件**
~~~
vi /etc/gitlab/gitlab.rb
~~~
### 修改里面的 external\_url 参数,例如我的宿主机的IP地址为 192.168.17.134
~~~
external_url='http://192.168.17.134'
~~~
### 因为修改了配置文件,所以重新加载配置文件
~~~
gitlab-ctl reconfigure
~~~
## **web页面配置**
~~~
gitlab默认端口是80,
~~~
### **先看看你的80端口是否开放**
~~~
firewall-cmd --zone=public --query-port=80/tcp
~~~
### **如果没开放就开放80端口**
~~~
firewall-cmd --zone=public --add-port=80/tcp --permanent
~~~
### **重启防火墙**
~~~
firewall-cmd --reload
~~~
### **web页面配置**
访问http://192.168.17.134:80 ,先设置管理员密码

然后登录,用户名root,密码是刚才设置的。
# 生成SSH Keys
## 生成root账号的ssh key
ssh-keygen -t rsa -C "admin@example.com" (这里填你自己的邮箱)

## 显示pub key的值
cat ~/.ssh/id_rsa.pub

### 复制显示出来的 pub key
以root账号登陆gitlab,点击 "profile settings" 然后点击 "SSH Keys"

**将复制的pub key粘贴进去,然后点击 Add key**

# 创建一个GitLab仓库
**点击 +New Project**

### 创建完了以后点开项目,可以先按照它提供的先初始化一下

## **使用clone命令克隆下来**
git clone git@192.168.17.134:first-group/majiang.git

*****
## **获取api访问令牌**
按图找到令牌,新建令牌,后面调用api的时候都要带上参数PRIVATE-TOKEN,做请求头

## **以我为例,创建组,成员,项目**
*****
:-: ***[附上官方api](https://docs.gitlab.com.cn/ee/api/README.html)***
*****
#### **查看的你的所有分组**
curl --header "PRIVATE-TOKEN: PTf8pP45WyzyAK\_chi7x" http://192.168.17.134:80/api/v4/groups
#### **查看的你的所有用户**
curl --header "PRIVATE-TOKEN: PTf8pP45WyzyAK\_chi7x" http://192.168.17.134:80/api/v4/users
#### **创建项目**
在我一个id为3的组下创建项目
curl --request POST --header "PRIVATE-TOKEN: PTf8pP45WyzyAK\_chi7x" --data "name=majiang&namespace\_id=3" http://192.168.17.134:80/api/v4/projects
### 创建组:
curl --request POST --header "PRIVATE-TOKEN:PTf8pP45WyzyAK\_chi7x" --data "name=helloGroup&path=helloGroup" [http://192.168.17.134:80/api/v4/groups/](http://192.168.17.134:80/api/v4/groups/)
### 创建用户:
curl --request POST --header "PRIVATE-TOKEN:PTf8pP45WyzyAK\_chi7x" --data "name=xiaohei&username=xiaohei&password=******&email=example@163.com" [http://192.168.17.134:80/api/v4/groups/](http://192.168.17.134:80/api/v4/users/)