Last active
August 29, 2015 13:57
-
-
Save wokamoto/9500102 to your computer and use it in GitHub Desktop.
Amazon Linux に gitlab 入れるメモ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# t1.micro の場合 unicorn 起動時にメモリ足りなくなるので swap 作っておく | |
dd if=/dev/zero of=/swapfile bs=1024 count=2097152 | |
mkswap /swapfile | |
swapon /swapfile | |
echo '/swapfile none swap defaults 0 0' >> /etc/fstab | |
echo ' | |
vm.swappiness=0' >> /etc/sysctl.conf | |
# PublicDNS の取得 | |
PUBLIC_HOST_NAME=`/usr/bin/curl http://169.254.169.254/latest/meta-data/public-hostname` | |
# ライブラリ類のインストール | |
yum -y groupinstall "Development tools" | |
yum install -y make gcc gcc-c++ patch zlib-devel bzip2-devel \ | |
readline-devel libffi-devel openssl-devel git vim-enhanced \ | |
libxslt-devel libxml2-devel libicu-devel | |
yum -y update | |
# redis のインストール | |
yum -y install --enablerepo=epel redis | |
chkconfig redis on | |
service redis start | |
redis-cli ping | |
# pong が返ってくればOK | |
# ruby 2.0.0-p451 のインストール | |
yum -y remove ruby | |
cd /usr/local | |
git clone https://github.com/sstephenson/rbenv rbenv | |
mkdir rbenv/shims rbenv/versions | |
git clone https://github.com/sstephenson/ruby-build ruby-build | |
cd ruby-build/ | |
./install.sh | |
echo 'export RBENV_ROOT="/usr/local/rbenv" | |
export PATH="$PATH:/usr/local/rbenv/bin:/usr/local/ruby-build/bin" | |
eval "$(rbenv init -)"' > /etc/profile.d/rbenv.sh | |
visudo | |
------ | |
# 起動スクリプト内で sudo 使ってるから root だけ requiretty を | |
# 外しておかないと再起動時にサービス起動しません | |
Defaults:root !requiretty | |
# 末尾に追加 | |
Defaults !secure_path | |
Defaults env_keep += "PATH RBENV_ROOT" | |
------ | |
source /etc/profile.d/rbenv.sh | |
rbenv install 2.0.0-p451 | |
rbenv global 2.0.0-p451 | |
ruby -v | |
# bundle のインストール | |
gem install bundler --no-ri --no-rdoc | |
rbenv rehash | |
# 実行ユーザーの作成 | |
useradd git | |
echo "[user] | |
name = GitLab | |
email = gitlab@$PUBLIC_HOST_NAME | |
[core] | |
autocrlf = input" > /home/git/.gitconfig | |
chown git:git /home/git/.gitconfig | |
# gitlab-shell のインストール | |
cd /home/git | |
sudo -u git -H git clone https://github.com/gitlabhq/gitlab-shell | |
cd gitlab-shell | |
sudo -u git -H git checkout v1.8.5 | |
sed -e "s/http:\/\/localhost/http:\/\/$PUBLIC_HOST_NAME/" config.yml.example > config.yml | |
chown git:git config.yml | |
sudo -u git -H ruby ./bin/install | |
# mysql のインストール | |
yum -y install mysql55 mysql55-server mysql55-devel | |
chkconfig mysqld on | |
service mysqld start | |
# mysql のユーザー・データベースの作成 | |
echo "GRANT ALL PRIVILEGES ON *.* TO gitlab@localhost IDENTIFIED BY 'gitlab';" | mysql -u root | |
echo 'DROP DATABASE IF EXISTS gitlabhq_production;' | mysql -u root | |
echo 'CREATE DATABASE gitlabhq_production DEFAULT CHARACTER SET utf8;' | mysql -u root | |
# gitlab のインストール | |
cd /home/git | |
sudo -u git -H git clone https://github.com/gitlabhq/gitlabhq gitlab | |
cd gitlab | |
sudo -u git -H git checkout 6-6-stable | |
# 設定ファイル類のコピーとか | |
sed -e "s/localhost/$PUBLIC_HOST_NAME/" config/gitlab.yml.example > config/gitlab.yml | |
chown git:git config/gitlab.yml | |
sed -e "s/username: git/username: gitlab/" config/database.yml.mysql \ | |
| sed -e "s/password: \"secure password\"/password: \"gitlab\"/" > config/database.yml | |
chown git:git config/database.yml | |
sudo -u git -H cp config/unicorn.rb.example config/unicorn.rb | |
sudo -u git -H cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb | |
# 必要なディレクトリを作成 | |
chown -R git log/ | |
chmod -R u+rwX log/ | |
chown -R git tmp/ | |
chmod -R u+rwX tmp/ | |
sudo -u git -H mkdir /home/git/gitlab-satellites | |
sudo -u git -H mkdir tmp/pids/ | |
chmod -R u+rwX tmp/pids/ | |
sudo -u git -H mkdir tmp/sockets/ | |
chmod -R u+rwX tmp/sockets/ | |
sudo -u git -H mkdir public/uploads | |
chmod -R u+rwX public/uploads | |
# gem 諸々のインストール | |
gem install charlock_holmes --version '0.6.9.4' | |
sudo -u git -H bundle install --deployment --without development test postgres aws | |
# データベースの初期化 | |
yes yes | sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production | |
# プリコンパイルしておかないと unicorn の worker がタイムアウトしちゃうので... | |
sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production | |
# 起動スクリプトのコピー | |
cp lib/support/init.d/gitlab /etc/init.d/gitlab | |
chmod +x /etc/init.d/gitlab | |
# logrotate 用ファイルの設定 | |
wget https://raw.github.com/gitlabhq/gitlabhq/master/lib/support/logrotate/gitlab | |
mv gitlab /etc/logrotate.d/ | |
# Application Status のチェック | |
sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production | |
# gitlab の起動 | |
service gitlab start | |
chkconfig gitlab on | |
# nginx のインストールと設定ファイルのコピー | |
yum -y install nginx | |
cd /etc/nginx | |
sed -e "s/YOUR_SERVER_FQDN/$PUBLIC_HOST_NAME/" /home/git/gitlab/lib/support/nginx/gitlab > conf.d/gitlab.conf | |
cp nginx.conf nginx.conf.org | |
# nginx の実行ユーザを git に変更したり、長いホスト名に対応させたり | |
sed -e "s/user nginx;/user git;/" nginx.conf.org \ | |
| sed -e "s/keepalive_timeout 65;/keepalive_timeout 65;\n\n server_names_hash_bucket_size 128;/" \ | |
> nginx.conf | |
service nginx start | |
chkconfig nginx on | |
# Application Status のチェック | |
cd /home/git/gitlab | |
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ここ参考にした
Amazon Linux 2013.09 に GitLab6.1 をインストール - OTメモ帳