#依賴 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,更新node
#須要此依賴包,不然報錯 yum install curl-devel cd /tmp curl --remote-name --progress https://www.kernel.org/pub/software/scm/git/git-2.12.0.tar.gz && tar -xzf git-2.12.0.tar.gz cd git-2.12.0 ./configure make prefix=/usr/local all # Install into /usr/local/bin make 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最低版本2.1,yum安裝的是2.0mysql
yum erase ruby mkdir /tmp/ruby && cd /tmp/ruby curl --remote-name --progress https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.3.tar.gz echo '1014ee699071aa2ddd501907d18cbe15399c997d ruby-2.3.3.tar.gz' | shasum -c - && tar xzf ruby-2.3.3.tar.gz cd ruby-2.3.3 ./configure --disable-install-rdoc make make install
安裝bundlerlinux
gem install bundler --no-ri --no-rdoc
curl --remote-name --progress https://storage.googleapis.com/golang/go1.5.3.linux-amd64.tar.gz tar -C /usr/local -xzf go1.5.3.linux-amd64.tar.gz ln -sf /usr/local/go/bin/{go,godoc,gofmt} /usr/local/bin/ rm go1.5.3.linux-amd64.tar.gz
node >= v4.3.0 yarn >=v0.17.0nginx
# install node v7.x curl --location https://rpm.nodesource.com/setup_7.x | bash - yum install -y nodejs # install yarn curl --location https://yarnpkg.com/install.sh | bash -
爲gitlab穿件用戶c++
adduser --system --shell /bin/bash --create-home --home-dir /home/git --comment 'GitLab' git
yum install gcc gcc-c++ ncurses-devel perl #cmake wget 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 user groupadd mysql useradd -r -g mysql mysql #dir mkdir -p /usr/local/mysql chown -R mysql:mysql /usr/local/mysql mkdir -p /data/mysqldb chown -R mysql:mysql /data/mysqldb #mysql wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.17.tar.gz tar -zxv -f mysql-5.7.17.tar.gz wget http://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz tar -xzf boost_1_59_0.tar.gz cd mysql-5.7.17 #make and install cmake -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_0 make && make install cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
編輯mysql配置文件git
[mysqld] basedir =/usr/local/mysql datadir =/data/mysqldb port = 3306 socket =/tmp/mysql.sock [client] socket=/tmp/mysql.sock
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql chkconfig mysql on
初始化golang
mysqld --defaults-file=/etc/my.cnf --initialize --user=mysql
注意產生的臨時密碼redis
#start service mysql start #login mysql -u root -p >set password for 'root'@'localhost'=password('your password');
下面爲gitlab建立數據庫sql
#user mysql> 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 database mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, CREATE TEMPORARY TABLES, DROP, INDEX, ALTER, LOCK TABLES, REFERENCES ON `gitlabhq_production`.* TO 'git'@'localhost';
配置yum源shell
rpm -ivh http://mirrors.ustc.edu.cn/epel/epel-release-latest-7.noarch.rpm rpm --import http://rpms.famillecollet.com/RPM-GPG-KEY-remi rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm chkconfig redis on
配置redis
cp /etc/redis.conf /etc/redis.conf.origin # Disable Redis listening on TCP by setting 'port' to 0 sed '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.conf echo -e 'unixsocketperm 0770' | sudo tee -a /etc/redis.conf #Create the directory which contains the socket mkdir /var/run/redis chown redis:redis /var/run/redis chmod 755 /var/run/redis #Persist the directory which contains the socket, if applicable if [ -d /etc/tmpfiles.d ]; then echo 'd /var/run/redis 0755 redis redis 10d -' | tee -a /etc/tmpfiles.d/redis.conf fi #Activate the changes to redis.conf: service redis restart #Add git to the redis group: usermod -aG redis git
su git git clone https://gitlab.com/gitlab-org/gitlab-ce.git -b 9-0-stable gitlab cd gitlab cp config/gitlab.yml.example config/gitlab.yml vim config/gitlab.yml
修改 gitlab -> host 爲主機域名 更新 gitlab -> email_from 修改 git -> bin_path 爲 /usr/local/bin/git
# Copy the example secrets file cp config/secrets.yml.example config/secrets.yml chmod 0600 config/secrets.yml # Make sure GitLab can write to the log/ and tmp/ directories chown -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/ directories chmod -R u+rwX tmp/pids/ chmod -R u+rwX tmp/sockets/ # Create the public/uploads/ directory mkdir 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-workhorse chmod 0700 public/uploads # Change the permissions of the directory where CI job traces are stored chmod -R u+rwX builds/ # Change the permissions of the directory where CI artifacts are stored chmod -R u+rwX shared/artifacts/ # Change the permissions of the directory where GitLab Pages are stored chmod -R ug+rwX shared/pages/ # Copy the example Unicorn config cp config/unicorn.rb.example config/unicorn.rb cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb config --global core.autocrlf input #redis cp config/resque.yml.example config/resque.yml # database cp config/database.yml.mysql config/database.yml vim config/database.yml chmod o-rwx config/database.yml
安裝 Gems
gem sources --add https://ruby.taobao.org/ --remove https://rubygems.org/ gem sources -l bundle config mirror.https://rubygems.org https://ruby.taobao.org bundle 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/gitlab chkconfig --add gitlab chkconfig 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 源
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 nginx chkconfig nginx on cp lib/support/nginx/gitlab /etc/nginx/conf.d/gitlab.conf usermod -a -G git nginx chmod g+rx /home/git/
檢查配置 sudo nginx -t 重啓nginx: sudo service nginx restart 安裝完成! 再次驗證應用狀態,保證安裝過程當中沒有錯過任何步驟,能夠經過如下命令驗證: sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production
參考文檔: https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/install/installation.md http://blog.csdn.net/huangzhijie3918/article/details/51330425