需要安装内容
- Packages / Dependencies
- Ruby
- Go
- Node
- System Users
- Database mysql
- Redis
- GitLab
- Nginx
依赖的包
#依赖yum -y install gettext-devel readline readline-devel ncurses-devel gdbm-devel glibc-devel tcl-devel openssl-devel curl-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 redis sudo wget crontabs logwatch logrotate perl-Time-HiRes git cmake libcom_err-devel.i686 libcom_err-devel.x86_64 perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker
CentOS 7 源中的git的版本是1.8.3.1,更新
#需要此依赖包,否则报错yum install curl-develcd /tmpcurl --remote-name --progress https://www.kernel.org/pub/software/scm/git/git-2.12.0.tar.gz && tar -xzf git-2.12.0.tar.gzcd git-2.12.0./configuremake prefix=/usr/local all# Install into /usr/local/binmake prefix=/usr/local install# When editing config/gitlab.yml (Step 5), change the git -> bin_path to /usr/local/bin/git
#邮件服务器yum install -y postfix
Ruby
ruby最低版本2.1,yum安装的是2.0
yum erase rubymkdir /tmp/ruby && cd /tmp/rubycurl --remote-name --progress https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.3.tar.gzecho '1014ee699071aa2ddd501907d18cbe15399c997d ruby-2.3.3.tar.gz' | shasum -c - && tar xzf ruby-2.3.3.tar.gzcd ruby-2.3.3./configure --disable-install-rdocmakemake install
安装bundler
gem install bundler --no-ri --no-rdoc
Go
curl --remote-name --progress https://storage.googleapis.com/golang/go1.5.3.linux-amd64.tar.gztar -C /usr/local -xzf go1.5.3.linux-amd64.tar.gzln -sf /usr/local/go/bin/{go,godoc,gofmt} /usr/local/bin/rm go1.5.3.linux-amd64.tar.gz
Node
node >= v4.3.0 yarn >=v0.17.0
# install node v7.xcurl --location https://rpm.nodesource.com/setup_7.x | bash -yum install -y nodejs# install yarncurl --location https://yarnpkg.com/install.sh | bash -
System Users
为gitlab穿件用户
adduser --system --shell /bin/bash --create-home --home-dir /home/git --comment 'GitLab' git
mysql 5.7.17
yum install gcc gcc-c++ ncurses-devel perl #cmakewget http://www.cmake.org/files/v2.8/cmake-2.8.10.2.tar.gz tar -xzvf cmake-2.8.10.2.tar.gz cd cmake-2.8.10.2 ./bootstrap ; make ; make install cd ~ #mysql usergroupadd mysql useradd -r -g mysql mysql #dirmkdir -p /usr/local/mysql chown -R mysql:mysql /usr/local/mysqlmkdir -p /data/mysqldbchown -R mysql:mysql /data/mysqldb#mysqlwget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.17.tar.gztar -zxv -f mysql-5.7.17.tar.gzwget http://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gztar -xzf boost_1_59_0.tar.gzcd mysql-5.7.17#make and installcmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_BOOST=../boost_1_59_0make && make install cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
编辑mysql配置文件
[mysqld]basedir =/usr/local/mysqldatadir =/data/mysqldbport = 3306socket =/tmp/mysql.sock[client]socket=/tmp/mysql.sock
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqlchkconfig mysql on
初始化
mysqld --defaults-file=/etc/my.cnf --initialize --user=mysql
注意产生的临时密码
#startservice mysql start#loginmysql -u root -p>set password for 'root'@'localhost'=password('your password');
下面为gitlab创建数据库
#usermysql> CREATE USER 'git'@'localhost' IDENTIFIED BY '$password';mysql> SET storage_engine=INNODB;mysql> SET GLOBAL innodb_file_per_table=1, innodb_file_format=Barracuda, innodb_large_prefix=1;mysql> CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_general_ci`;# Grant the GitLab user necessary permissions on the databasemysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, CREATE TEMPORARY TABLES, DROP, INDEX, ALTER, LOCK TABLES, REFERENCES ON `gitlabhq_production`.* TO 'git'@'localhost';
Redis
配置yum源
rpm -ivh http://mirrors.ustc.edu.cn/epel/epel-release-latest-7.noarch.rpmrpm --import http://rpms.famillecollet.com/RPM-GPG-KEY-remirpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpmchkconfig redis on
配置redis
cp /etc/redis.conf /etc/redis.conf.origin# Disable Redis listening on TCP by setting 'port' to 0sed 's/^port .*/port 0/' /etc/redis.conf.origin | sudo tee /etc/redis.conf#Enable Redis socket for default CentOS path:echo 'unixsocket /var/run/redis/redis.sock' | sudo tee -a /etc/redis.confecho -e 'unixsocketperm 0770' | sudo tee -a /etc/redis.conf#Create the directory which contains the socketmkdir /var/run/redischown redis:redis /var/run/redischmod 755 /var/run/redis#Persist the directory which contains the socket, if applicableif [ -d /etc/tmpfiles.d ]; then echo 'd /var/run/redis 0755 redis redis 10d -' | tee -a /etc/tmpfiles.d/redis.conffi#Activate the changes to redis.conf:service redis restart#Add git to the redis group:usermod -aG redis git
GitLab
su gitgit clone https://gitlab.com/gitlab-org/gitlab-ce.git -b 9-0-stable gitlabcd gitlabcp config/gitlab.yml.example config/gitlab.ymlvim config/gitlab.yml
修改 gitlab -> host 为主机域名 更新 gitlab -> email_from 修改 git -> bin_path 为 /usr/local/bin/git
# Copy the example secrets filecp config/secrets.yml.example config/secrets.ymlchmod 0600 config/secrets.yml# Make sure GitLab can write to the log/ and tmp/ directorieschown -R git log/chown -R git tmp/chmod -R u+rwX,go-w log/chmod -R u+rwX tmp/# Make sure GitLab can write to the tmp/pids/ and tmp/sockets/ directorieschmod -R u+rwX tmp/pids/chmod -R u+rwX tmp/sockets/# Create the public/uploads/ directorymkdir public/uploads/# Make sure only the GitLab user has access to the public/uploads/ directory# now that files in public/uploads are served by gitlab-workhorsechmod 0700 public/uploads# Change the permissions of the directory where CI job traces are storedchmod -R u+rwX builds/# Change the permissions of the directory where CI artifacts are storedchmod -R u+rwX shared/artifacts/# Change the permissions of the directory where GitLab Pages are storedchmod -R ug+rwX shared/pages/# Copy the example Unicorn configcp config/unicorn.rb.example config/unicorn.rbcp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rbconfig --global core.autocrlf input#rediscp config/resque.yml.example config/resque.yml# database cp config/database.yml.mysql config/database.ymlvim config/database.ymlchmod o-rwx config/database.yml
安装 Gems
gem sources --add https://ruby.taobao.org/ --remove https://rubygems.org/gem sources -lbundle config mirror.https://rubygems.org https://ruby.taobao.orgbundle install --deployment --without development test postgres aws kerberos
安装
bundle exec rake gitlab:shell:install REDIS_URL=unix:/var/run/redis/redis.sock RAILS_ENV=production SKIP_STORAGE_VALIDATION=true
Install gitlab-workhorse
bundle exec rake "gitlab:workhorse:install[/home/git/gitlab-workhorse]" RAILS_ENV=production
初始化数据库
bundle exec rake gitlab:setup RAILS_ENV=production
我在这里遇到了小麻烦,redis不能初始化,我直接改用tcp端口通信
安装脚本
cp lib/support/init.d/gitlab /etc/init.d/gitlabchkconfig --add gitlabchkconfig gitlab on
安装 Logrotate
cp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab
检查应用状态
su git bundle exec rake gitlab:env:info RAILS_ENV=production
编译Assets\
bundle exec rake assets:precompile RAILS_ENV=production
启动 GitLab 服务
service gitlab start
nginx
首先配置nginx 源
vim /etc/yum.repos.d/nginx.repo
[nginx] name=nginx repo baseurl=http://nginx.org/packages/centos/6/$basearch/ gpgcheck=0 enabled=1
yum -y --enablerepo=nginx install nginxchkconfig nginx oncp lib/support/nginx/gitlab /etc/nginx/conf.d/gitlab.confusermod -a -G git nginxchmod g+rx /home/git/
检查配置 sudo nginx -t 重启nginx: sudo service nginx restart 安装完成! 再次验证应用状态,保证安装过程中没有错过任何步骤,可以通过以下命令验证: sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production
参考文档: