CentOS6.4のインストールからGitLab5.4インストールまでのコマンド他メモ
なかなか書き続けることって難しい。
と言い訳から書き始めてみました。
CentOSにGitLabをインストールする作業をしていました。
ただただプログラムだけ書いていれたらいいのにな...
とか現実逃避するくらい、ちょっとだけはまってました。
ちょっとだけ。
インストールするマシンは2004年購入の...
DVDついてないので、CentOS6.4のダウンロードページ http://ftp.riken.jp/Linux/centos/6.4/isos/i386/ から、
CentOS-6.4-i386-minimal.isoをダウンロードして、CD-Rに書き込んでインストールしました。
1. CentOS6.4の初期設定
カーネルバージョンの更新(権限昇格される脆弱性があるみたいだから)
再起動
カーネル自動更新の停止
ファイルシステムext4のオプション変更
プロセス最大数の制限解除
SELinuxの停止(自己責任で)
iptablesの停止(自己責任で)
OpenSSHのアップグレード
再起動
# yum update kernel* # reboot # yum clean all # sed -i 's/^UPDATEDEFAULT=yes/UPDATEDEFAULT=no/' /etc/sysconfig/kernel # sed -i 's/\(.*ext4.*\)defaults/\1defaults,nobarrier,noatime/' /etc/fstab # sed -i 's/^\*/#\*/' /etc/security/limits.d/90-nproc.conf # sed -i 's/^SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config # chkconfig iptables off # chkconfig ip6tables off # yum -y install yum-utils # rpm -ivh http://dl.atrpms.net/el6.4-i386/atrpms/stable/atrpms-repo-6-6.el6.i686.rpm # sed -i 's/^enabled=1/enabled=0/' /etc/yum.repos.d/atrpms.repo # yum --enablerepo=atrpms -y install libtool # rpm -ivh http://centos.alt.ru/repository/centos/6/i386/centalt-release-6-1.noarch.rpm # sed -i 's/^enabled=1/enabled=0/' /etc/yum.repos.d/centalt.repo # yum --enablerepo=CentALT -y upgrade openssh # sed -i 's/^#Protocol 2/Protocol 2/' /etc/ssh/sshd_config # sed -i 's/^#PermitRootLogin yes/PermitRootLogin no/' /etc/ssh/sshd_config # sed -i 's/^#PermitEmptyPasswords no/PermitEmptyPasswords no/' /etc/ssh/sshd_config # reboot
GitLabのインストールの参考は公式ページ
https://github.com/gitlabhq/gitlabhq/blob/5-4-stable/doc/install/installation.md
2. 参照パッケージ群のインストール
# yum -y install wget make tcl tcl-devel tk tk-devel gcc gcc-c++ kernel-devel ncurses-devel zlib-devel readline-devel openssl-devel gdbm-devel libffi-devel curl bzip2-devel libxml2-devel libxslt-devel libicu-devel libcurl-devel perl-ExtUtils-MakeMaker gettext rsync # rpm -ivh http://ftp-srv2.kddilabs.jp/Linux/distributions/fedora/epel/6/i386/epel-release-6-8.noarch.rpm # sed -i 's/^enabled=1/enabled=0/' /etc/yum.repos.d/epel.repo # yum --enablerepo=epel -y install libyaml-devel # yum groupinstall --enablerepo=epel --exclude=*perl-Git* --skip-broken -y 'Development Tools'
3. SQLite3 Python2.7.5のインストール
# cd /usr/local/src/ # wget http://www.sqlite.org/sqlite-3.6.23.1.tar.gz # tar xvzf sqlite-3.6.23.1.tar.gz # cd sqlite-3.6.23.1 # ./configure # make # make install # sqlite3 -version # cd /usr/local/src/ # wget http://www.python.org/ftp/python/2.7.5/Python-2.7.5.tgz # tar xvzf Python-2.7.5.tgz # cd Python-2.7.5 # CC=gcc CXX=g++ ./configure --enable-shared --with-threads # make # make install # cp libpython2.7.so libpython2.7.so.1.0 /usr/lib # /sbin/ldconfig # python -V
4. git 1.8.3.3のインストール
# cd /usr/local/src/ # wget http://git-core.googlecode.com/files/git-1.8.3.3.tar.gz # tar zxvf git-1.8.3.3.tar.gz # cd git-1.8.3.3 # ./configure # make # make install # ln -s /usr/local/bin/git /usr/bin/git # git --version
5. Ruby 1.9.3のインストール
# curl -L https://get.rvm.io | bash -s stable # source /etc/profile.d/rvm.sh # rvm autolibs enable 3 # rvm install 1.9.3 --with-libyaml-dir=/usr/local # rvm use 1.9.3 --default # gem install bundler --no-ri --no-rdoc
6. gitユーザの作成
# 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
7. GitLab shellのインストール
$ cd /home/git $ git clone https://github.com/gitlabhq/gitlab-shell.git $ cd gitlab-shell $ git checkout v1.5.0 $ cp config.yml.example config.yml $ vi config.yml --- gitlab_url: "http://localhost/" +++ gitlab_url: "http://アドレス変更/" $ ./bin/install $ exit
8.MySQLのインストール
# rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm # yum install --enablerepo=remi -y mysql mysql-server mysql-devel mysql-libs # vi /etc/my.cnf --- [mysqld] --- datadir=/var/lib/musql --- socket=/var/lib/musql/mysql.sock +++ [mysqld] +++ datadir=/var/lib/musql +++ socket=/var/lib/musql/mysql.sock +++ bind-address=127.0.0.1 # /etc/init.d/mysqld start # chkconfig mysqld on # mysql > CREATE USER 'gitlab'@'localhost' IDENTIFIED BY 'password(パスワードを記入)'; > CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`; > GRANT SELECT, LOCK TABLES, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO 'gitlab'@'localhost'; >\q # mysql -u gitlab -p -D gitlabhq_production Enter password: >\q
9.Redisのインストール
# yum --enablerepo=epel -y install redis # /etc/init.d/redis start # chkconfig redis on
10. GitLab関連のインストール
# su - git $ cd /home/git $ git clone https://github.com/gitlabhq/gitlabhq.git gitlab $ cd /home/git/gitlab $ git checkout 5-4-stable $ cp config/gitlab.yml.example config/gitlab.yml $ vi config/gitlab.yml --- host:localhost +++ host:アドレス変更 $ chown -R git log/ $ chown -R git tmp/ $ chmod -R u+rwX log/ $ chmod -R u+rwX tmp/ $ mkdir /home/git/gitlab-satellites $ mkdir tmp/pids/ $ mkdir tmp/sockets/ $ chmod -R u+rwX tmp/pids/ $ chmod -R u+rwX tmp/sockets/ $ mkdir public/uploads $ chmod -R u+rwX public/uploads $ cp config/puma.rb.example config/puma.rb $ git config --global user.name "GitLab" $ git config --global user.email "gitlab@example.co.jp" $ cp config/database.yml.mysql config/database.yml $ vi config/database.yml --- username: root --- password: "secure password" +++ username: gitlab +++ password: password(パスワード) $ chmod o-rwx config/database.yml $ exit # cd /home/git/gitlab # gem install charlock_holmes --version '0.6.9.4' $ su - git $ cd /home/git/gitlab $ bundle install --deployment --without development test postgres unicorn aws $ bundle exec rake gitlab:setup RAILS_ENV=production $ exit # cp /home/git/gitlab/lib/support/init.d/gitlab /etc/init.d/gitlab # chmod +x /etc/init.d/gitlab # su - git $ cd /home/git/gitlab $ bundle exec rake gitlab:env:info RAILS_ENV=production $ bundle exec rake gitlab:check RAILS_ENV=production $ exit # chkconfig gitlab on # /etc/init.d/gitlab start
※追記 bundle install --deployment --without development test postgres unicorn awsでエラー時 ->http://stackoverflow.com/questions/22825497/installing-gitlab-missing-modernizer
11. Nginxのインストール
# rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm # sed -i 's/^enabled=1/enabled=0/' /etc/yum.repos.d/nginx.repo # yum --enablerepo=nginx -y install nginx # chkconfig nginx on # cp /home/git/gitlab/lib/support/nginx/gitlab /etc/nginx/conf.d/gitlab.conf # vi /etc/nginx/conf.d/gitlab.conf --- listen 80 default_server; +++ listen アドレス変更:80; 注) 2013.12.13追記: +++ client_max_body_size 20M; ここまで) # /etc/init.d/nginx configtest # chmod 755 /home/git # /etc/init.d/nginx start
※追記注 ->GitLab5.4 - nginx で push 時に"413 Request Entity Too Large"が出たときの対応をメモ - 書く。
ブラウザからアクセスして画面が表示できれば終了。
もっといい方法とかあったら @nzkh2nr に教えください。
*2