CentOS系统怎样安装GitLab客户端

2016-12-21

CentOS系统怎样安装GitLab客户端?其实在CentOS安装GitLab的方法非常的简单,要安装Ruby环境作为依赖,今天小编与大家分享下CentOS系统安装GitLab客户端的具体操作步骤,有需要的朋友不妨了解下。

CentOS系统安装GitLab客户端方法

一、安装环境

基础操作系统(CentOS 6.5 Minimal)

Ruby (版本: 2.0.0p353+)

创建项目运行用户(创建git账号,方便权限管理)

GitLab Shell(版本:1.8.1)

数据库,采用PostgreSQL(可以支持mysql和PostgreSQL)

GitLab(版本:6-3-stable)

Web服务器,采用nginx(可支持nginx和apache)

防火墙,开放相关端口(iptables)

二、升级更新系统

yum groupinstall "Development Tools" -y

yum update -y

yum install wget vim -y

三、配置安装源

1、下载EPEL的GPG KEY

wget -O /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 https://www.fedoraproject.org/static/0608B895.txt

rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

rpm -qa gpg*

2、安装epel-release-6-8.noarch package

rpm -Uvh //dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

3、创建PUIAS安装源

vim /etc/yum.repos.d/PUIAS_6_computational.repo

======================

[PUIAS_6_computational]

name=PUIAS computational Base $releasever - $basearch

mirrorlist=//puias.math.ias.edu/data/puias/computational/$releasever/$basearch/mirrorlist

#baseurl=//puias.math.ias.edu/data/puias/computational/$releasever/$basearch

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-puias

=======================

4、下载PUIAS的GPG key

wget -O /etc/pki/rpm-gpg/RPM-GPG-KEY-puias //springdale.math.ias.edu/data/puias/6/x86_64/os/RPM-GPG-KEY-puias

rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-puias

5、检查是否安装成功

rpm -qa gpg*

yum repolist

四、安装GitLab所需依赖包

yum -y install vim-enhanced readline readline-devel ncurses-devel gdbm-devel glibc-devel tcl-devel openssl-devel curl-devel expat-devel db4-devel byacc sqlite-devel gcc-c++ libyaml libyaml-devel libffi libffi-devel libxml2 libxml2-devel libxslt libxslt-devel libicu libicu-devel system-config-firewall-tui python-devel redis sudo wget crontabs logwatch logrotate perl-Time-HiRes git

五、安装所需服务

1、Redis

chkconfig redis on

service redis start

2、Ruby(记得下载好了,tar一个备份,下载贼慢了)

curl --progress ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p353.tar.gz | tar xz

cd ruby-2.0.0-p353

./configure --prefix=/usr/local/

make && make install

3、检查Ruby是否安装成功,并配置$PATH

which ruby

/usr/local/bin/ruby

ruby -v

ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-linux]

4、Bundle

gem install bundler --no-ri --no-rdoc

六、创建git用户

注:git@#命令行表示是用git用户登录执行命令,其他所有均以root用户执行

adduser --system --shell /bin/bash --comment 'GitLab' --create-home --home-dir /home/git/ git

七、配置GitLab Shell

注:GitLab shell是专门为GitLab开发的提供ssh访问和版本管理的软件

1、下载gitlab-shell

su - git

git@# git clone https://github.com/gitlabhq/gitlab-shell.git

git@# cd gitlab-shell

git@# git checkout v1.9.4

2、修改配置文件

git@# cp config.yml.example config.yml

# Url to gitlab instance. Used for api calls. Should end with a slash.

gitlab_url: "//yourdomain:8080/"

注:如果gitlab是使用https访问,则需将http替换成https,配置文件中的self_signed_cert要修改成true,否则gitlab shell在通过api和gitlab进行通信的时候就会出现错误,导致项目push出错。因为后面配置web服务器的时候是使用ssl,所以这里要按照ssl的方式配置。

3、安装gitlab-shell

git@# ./bin/install

八、安装PostgreSQL数据库

1、yum安装postgresql

yum install postgresql-server postgresql-devel -y

service postgresql initdb

service postgresql start

chkconfig postgresql on

2、创建数据库和对应用户

su - postgres

psql -d template1

template1=# CREATE USER git WITH PASSWORD 'password';

template1=# CREATE DATABASE gitlabhq_production OWNER git;

template1=# q

exit

附:MYSQL安装方法

yum install -y mysql-server mysql-devel

chkconfig mysqld on

service mysqld start

/usr/bin/mysql_secure_installation

mysql -u root -p

CREATE USER 'gitlab'@'localhost' IDENTIFIED BY 'password';

CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;

GRANT SELECT, LOCK TABLES, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO 'gitlab'@'localhost';

九、安装GitLab

1、下载项目

su - git

git@# git clone https://github.com/gitlabhq/gitlabhq.git gitlab

git@# cd /home/git/gitlab

git@# git checkout 6-3-stable

2、配置项目

git@# cp config/gitlab.yml.example config/gitlab.yml

git@# sed -i 's|localhost|your_domain_name|g' config/gitlab.yml

3、创建相关目录,及配置所有者权限

git@# chown -R git log/

git@# chown -R git tmp/

git@# chmod -R u+rwX log/

git@# chmod -R u+rwX tmp/

git@# mkdir /home/git/gitlab-satellites

git@# mkdir tmp/pids/ tmp/sockets

git@# chmod -R u+rwX tmp/pids/

git@# chmod -R u+rwX tmp/sockets/

git@# mkdir public/uploads

git@# chmod -R u+rwX public/uploads

git@# cp config/unicorn.rb.example config/unicorn.rb

4、配置unicorn.rb

git@# vim config/unicorn.rb

listen "yourdomain:8080", :tcp_nopush => true

5、全局配置

git@# git config --global user.name "GitLab"

git@# git config --global user.email "gitlab@your_domain_name"

git@# git config --global core.autocrlf input

6、修改数据库配置文件

git@# cp config/database.yml.postgresql config/database.yml

git@# vim config/database.yml

git@# chmod o-rwx config/database.yml

十、安装gems

gem install charlock_holmes --version '0.6.9.4'

十一、安装postgresql包

git@# cd /home/git/gitlab/

git@# bundle install --deployment --without development test mysql

注:mysql包安装方法

git@# bundle install --deployment --without development test postgres puma aws ( mysql包)

十二、初始化数据和激活高级功能

git@# cd /home/git/gitlab

git@# bundle exec rake gitlab:setup RAILS_ENV=production

生成默认的管理账号

admin@local.host

5iveL!fe

十三、安装GitLab启动脚本

1、下载启动脚本

wget -O /etc/init.d/gitlab https://raw.github.com/gitlabhq/gitlab-recipes/master/init/sysvinit/centos/gitlab-unicorn

chmod +x /etc/init.d/gitlab

chkconfig --add gitlab

chkconfig gitlab on

2、检查状态

git@# cd gitlab/

git@# bundle exec rake gitlab:env:info RAILS_ENV=production

3、启动gitlab

service gitlab start

4、检查安装信息

git@# cd gitlab/

git@# bundle exec rake gitlab:check RAILS_ENV=production

十四、安装web服务 (nginx)

1、安装nginx

yum -y install nginx

chkconfig nginx on

mkdir /etc/nginx/sites-available

mkdir /etc/nginx/sites-enabled

wget -O /etc/nginx/sites-available/gitlab https://raw.github.com/gitlabhq/gitlab-recipes/master/web-server/nginx/gitlab-ssl

ln -sf /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab

2、修改配置文件

vim /etc/nginx/nginx.conf

include /etc/nginx/conf.d/*.conf;

改为

include /etc/nginx/sites-enabled/*;

vim /etc/nginx/sites-available/gitlab

server_name git.example.com;

改为

server_name youdomain.com;

3、将nginx加入git用户组

usermod -a -G git nginx

chmod g+rx /home/git/

4、添加ssl证书

mkdir /etc/nginx/ssl

cd /etc/nginx/ssl

openssl req -new -x509 -nodes -days 3560 -out gitlab.crt -keyout gitlab.key

5、启动nginx

service nginx start

6、要看监听的端口是否启动

nestat -nap | grep nginx

十五、开放相关端口和服务

lokkit -s http -s https -s ssh

service iptables restart

十六、系统相关配置

1、主机hosts配置

vim /etc/hosts

yourIP yourdomain

2、关闭selinux

setenforce 0

访问gitlab首页 //yourdomain.com/

十七、邮箱配置

1、后期再配置,待续.........

十八、GitLab windows客户端

1、TortoiseGit

2、msysgit

问题处理:

1、检测API-access失败

解决方法:

查看三个配置文件

vim gitlab/config/unicorn.rb #配置ruby提供的服务端口,ip

listen "gitlab.test.com:8080", :tcp_nopush => true

vim gitlab-shell/config.yml #配置gitlab-shell要调用的API接口

gitlab_url: "//gitlab.test.com:8080/"

vim gitlab/config/gitlab.yml #配置gitlab服务的端口,ip

host: gitlab.test.com

port: 80

2、启动nginx报错

service nginx start

Starting nginx: nginx: [emerg] unknown directive "ssl_stapling" in /etc/nginx/sites-enabled/gitlab:102

解决方法:

vim /etc/nginx/sites-available/gitlab

注释以下几行

3、登录打开首页显示不完全

解决方法:

vim /etc/nginx/sites-available/gitlab

注释下面几行

/etc/init.d/nginx restart #重启nginx

4、打开首页提示BAD GATEWAY

解决方法:

setenforce 0

更多相关阅读

最新发布的文章