CentOS 6.5 配置GitLab

環境:CentOS 6.5 x64 minhtml

GitLab是一個利用 Ruby on Rails 開發的開源應用程序,實現一個自託管的Git項目倉庫,可經過Web界面進行訪問公開的或者私人項目。
https://github.com/gitlabhq/gitlabhq      
https://www.gitlab.com/python

#配置安裝EPEL及依賴環境

#更新包    
yum update      
yum -y install wget      
#添加epel源      
http://www.cnblogs.com/Irving/p/3729074.html    
#安裝所需依賴包    
yum -y install readline readline-devel ncurses-devel gdbm-devel glibc-devel tcl-devel expat-devel db4-devel byacc sqlite-devel libyaml libyaml-devel libffi libffi-devel libxml2 libxml2-devel libxslt libxslt-devel libicu libicu-devel system-config-firewall-tui python-devel redis wget crontabs logwatch logrotate perl-Time-HiRes git gettext-devel libel openssl-devel zlib-devel gcc gcc-c++ make autoconf readline-devel expat-devel gettext-devel tk-devel  libxml2-devel libffi-devel libxslt-devel libicu-devel python-pip sqlite-devel  patch libyaml* pcre-devel      
#安裝bundle(須要添加rubygems的國內鏡像)      
gem sources --remove
https://rubygems.org/    
gem source -a http://ruby.taobao.org/    
gem sources -l    
gem install bundler --no-ri --no-rdoc      
ln -s /usr/local/bin/gem /usr/bin/gem      
ln -s /usr/local/bin/bundle /usr/bin/bundle
mysql

#安裝Ruby

wget http://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.2.tar.gz    
tar zfvx ruby-2.1.2.tar.gz    
./configure --prefix=/usr/local/      
make && make install      
ln -s /usr/local/bin/ruby /usr/bin/ruby      
ruby -v
nginx

#安裝Git

http://www.cnblogs.com/Irving/p/3729064.html    
#建立一個Git用戶供GitLab使用    
adduser --comment 'GitLab' git      
passwd git      
#爲了方便添加git用戶擁有root權限      
vi /etc/sudoers      
git  ALL=(ALL)    ALL      
#強制保存      
:wq!      
#設置權限(重要)      
sudo chmod o+x /home/git      
vi /home/git/.bash_profile      
export GIT_SSL_NO_VERIFY=1      
source /home/git/.bash_profile      
#不添加變量的話使用https連接會報以下錯誤      
fatal: unable to access '
https://github.com/gitlabhq/grit.git/': Peer certificate cannot be authenticated with known CA certificatesc++

#安裝GitLab的Shell

su - git    
git clone
https://gitlab.com/gitlab-org/gitlab-shell.git -b v1.9.3    
cd gitlab-shell/      
cp config.yml.example config.yml      
vi config.yml      
#配置gitlab域名      
gitlab_url: "
http://git.test.com/"    
#果gitlab是使用https訪問    
self_signed_cert:true      
#安裝      
./bin/install      
CREATE USER 'gitlab'@'localhost' IDENTIFIED BY '123456';
git

#安裝MYSQL

su -    
yum install -y mysql-server mysql-devel      
chkconfig mysqld on      
service mysqld start      
#設置mysql root帳號的密碼      
/usr/bin/mysql_secure_installation
github

建立gitlab使用的數據庫    
mysql -u root -p      
#建立用戶      
CREATE USER 'gitlab'@'localhost' IDENTIFIED BY 'gitlab登錄密碼';      
#建立數據庫      
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';      
quit      
web

#安裝GitLab

su - git    
git clone
https://gitlab.com/gitlab-org/gitlab-ce.git -b 6-8-stable gitlab    
cd gitlab      
#複製配置文件      
cp config/gitlab.yml.example config/gitlab.yml      
#修改訪問域名      
vi config/gitlab.yml      
## Web server settings      
  host: git.test.com      
  port: 80      
  https: true      
#配置權限      
chown -R git log/      
chown -R git tmp/      
chmod -R u+rwX  log/      
chmod -R u+rwX  tmp/      
mkdir tmp/pids/      
mkdir tmp/sockets/      
chmod -R u+rwX  tmp/pids/      
chmod -R u+rwX  tmp/sockets/      
mkdir public/uploads      
chmod -R u+rwX  public/uploads      
cp config/unicorn.rb.example config/unicorn.rb      
cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb      
#配置git的用戶和郵件      
git config --global user.name "GitLab"      
git config --global user.email "gitlab@localhost"      
git config --global core.autocrlf input
redis

#配置gitlab數據庫    
cp config/database.yml.mysql config/database.yml      
vi config/database.yml      
production:      
  adapter: mysql2      
  encoding: utf8      
  reconnect: false      
  database: gitlabhq_production      
  pool: 5      
  username: gitlab      
  password: "gitlab"      
  # host: localhost      
  # socket: /tmp/mysql.sock      
sql

#安裝gems

su -    
$ gem install charlock_holmes --version '0.6.9.4'      
vi Gemfile      
source "
https://rubygems.org"改成source "http://rubygems.org"或改爲    
#安裝    
bundle install --deployment --without development test postgres puma aws

#啓動redis服務

sudo /etc/init.d/redis start    
sudo chkconfig redis on      
#初始化數據庫      
bundle exec rake gitlab:setup RAILS_ENV=production      
#默認帳號和密碼      
Administrator account created:      
login.........admin@local.host      
password......5iveL!fe

#安裝啓動腳本

sudo wget https://raw.github.com/gitlabhq/gitlab-recipes/master/init/sysvinit/centos/gitlab-unicorn -P /etc/init.d/    
sudo mv /etc/init.d/gitlab-unicorn /etc/init.d/gitlab      
sudo chmod +x /etc/init.d/gitlab      
sudo chkconfig --add gitlab      
sudo chkconfig gitlab on      
sudo /etc/init.d/gitlab start

#拉取GitLab靜態文件

cd /home/git/gitlab    
bundle exec rake assets:precompile RAILS_ENV=production

#檢查應用程序情況    
bundle exec rake gitlab:env:info RAILS_ENV=production

#安裝Nginx

#安裝
su -
yum -y install nginx
chkconfig nginx on

#拷貝gitlab配置    
cp /home/git/gitlab/lib/support/nginx/gitlab /etc/nginx/conf.d/      
#備份默認配置      
mv /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf.back      
#重蓋默認配置(或者刪除default.conf 默認配置,只用gitlab)      
mv /etc/nginx/conf.d/gitlab /etc/nginx/conf.d/default.conf

#啓動服務

#service gitlab start (restart)    
#service nginx start  (restart)      
#關閉防火牆 (重啓後永久性生效)      
service iptables stop      
chkconfig iptables off      
#訪問服務      
http://192.168.0.107/

image


基本查看網上的文章安裝,還算比較順利,我這邊遇到以下問題:      
1.ruby 最新源碼編譯好久不能經過,換到低一個版本        
2.502錯誤,由於Nginx默認配置了502錯誤,查看Nginx日誌 /var/log/nginx/gitlab_error.log        
"/home/git/gitlab/public/favicon.ico.html" failed (13: Permission denied), client: 33.33.33.1, server: gitlab.web.lo, request: "GET /favicon.ico HTTP/1.1"        
開始覺得是Socet服務有問題,後發現是權限問題。        
解決方法:chmod o+x /home/git

Refer:      
用Gitlab來工做        
http://feiyang.me/2013/03/work-with-gitlab/      
Puma 替換 Unicorn 跑 Gitlab      
http://icyleaf.com/2014/01/moving-unicorn-to-puma-on-gitlab/      
GitLab 啓用HTTPS        
http://blog.csdn.net/csfreebird/article/details/8579488      
Ubuntu      
http://my.oschina.net/guol/blog/165409      
http://rfyiamcool.blog.51cto.com/1030776/1365521/      
Redhat      
http://my.oschina.net/xiaokaceng/blog/187573      
CentOS      
http://my.oschina.net/wzlee/blog/262181      
http://hypocritical.blog.51cto.com/3388028/1405574

相關文章
相關標籤/搜索