githubがあるからgitlabなくてもいいんじぇね?と言う人もいるだろう。
だが、我がubuntuサーバーが暇をもてあましていて、タイトル通り、gitlabをインストールしてみた。
が・・・・・、ほかのサイトの人もそうだけど、初心者には時間がかかるw
今後また構築する機会がありそうなので、メモ代わりに手順を書いておく。この手順通りにやって、エラーが出た場合は、各自がググって解決しましょう。甘やかしはしませんぜ(-.☆
sudo、vimなどが入ってない場合、いれておくこと!
バージョン確認のために
現在、ちなみに私の環境では、
はい、これでruby2.0がインストールされた
その後、Bundler もさらにインストール
インストール後、現在、私の環境では、
config.ymlを開くと、gitlab_urlの項目を、環境に合わせた名前に変更。
私の場合は、gitlab.kaoken.net としました。Apache(プロクシ)経由で今後アクセスできるように!
“timeout”については、余裕をもって120秒にしました。
下記のように表示された
mysqlユーザーとして”git“を作っておきます。
その後”gitlabhq_production“データーベスを作り、全ての権限をgitに与えておいてください。ユーザー作成、DB作成については、ググってください。
移動後、gitlabをいれます。このとき、ダウンロードにしばらく時間がかかります。
現時点で最新版の6.6.5をコピーし、そして移動。
gitlab.ymlファイルの”host”は、Gitlab shellのconfig.ymlと同じく”gitlab.kaoken.net”とした。
“email_from”、”support_email”の項目は各環境に合わせて変更。
database.ymlファイルの”password”の項目のパスワードを各自設定したパスを入力
設定&インストールなどで、しばし、待つ・・・・
正常に終了すると、ログインとパスワードを返す。
特にエラーなし。
何事もなければ、実行される。
入力後
gitlab用にプロクシ設定をする。
この辺の設定は、各サーバによって違うのでがんばってくれ!(-.☆
はぃ~~、これでgitlabが見られるようになりました。 http://gitlab.kaoken.cg0.xyz
おつかれさまぁ~
だが、我がubuntuサーバーが暇をもてあましていて、タイトル通り、gitlabをインストールしてみた。
が・・・・・、ほかのサイトの人もそうだけど、初心者には時間がかかるw
今後また構築する機会がありそうなので、メモ代わりに手順を書いておく。この手順通りにやって、エラーが出た場合は、各自がググって解決しましょう。甘やかしはしませんぜ(-.☆
最初に
sudo apt-get install build-essential zlib1g-dev libyaml-dev libssl-dev libgdbm-dev libreadline-dev libncurses5-dev libffi-dev curl openssh-server redis-server checkinstall libxml2-dev libxslt-dev libcurl4-openssl-dev libicu-dev logrotate sudo apt-get update sudo apt-get upgrade
sudo、vimなどが入ってない場合、いれておくこと!
ruby2.0を入れる
rubyが既に、1.8または1.9が入っていたら削除しておく。このバージョンとリンクしているモジュールなどがあった場合、個々で対応してくださいな。かなりめんどいだろうなぁ^^;sudo apt-get remove ruby1.8 sudo apt-get remove ruby1.9 sudo apt-get install ruby2.0
バージョン確認のために
sudo ruby -v
現在、ちなみに私の環境では、
ruby 2.0.0p299 (2013-08-29) [x86_64-linux-gnu]
と、表示されるはい、これでruby2.0がインストールされた
その後、Bundler もさらにインストール
sudo gem install bundler --no-ri --no-rdoc
gitを入れる
これが無ければはじまらない、sudo apt-get install -y git-core git --version
インストール後、現在、私の環境では、
git version 1.8.3.2
と表示される。postfixを入れる
この辺は、googleで検索して入れてくださいな。postfixの設定説明だけで、日が暮れてしまう。gitと言うなのユーザーを作成
sudo adduser --disabled-login --gecos 'GitLab' gitGitlab専用ユーザーと思ってくださいな
GitLab shellの設定など
cd /home/git sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-shell.git -b v1.8.0 cd gitlab-shell sudo -u git -H cp config.yml.example config.yml sudo -u git -H vim config.yml
config.ymlを開くと、gitlab_urlの項目を、環境に合わせた名前に変更。
# GitLab user. git by default user: git # Url to gitlab instance. Used for api calls. Should end with a slash. #gitlab_url: "http://localhost/" gitlab_url: "http://gitlab.kaoken.net/" #timeout 30 timeout 120
私の場合は、gitlab.kaoken.net としました。Apache(プロクシ)経由で今後アクセスできるように!
“timeout”については、余裕をもって120秒にしました。
sudo -u git -H ./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 -print0 | xargs -0 chmod g+s: 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 -print0 | xargs -0 chmod g+s: OK
Mysql(データーベース)の初期設定
Mysqlは既に入っている物とします。mysqlユーザーとして”git“を作っておきます。
その後”gitlabhq_production“データーベスを作り、全ての権限をgitに与えておいてください。ユーザー作成、DB作成については、ググってください。
GitLabの設定の設定など
cd /home/git
移動後、gitlabをいれます。このとき、ダウンロードにしばらく時間がかかります。
sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-ce.git -b 6-6-stable gitlab cd /home/git/gitlab
現時点で最新版の6.6.5をコピーし、そして移動。
sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml sudo -u git -H vim config/gitlab.yml
gitlab.ymlファイルの”host”は、Gitlab shellのconfig.ymlと同じく”gitlab.kaoken.net”とした。
“email_from”、”support_email”の項目は各環境に合わせて変更。
# ↑↑ 以下省略 ↓↓ ## GitLab 設定 gitlab: ## Webサーバーの設定(注:ホストはFQDN、http://を含まず) # host: localhost port: 80 host: gitlab.kaoken.net https: false # ↑↑ 以下省略 ↓↓ # email_from: gitlab@localhost # support_email: support@localhost email_from: gitlab@kaoken.net support_email: support@kaoken.netその後一気に下記を実行
sudo chown -R git log/ sudo chown -R git tmp/ sudo chmod -R u+rwX log/ sudo chmod -R u+rwX tmp/ sudo -u git -H mkdir /home/git/gitlab-satellites sudo -u git -H mkdir tmp/pids/ sudo -u git -H mkdir tmp/sockets/ sudo chmod -R u+rwX tmp/pids/ sudo chmod -R u+rwX tmp/sockets/ sudo -u git -H mkdir public/uploads sudo chmod -R u+rwX public/uploads sudo -u git -H cp config/unicorn.rb.example config/unicorn.rb sudo -u git -H vim config/unicorn.rbunicorn.rbファイルの”listen”項目のポート番号を3000にするだけ
#listen "127.0.0.1:8080", :tcp_nopush => true listen "127.0.0.1:3000", :tcp_nopush => true下記”user.email”のメールアドレスの’kaoken.net’は各自の環境に合わせて変更
sudo -u git -H cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb sudo -u git -H git config --global user.name "GitLab" sudo -u git -H git config --global user.email "gitlab@kaoken.net" sudo -u git -H git config --global core.autocrlf input sudo -u git cp config/database.yml.mysql config/database.yml sudo -u git -H vim config/database.yml
database.ymlファイルの”password”の項目のパスワードを各自設定したパスを入力
# # PRODUCTION # production: adapter: mysql2 encoding: utf8 reconnect: false database: gitlabhq_production pool: 10 username: git password: "パスワードを入力"database.ymlファイルの設定終了後
gemのインストール
cd /home/git/gitlab sudo -u git -H bundle install --deployment --without development test postgres aws
設定&インストールなどで、しばし、待つ・・・・
Your bundle is complete!
Gems in the groups development, test, postgres and aws were not installed.
It was installed into ./vendor/bundle
Post-install message from haml:
HEADS UP! Haml 4.0 has many improvements, but also has changes that may break
your application:
* Support for Ruby 1.8.6 dropped
* Support for Rails 2 dropped
* Sass filter now always outputs <style> tags
* Data attributes are now hyphenated, not underscored
* html2haml utility moved to the html2haml gem
* Textile and Maruku filters moved to the haml-contrib gem
For more info see:
http://rubydoc.info/github/haml/haml/file/CHANGELOG.md
Post-install message from httparty:
When you HTTParty, you must party hard!
上記のようになればOK!Gems in the groups development, test, postgres and aws were not installed.
It was installed into ./vendor/bundle
Post-install message from haml:
HEADS UP! Haml 4.0 has many improvements, but also has changes that may break
your application:
* Support for Ruby 1.8.6 dropped
* Support for Rails 2 dropped
* Sass filter now always outputs <style> tags
* Data attributes are now hyphenated, not underscored
* html2haml utility moved to the html2haml gem
* Textile and Maruku filters moved to the haml-contrib gem
For more info see:
http://rubydoc.info/github/haml/haml/file/CHANGELOG.md
Post-install message from httparty:
When you HTTParty, you must party hard!
DBの初期化など
sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production
This will create the necessary database tables and seed the database.
You will lose any previous data stored in the database.
Do you want to continue (yes/no)?yes
以下省略
Administrator account created:
login………admin@local.host
password……5iveL!fe
上記メッセージが出てきて、ここで”yes”と入力You will lose any previous data stored in the database.
Do you want to continue (yes/no)?yes
以下省略
Administrator account created:
login………admin@local.host
password……5iveL!fe
正常に終了すると、ログインとパスワードを返す。
起動スクリプトの設定
sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab sudo chmod +x /etc/init.d/gitlab sudo update-rc.d gitlab defaults 21
logrotateの設定
sudo cp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab
アプリケーションステータスの確認
sudo cp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab
System information System: Ubuntu 13.10 Current User: git Using RVM: no Ruby Version: 2.0.0p299 Gem Version: 2.0.7 Bundler Version:1.5.3 Rake Version: 10.1.1 GitLab information Version: 6.6.5 Revision: ad5e5b5 Directory: /home/git/gitlab DB Adapter: mysql2 URL: http://localhost HTTP Clone URL: http://localhost/some-project.git SSH Clone URL: git@localhost:some-project.git Using LDAP: no Using Omniauth: no GitLab Shell Version: 1.8.0 Repositories: /home/git/repositories/ Hooks: /home/git/gitlab-shell/hooks/ Git: /usr/bin/g
gitlabの実行
sudo service gitlab start
何事もなければ、実行される。
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production
入力後
Checking GitLab … Finished
これが出ればとりあえず、一安心。Apacheの設定
まずは、アパッチにプロクシモジュールをしようできるようにする。sudo a2enmod proxy sudo a2enmod proxy_http sudo vim /etc/apache2/sites-available/gitlab.conf
gitlab用にプロクシ設定をする。
<VirtualHost *:80> ServerName gitlab.kaoken.net:80 DocumentRoot /home/git/gitlab/public # ProxyTimeout 300 ProxyPass / http://localhost:3000/ ProxyPassReverse / http://localhost:3000/ ProxyPreserveHost On # CustomLog /home/git/gitlab/log/apache_access.log combined # ErrorLog /home/git/gitlab/log/apache_error.log </VirtualHost>
この辺の設定は、各サーバによって違うのでがんばってくれ!(-.☆
sudo a2ensite gitlab sudo service apache2 restart
はぃ~~、これでgitlabが見られるようになりました。 http://gitlab.kaoken.cg0.xyz
おつかれさまぁ~