環境
項目 | 内容(バージョン) | 備考 |
---|---|---|
OS | Ubuntu 14.04LTS | |
Ruby | 2.1.6 | |
gem | 2.2.3 | |
bundler | 1.10.5 | |
DB | MySQL5.6.25 | 5.7は未対応っぽい |
git | 2.4.6 | |
GitLab | 7-13-stable | |
gitlab-shell | 2.6.3 |
インストール手順
パッケージを最新に更新する
console
# run as root user
sudo apt-get update -y
sudo apt-get upgrade -y
必要に応じてvimをインストールする
console
# run as root user
sudo apt-get install -y vim
update-alternatives --set vim /usr/bin/vim.basic
インストールに必要なパッケージをインストールする
インストールに必要なパッケージをインストール
sudo apt-get install -y build-essential libssl-dev libicu-dev pkg-config libmysqlclient-dev libkrb5-dev logrotate postfix
# シンボリックリンクを貼る
ln -s /usr/bin/make /usr/bin/gmake
gitのインストール
gitインストール
sudo apt-get install -y python-software-properties
sudo add-apt-repository ppa:git-core/ppa
sudo apt-get update
sudo apt-get install git
git --version
rubyのインストール
console
git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="~/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
source ~/.bashrc
# インストールできるバージョンを確認
rbenv install -l
# インストール
rbenv install 2.1.6
# グローバルで使用するRubyのバージョン指定
rbenv global 2.1.6
rbenv versions
# バージョンの確認
ruby -v
bundlerのインストール
# bundlerのインストール
gem install bundler
# バージョンの確認
bundle -v
redisのインストール
# リポジトリの追加と更新
sudo add-apt-repository ppa:chris-lea/redis-server
# インストール可能バージョンの確認
sudo apt-get update
# バージョンを指定してインストール
sudo apt-cache showpkg redis-server
sudo apt-get install redis-server=3:3.0.2-1chl1~trusty1
# バージョンの確認
redis-server -v
ユーザの作成
console
adduser git
Adding user `git' ...
Adding new group `git' (1000) ...
Adding new user `git' (1000) with group `git' ...
Creating home directory `/home/git' ...
Copying files from `/etc/skel' ...
Enter new UNIX password: パスワード
Retype new UNIX password: パスワード(確認)
passwd: password updated successfully
Changing the user information for git
Enter the new value, or press ENTER for the default
Full Name []:
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n] y
# 必要に応じてsudo権限を付与する
usermod -G sudo git
MySQLのインストール
console
wget http://dev.mysql.com/get/mysql-apt-config_0.3.3-2ubuntu14.04_all.deb
dpkg -i mysql-apt-config_0.3.3-2ubuntu14.04_all.deb
apt-get update
apt-cache policy mysql-server
apt-get install mysql-server
GitLab用DB設定
console
mysql -u root -p
CREATE USER 'gitlab'@'localhost' IDENTIFIED BY 'パスワード';
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';
\q
# 接続確認
mysql -u gitlab -p -D gitlabhq_production
GitLab-Shellのインストール
console
# gitユーザに切り替え
sudo su - git
# ホームに移動(/home/git/)
cd
# gitlab-shellをclone
git clone https://github.com/gitlabhq/gitlab-shell.git gitlab-shell
# 移動
cd gitlab-shell
# 最新タグをチェックアウトする
git checkout v2.6.3
# 設定ファイルを作成する
cp config.yml.example config.yml
# 日安協に合うように修正する
vim config,yml
# gitlab-shellのインストール
./bin/install
GitLabのインストール
console
# gitユーザに切り替える
sudo su - git
# ホームに移動
cd
# GitLabのソースコードをclone
git clone https://github.com/gitlabhq/gitlabhq.git gitlab
cd gitlab
git checkout 7-13-stable
# 権限の変更
sudo chown -R git log/
sudo chown -R git tmp/
sudo chmod -R u+rwX log/
sudo chmod -R u+rwX tmp/
# 各種設定ファイル
cd /home/git/gitlab/config
# データベース設定をコピー
cp database.yml.mysql database.yml
# 必要に応じて修正
vim database.yml
# GitLabの」設定をコピー
cp gitlab.yml.example gitlab.yml
# 必要に応じて修正
vim gitlab.yml
# resqueの設定をコピー
cp resque.yml.example resque.yml
# 必要に応じて修正
vim resque.yml
# unicornの設定をコピー
cp unicorn.rb.example unicorn.rb
# 必要に応じて修正
vim unicorn.rb
# gemsのインストール
bundle install --deployment --without development test postgres
# DBの初期化とセットアップ
bundle exec rake gitlab:setup RAILS_ENV=production
# Assetsのビルド
bundle exec rake assets:precompile RAILS_ENV=production
cp /lib/support/nginx/gitlab /etc/nginx/conf.d/gitlab
vim /etc/nginx/conf.d/gitlab
cp /lib/support/init.d/gitlab /etc/init.d/gitlab
/etc/init.d/gitlab start
Nginx
console
curl http://nginx.org/keys/nginx_signing.key | sudo apt-key add -
sudo sh -c "echo 'deb http://nginx.org/packages/ubuntu/ trusty nginx' >> /etc/apt/sources.list"
sudo sh -c "echo 'deb-src http://nginx.org/packages/ubuntu/ trusty nginx' >> /etc/apt/sources.list"
# アップデート後、nginxをインストール
sudo apt-get update
sudo apt-get install nginx
cp /home/git/gitlab/lib/support/nginx/nginx /etc/nginx/conf.d/gitlab.conf
# 自分の環境に合わせて修正
vim /etc/nginx/conf.d/gitlab.conf
# nginx再起動
service nginx restart
ブラウザでhttp://yourhost/
にアクセスするとログインページが表示する。
項目 | 値 |
---|---|
ID | root |
Password | 5iveL!fe |