安装环境
- CentOS release 6.5 (Final)
- Apache 2.2.27
- MySQL 5.5.38
- Git 1.9.3
- Ruby 2.1.0p0
- GitLab 7.0.0.rc1
- Gitlab-shell 1.9.6
- Redis 2.4.10
省略。。。
mysql安装
1.mysql安装
省略。。。
2.mysql数据库以及操作用户作成
$ mysql -uroot
mysql>
CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO 'gitlab'@'localhost' IDENTIFIED BY '*****';
git安装
1.git安装
cd /usr/local/src
wget https://www.kernel.org/pub/software/scm/git/git-1.9.3.tar.gz
tar zxvf git-1.9.3.tar.gz
cd git-1.9.3
./configure --prefix=/usr/local/<span style="font-family: Arial, Helvetica, sans-serif;">git-1.9.3</span>
make
make install
ln -s /usr/local/git-1.9.3 git
vi /etc/profile
#git
export PATH=/usr/local/git/bin:$PATH
source /etc/profile
4.git版本确认
git --version
ruby安装
省略。。。
gitlab操作用户做成
useradd -c 'GitLab' -s /bin/bash git
su - git
cd /home/git
mkdir .ssh
touch .ssh/authorized_keys
chmod 600 .ssh/authorized_keys
chmod 700 .ssh
redis安装
1.redis安装
#用yum安装
yum install redis
/etc/init.d/redis start
chkconfig redis on
chkconfig --list |grep redis
#用yum安装出问题,下面解决方法
$ wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rp
$ wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
$ rpm -Uvh remi-release-6*.rpm epel-release-6*.rpm
$ yum install redis -y
2.状态检测
redis-cli
redis> ping
PONG
redis> set foo bar
OK
redis> get foo
"bar"
redis> quit
1.gitlab shell安装
cd /home/git
git clone https://github.com/gitlabhq/gitlab-shell.git
cd gitlab-shell/
cat VERSION
2.gitlab shell设定
cp config.yml.example config.yml
vi config.yml
gitlab_url: "http://localhost/"
↓
gitlab_url: "https://210.160.8.249/gitlab"
# ca_file: /etc/ssl/cert.pem
# ca_path: /etc/pki/tls/certs
self_signed_cert: false
↓
ca_file: /usr/local/apache2/conf/ssl/server.crt
ca_path: /usr/local/apache2/conf/ssl
self_signed_cert: true
3.gitlab shell执行
./bin/install
mkdir -p /home/git/repositories: OK
mkdir -p /home/git/.ssh: OK
chmod 700 /home/git/.ssh: OK
touch /home/git/.ssh/authorized_keys: OK
chmod 600 /home/git/.ssh/authorized_keys: OK
chmod -R ug+rwX,o-rwx /home/git/repositories: OK
find /home/git/repositories -type d -exec chmod g+s {} ;: OK
gitlab安装
1.gitlab安装
cd /home/git
git clone https://github.com/gitlabhq/gitlabhq.git gitlab
cd gitlab
cat VERSION
7.0.0.rc1
git checkout -b 7.0.0.rc1
2.gitlab设定
cd /home/git/gitlab
cp config/application.rb config/application.rb.origin
vi config/application.rb
# config.relative_url_root = "/gitlab"
↓
config.relative_url_root = "/gitlab"
cp config/gitlab.yml.example config/gitlab.yml
vi config/gitlab.yml
host: localhost
port: 80
https: false
↓
host: 210.160.8.249
port: 443
https: true
# relative_url_root: /gitlab
↓
relative_url_root: /gitlab
email_from: example@example.com
↓
email_from: yang_ming@microad.co.jp
bin_path: /usr/bin/git
↓
bin_path: /usr/local/bin/git
cp config/database.yml.mysql config/database.yml
vi config/database.yml
username: gitlab
password: "microad"
↓
username: git
password: "secure password"
username: gitlab
password: "microad"
↓
username: root
password: "secure password"
username: gitlab
password: "microad"
↓
username: root
password:
cp config/unicorn.rb.example config/unicorn.rb
vi config/unicorn.rb
ENV['RAILS_RELATIVE_URL_ROOT'] = "/gitlab"
↓
# ENV['RAILS_RELATIVE_URL_ROOT'] = "/gitlab"
#listen "127.0.0.1:8080", :tcp_nopush => true
↓
listen "127.0.0.1:8080", :tcp_nopush => true
#相关包导入
yum list | grep libicu
yum list | grep libcurl
yum list | grep libicu-dev
yum list | grep libicu-devel
#gem安装
cd /home/git/gitlab
bundle install --deployment --without development test postgres
4.gitlab数据库初始化
bundle exec rake gitlab:setup RAILS_ENV=production
5.启动文件作成
cd /home/gitlab
cp lib/support/init.d/gitlab /etc/init.d/gitlab
cp lib/support/init.d/gitlab.default.example /etc/default/gitlab
chmod +x /etc/init.d/gitlab
6.日志设置
cd /home/gitlab
cp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab
7.gitlab状态检测
bundle exec rake gitlab:env:info RAILS_ENV=production
System information System: Current User: git Using RVM: no Ruby Version: 2.1.0p0 Gem Version: 2.2.0 Bundler Version:1.5.3 Rake Version: 10.3.2 Sidekiq Version:2.17.0 GitLab information Version: 7.0.0.rc1 Revision: 6793414 Directory: /home/git/gitlab DB Adapter: mysql2 URL: https://210.160.8.249/gitlab HTTP Clone URL: https://210.160.8.249/gitlab/some-project.git SSH Clone URL: git@210.160.8.249:some-project.git Using LDAP: no Using Omniauth: no GitLab Shell Version: 1.9.6 Repositories: /home/git/repositories/ Hooks: /home/git/gitlab-shell/hooks/ Git: /usr/local/bin/git
8.assets执行
bundle exec rake assets:precompile RAILS_ENV=production
9.gitlab启动
/etc/init.d/gitlab start
10.gitlab启动状态检测
bundle exec rake gitlab:check RAILS_ENV=production
apache对应与设置
1.passenger安装
passenger-install-apache2-module
2.apache设定
cd /usr/local/apache2/conf
vi httpd.conf
#passenger
LoadModule passenger_module /usr/local/ruby-2.1.0/lib/ruby/gems/2.1.0/gems/passenger-4.0.37/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
PassengerRoot /usr/local/ruby-2.1.0/lib/ruby/gems/2.1.0/gems/passenger-4.0.37
PassengerDefaultRuby /usr/local/ruby-2.1.0/bin/ruby
</IfModule>
cd /usr/local/apache2/conf/extra
vi httpd-ssl.conf
#gitlab
Alias /gitlab "/home/www/htdocs/gitlab"
<Directory "/home/www/htdocs/gitlab*">
Options -MultiViews
SetEnv RAILS_RELATIVE_URL_ROOT "/gitlab"
PassengerAppRoot "/home/git/gitlab"
Order allow,deny
Allow from all
</Directory>
3.apache再启动
/etc/rc.d/init.d/httpd restart
gitlab登陆画面确认
https://hostlocal/gitlab/users/sign_in
gitlab版本取得
git clone https://localhost/gitlab/yang/repos_test.git
#出现问题,下面解决方法
git config --global http.sslVerify false