環境:CentOS-6.6-x86_64-minimal。前置條件是先裝好 LNMP(Nginx、MySQL、Redis 為必要,PHP 可選),可參考 lnmp 一鍵安裝包。
cat > /etc/yum.repos.d/epel.repo << EOF [epel] name=Extra Packages for Enterprise Linux 6 - \$basearch mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=\$basearch failovermethod=priority enabled=1 gpgcheck=0 EOF
內建的 git 1.7 與 GitLab 不相容,因此還要加入 PUIAS Computational 取得新版 git:
cat > /etc/yum.repos.d/PUIAS_6_computational.repo << EOF [PUIAS_6_computational] name=PUIAS computational Base \$releasever - \$basearch mirrorlist=https://puias.math.ias.edu/data/puias/computational/\$releasever/\$basearch/mirrorlist enabled=1 gpgcheck=0 EOF
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 crontabs logwatch \ logrotate perl-Time-HiRes git
cd lnmp/src wget https://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.5.tar.gz tar xzf ruby-2.1.5.tar.gz cd ruby-2.1.5 ./configure --prefix=/usr/local/ruby make && make install cd ..
vi /etc/profile export PATH=/usr/local/ruby/bin:$PATH . /etc/profile gem install bundler --no-ri --no-rdoc
adduser --system --shell /bin/bash --comment 'GitLab' --create-home --home-dir /home/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 sed -i 's@https://localhost/@https://git.linuxeye.com/@' config.yml sed -i 's@/usr/bin/redis-cli@/usr/local/redis/bin/redis-cli@' config.yml ./bin/install
mysql -uroot -p mysql> create database gitlabhq_production; mysql> quit;
指定 redis.sock 位置:
service redis-server stop mkdir /var/run/redis; chown -R redis.redis /var/run/redis vi /usr/local/redis/etc/redis.conf unixsocket /var/run/redis/redis.sock service redis-server start ls -l /var/run/redis/redis.sock
su - git wget https://github.com/gitlabhq/gitlabhq/archive/v7.4.5.tar.gz tar xzvf v7.4.5.tar.gz mv gitlabhq-7.4.5 gitlab cd gitlab cp config/gitlab.yml.example config/gitlab.yml sed -i 's@localhost@git.linuxeye.com@g' config/gitlab.yml chown -R git log/ tmp/ chmod -R u+rwX log/ tmp/ mkdir /home/git/gitlab-satellites mkdir tmp/pids/ tmp/sockets/ chmod -R u+rwX tmp/pids/ 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 "gitlab@linuxeye.com" git config --global core.autocrlf input cp config/resque.yml.example config/resque.yml
cp config/database.yml{.mysql,}
vi config/database.yml
production:
adapter: mysql2
encoding: utf8
collation: utf8_general_ci
reconnect: false
database: gitlabhq_production
pool: 10
username: root
password: "password"
chmod o-rwx config/database.yml
su - gem install charlock_holmes --version '0.6.9.4' exit cd /home/git/gitlab/ bundle install --deployment --without development test postgres puma aws
bundle exec rake gitlab:shell:install[v2.1.0] REDIS_URL=unix:/var/run/redis/redis.sock RAILS_ENV=production vi /home/git/gitlab-shell/config.yml # 修正 redis-cli 等路徑 restorecon -Rv /home/git/.ssh
bundle exec rake gitlab:setup RAILS_ENV=production # 預設帳號 root,密碼 5iveL!fe
su - 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 exit cd /home/git/gitlab/ bundle exec rake gitlab:env:info RAILS_ENV=production bundle exec rake assets:precompile RAILS_ENV=production service gitlab start
cd /usr/local/nginx/conf/vhost wget -O git.linuxeye.com.conf https://gitlab.com/gitlab-org/gitlab-ce/raw/master/lib/support/nginx/gitlab-ssl vi git.linuxeye.com.conf # root /home/git/gitlab; server_name、access_log、error_log # ssl_certificate gitlab.crt; ssl_certificate_key gitlab.key;
自簽憑證的做法(正式環境建議改用第三方簽發的憑證,以免瀏覽器警告):
cd /usr/local/nginx/conf openssl genrsa -out gitlab.key 2048 openssl req -new -x509 -days 36500 -key gitlab.key -out gitlab.crt \ -subj "/C=CN/ST=Shanghai/L=Shanghai/O=LinuxEye Ltd./OU=LinuxEye"
service nginx restart
完成後開啟 https://git.linuxeye.com,以 root/5iveL!fe 登入。
原文:https://blog.linuxeye.com/411.html