CentOS系統(tǒng)怎樣安裝GitLab客戶端
CentOS系統(tǒng)怎樣安裝GitLab客戶端
CentOS系統(tǒng)怎樣安裝GitLab客戶端?其實在CentOS安裝GitLab的方法非常的簡單,要安裝Ruby環(huán)境作為依賴,今天學(xué)習(xí)啦小編與大家分享下CentOS系統(tǒng)安裝GitLab客戶端的具體操作步驟,有需要的朋友不妨了解下。
CentOS系統(tǒng)安裝GitLab客戶端方法
一、安裝環(huán)境
基礎(chǔ)操作系統(tǒng)(CentOS 6.5 Minimal)
Ruby (版本: 2.0.0p353+)
創(chuàng)建項目運行用戶(創(chuàng)建git賬號,方便權(quán)限管理)
GitLab Shell(版本:1.8.1)
數(shù)據(jù)庫,采用PostgreSQL(可以支持mysql和PostgreSQL)
GitLab(版本:6-3-stable)
Web服務(wù)器,采用nginx(可支持nginx和apache)
防火墻,開放相關(guān)端口(iptables)
二、升級更新系統(tǒng)
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 http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
3、創(chuàng)建PUIAS安裝源
vim /etc/yum.repos.d/PUIAS_6_computational.repo
======================
[PUIAS_6_computational]
name=PUIAS computational Base $releasever - $basearch
mirrorlist=http://puias.math.ias.edu/data/puias/computational/$releasever/$basearch/mirrorlist
#baseurl=http://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 http://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
五、安裝所需服務(wù)
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
六、創(chuàng)建git用戶
注:git@#命令行表示是用git用戶登錄執(zhí)行命令,其他所有均以root用戶執(zhí)行
adduser --system --shell /bin/bash --comment 'GitLab' --create-home --home-dir /home/git/ git
七、配置GitLab Shell
注:GitLab shell是專門為GitLab開發(fā)的提供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: "http://yourdomain:8080/"
注:如果gitlab是使用https訪問,則需將http替換成https,配置文件中的self_signed_cert要修改成true,否則gitlab shell在通過api和gitlab進行通信的時候就會出現(xiàn)錯誤,導(dǎo)致項目push出錯。因為后面配置web服務(wù)器的時候是使用ssl,所以這里要按照ssl的方式配置。
3、安裝gitlab-shell
git@# ./bin/install
八、安裝PostgreSQL數(shù)據(jù)庫
1、yum安裝postgresql
yum install postgresql-server postgresql-devel -y
service postgresql initdb
service postgresql start
chkconfig postgresql on
2、創(chuàng)建數(shù)據(jù)庫和對應(yīng)用戶
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、創(chuàng)建相關(guān)目錄,及配置所有者權(quán)限
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、修改數(shù)據(jù)庫配置文件
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包)
十二、初始化數(shù)據(jù)和激活高級功能
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、檢查狀態(tài)
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服務(wù) (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、要看監(jiān)聽的端口是否啟動
nestat -nap | grep nginx
十五、開放相關(guān)端口和服務(wù)
lokkit -s http -s https -s ssh
service iptables restart
十六、系統(tǒng)相關(guān)配置
1、主機hosts配置
vim /etc/hosts
yourIP yourdomain
2、關(guān)閉selinux
setenforce 0
訪問gitlab首頁 http://yourdomain.com/
十七、郵箱配置
1、后期再配置,待續(xù).........
十八、GitLab windows客戶端
1、TortoiseGit
2、msysgit
問題處理:
1、檢測API-access失敗
解決方法:
查看三個配置文件
vim gitlab/config/unicorn.rb #配置ruby提供的服務(wù)端口,ip
listen "gitlab.test.com:8080", :tcp_nopush => true
vim gitlab-shell/config.yml #配置gitlab-shell要調(diào)用的API接口
gitlab_url: "http://gitlab.test.com:8080/"
vim gitlab/config/gitlab.yml #配置gitlab服務(wù)的端口,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
看過“CentOS系統(tǒng)怎樣安裝GitLab客戶端”的人還看了: