centos7中gitlab服务部署

本文详细介绍如何在Linux环境下安装GitLab,包括依赖软件的安装、GitLab版本的选择与安装,以及GitLab的端口配置、SMTP邮件设置等关键步骤,并指导如何创建项目并进行基本的Git操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、安装

yum install -y curl policycoreutils openssh-server openssh-clients

yum install -y postfix

systemctl enable sshd  &&  systemctl start sshd

systemctl enable postfix  &&  systemctl start postfix

firewall-cmd --permanent --add-service=http

systemctl reload firewalld

https://packages.gitlab.com/gitlab/gitlab-ce/中找到需要安装的版本,添加源

例如 gitlab-ce 版:

curl -s https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash

yum install -y gitlab-ce-11.1.0-ce.0.el7.x86_64

二、配置

修改默认的gitlab 相关端口

修改/etc/gitlab/gitlab.rb

vim /etc/gitlab/gitlab.rb

#unicorn['port'] = 80 修改 8080  默认是注释的去掉前面的#
unicorn['port'] = 8080
#nginx['listen_port'] = nil 修改 8088  默认是注释的去掉前面的#
nginx['listen_port'] = 8088

修改/var/opt/gitlab/gitlab-rails/etc/unicorn.rb

vim /var/opt/gitlab/gitlab-rails/etc/unicorn.rb

#listen "127.0.0.1:80", :tcp_nopush => true
listen "127.0.0.1:8080", :tcp_nopush => true

修改默认的gitlab nginx的web服务80端 /var/opt/gitlab/nginx/conf/gitlab-http.conf

vim /var/opt/gitlab/nginx/conf/gitlab-http.conf

#listen *:80;
listen *:8088;

配置smtp邮件发送

$ sudo vi /etc/gitlab/gitlab.rb                            
# Change the external_url to the address your users will type in their browser
external_url 'http://xxhost.com'

#Sending application email via SMTP
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.163.com"
gitlab_rails['smtp_port'] = 25 
gitlab_rails['smtp_user_name'] = "user@163.com"
gitlab_rails['smtp_password'] = "mypwd"
gitlab_rails['smtp_domain'] = "163.com"
gitlab_rails['smtp_authentication'] = :login
gitlab_rails['smtp_enable_starttls_auto'] = true

##修改gitlab配置的发信人
gitlab_rails['gitlab_email_from'] = "user@163.com"
user["git_user_email"] = "user@163.com"

重新配置gitlab

gitlab-ctl reconfigure

重新启动gitlab

gitlab-ctl restart

三、使用 

1.使用gitlab用户登陆后,使用 new project 创建新项目

2.在本地创建项目路径(项目文件夹)后,在此路径下执行 git bush here(windows:在此文件夹中,右键菜单,git bush here )

3.在弹出的git bash中,初始化本地git仓库

git init

4.添加远程仓库源(前面在gitlab中创建的项目git地址)

git remote add origin http://10.0.0.11:8088/user1/demo.git

 5.推送变更至远程仓库对应的分支

git push -u origin master

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值