centos 7 安裝gitlab

來源:互聯網
上載者:User

標籤:style   blog   http   io   ar   os   使用   sp   檔案   

#配置安裝EPEL及依賴環境

#更新包     
yum update      
yum -y install wget      

yum -y --nogpgcheck install http://download.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-2.noarch.rpm
#添加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      

 

#安裝Ruby(需要添加rubygems的國內鏡像)      

Gem是一個管理Ruby庫和程式的標準包,它通過Ruby Gem(如 http://rubygems.org/ )源來尋找、安裝、升級和卸載軟體包,非常的便捷。

yum -y install rubygems  ruby

 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

ruby -v

#安裝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 certificates

#安裝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‘;

#安裝MYSQL

su -     
yum install mariadb mariadb-devel    
chkconfig mysqld on      
service mysqld start      
#設定mysql root帳號的密碼      
/usr/bin/mysql_secure_installation

建立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      

#安裝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 "[email protected]"      
git config --global core.autocrlf input

#配置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      

#安裝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:      
[email protected]      
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/


基本查看網上的文章安裝,還算比較順利,我這邊遇到如下問題:       
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

 

centos 7 安裝gitlab

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.