gitlab安装(基于centos6.5)

gitlab安装(基于centos6.5)


安装wget和cmake

sudo yum -y install wget

sudo yum -y install cmake


增加EPEL安装源

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


安装epel-release-6-8.noarch包

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


增加PUIAS安装源

vi /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


下载并安装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


yum repolist


安装GitLab的所需依赖包和工具

yum -y groupinstall 'Development Tools'


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


配置redis

chkconfig redis on

service redis start


安装Ruby


mkdir /tmp/ruby && cd /tmp/ruby

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


查看ruby版本

ruby -v


安装bundle


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


创建用户git

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


切换到git

su - git


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


cd gitlab-shell


git checkout v1.8.0


cp config.yml.example config.yml


vi config/config.yml


将gitlab_url修改成gitlab的访问域名。形如:http://test.gitlab.com/


./bin/install


安装数据库


切换到root用户

su -

yum install -y mysql-server mysql-devel

chkconfig mysqld on

service mysqld start


/usr/bin/mysql_secure_installation

重新设定数据库密码并清除空用户跟test数据库


mysql -u root -p


创建git用户

CREATE USER 'git'@'localhost' IDENTIFIED BY '123456';


创建数据库

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


设定git权限

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


切换到git用户


su - git


克隆分支:

git clone https://gitlab.com/larryli/gitlab.git .gitlab

cd gitlab

git checkout 7-7-zh


配置项目


cp config/gitlab.yml.example config/gitlab.yml


vi config/gitlab.yml


把localhost修改成你需要的域名


chown -R git log/

chown -R git tmp/

chmod -R u+rwX log/

chmod -R u+rwX tmp/

mkdir /home/git/gitlab-satellites

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

git config --global user.name "GitLab"

git config --global user.email "[email protected]"

git config --global core.autocrlf input


配置数据库访问文件

cp config/database.yml.mysql config/database.yml


vi config/database.yml


修改数据库连接密码(把password里面的密码修改成我们刚才设置的密码123456)


chmod o-rwx config/database.yml




安装Gems


切换到git用户


修改源

vi Gemfile


#source "https://rubygems.org"

source "https://ruby.taobao.org"


bundle install --deployment --without development test postgres puma aws



完成后会生成默认管理员账户密码


root

5iveL!fe


安装启动脚本


切换到root用户


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


service gitlab start


切换到git用户


su - git


cd gitlab/


bundle exec rake gitlab:check RAILS_ENV=production


bundle exec rake assets:precompile RAILS_ENV=production


切换到root用户

service gitlab restart


安装web服务器


yum -y install nginx

chkconfig nginx on

mkdir /etc/nginx/sites-available

mkdir /etc/nginx/sites-enabled


cp /home/git/gitlab/lib/support/nginx/gitlab /etc/nginx/sites-available


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


编辑/etc/nginx/nginx.conf,将 include /etc/nginx/conf.d/*.conf; 替换成 include /etc/nginx/sites-enabled/*;


编辑/etc/nginx/sites-available/gitlab,将配置中server_name替换成实际访问的域名。


将nginx加入git用户组


usermod -a -G git nginx

chmod g+rx /home/git/


service nginx start


配置防火墙

lokkit -s http -s https -s ssh


service iptables restart


访问:

http://localhost

你可能感兴趣的:(gitlab安装)