Last active
August 29, 2015 14:00
-
-
Save ruo91/11204183 to your computer and use it in GitHub Desktop.
How to install own private git server on Ubuntu 12.04 LTS
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
How to install own private git server on Ubuntu 12.04 LTS | |
1. 필요 패키지 설치 | |
root@ruo91:~# apt-get install -y build-essential zlib1g-dev libyaml-dev libssl-dev libgdbm-dev \ | |
libreadline-dev libncurses5-dev libffi-dev curl git-core openssh-server redis-server \ | |
checkinstall libxml2-dev libxslt1-dev libcurl4-openssl-dev libicu-dev | |
2. Ruby 설치 | |
기존 패키지 방식으로 설치시 버전이 낮으므로 최신버전으로 함. | |
make install시 SSH 원격이 끊어질수 있으므로 tmux나 screen으로 세션을 유지하는걸 추천. | |
root@ruo91:~# wget ftp://ftp.ruby-lang.org/pub/ruby/2.1/ruby-2.1.1.tar.gz | |
root@ruo91:~# cd ruby-2.1.1 | |
root@ruo91:~# ./configure | |
root@ruo91:~# make ; make install | |
- bundler 설치 | |
root@ruo91:~# gem install bundler --no-ri --no-rdoc | |
3. git 계정 생성 | |
root@ruo91:~# adduser --disabled-login --gecos 'GitLab' git | |
4. GitLab Shell 설치 | |
root@ruo91:~# cd /home/git | |
root@ruo91:~# sudo -u git -H git clone https://github.com/gitlabhq/gitlab-shell.git | |
root@ruo91:~# cd gitlab-shell | |
root@ruo91:~# sudo -u git -H cp config.yml.example config.yml | |
config.yml을 에디터로 열어 gitlab_url 부분에 git 서버로 사용할 도메인으로 변경 | |
root@ruo91:~# nano config.yml | |
gitlab_url: "http://git.yongbok.net/" | |
설치 시작. | |
root@ruo91:~# sudo -u git -H ./bin/install | |
5. Data Base 설치 | |
선호하는 RDBMS를 설치 | |
root@ruo91:~# apt-get install -y mysql-server mysql-client libmysqlclient-dev | |
- gitlab용 데이터베이스 계정을 생성 | |
root@ruo91:~# mysql -u root -p | |
mysql> CREATE USER 'gitlab'@'localhost' IDENTIFIED BY '비밀번호'; | |
mysql> CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`; | |
mysql> GRANT SELECT, LOCK TABLES, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO 'gitlab'@'localhost'; | |
mysql> exit; | |
6. GitLab 설치 | |
root@ruo91:~# cd /home/git | |
root@ruo91:~# sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-ce.git gitlab | |
root@ruo91:~# cd /home/git/gitlab | |
root@ruo91:~# sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml | |
config/gitlab.yml를 에디터로 열어 웹서버 부분의 host를 수정 | |
root@ruo91:~# sudo -u git -H nano config/gitlab.yml | |
## Web server settings (note: host is the FQDN, do not include http://) | |
host: git.yongbok.net | |
port: 80 | |
https: false | |
- 권한 및 설정파일 복사 | |
root@ruo91:~# cd /home/git/gitlab | |
root@ruo91:~# sudo chown -R git {log,tmp} | |
root@ruo91:~# sudo chmod -R u+rwX {log,tmp} | |
root@ruo91:~# sudo -u git -H mkdir -p {/home/git/gitlab-satellites,tmp/pids,tmp/sockets,public/uploads} | |
root@ruo91:~# sudo chmod -R u+rwX {tmp/pids,tmp/sockets,public/uploads} | |
root@ruo91:~# sudo -u git -H cp config/unicorn.rb.example config/unicorn.rb | |
root@ruo91:~# sudo -u git -H git config --global user.name "GitLab" | |
root@ruo91:~# sudo -u git -H git config --global user.email "gitlab@localhost" | |
root@ruo91:~# sudo -u git -H git config --global core.autocrlf input | |
root@ruo91:~# sudo -u git -H cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb | |
- 데이터베이스 설정 | |
root@ruo91:~# sudo -u git cp config/database.yml.mysql config/database.yml | |
root@ruo91:~# sudo -u git -H nano config/database.yml | |
# | |
# PRODUCTION | |
# | |
production: | |
adapter: mysql2 | |
encoding: utf8 | |
reconnect: false | |
database: gitlabhq_production | |
pool: 10 | |
username: gitlab | |
password: "gitlab용 데이터베이스 비밀번호" | |
# host: localhost | |
# socket: /tmp/mysql.sock | |
root@ruo91:~# sudo -u git -H chmod o-rwx config/database.yml | |
- production외에 필요 없는것들은 제외하고 설치 | |
root@ruo91:~# cd /home/git/gitlab | |
root@ruo91:~# sudo -u git -H bundle install --deployment --without development test postgres aws | |
root@ruo91:~# 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 | |
아래와 같이 gitlab의 관리자 계정 정보가 나옴. 기억 해두자. | |
Administrator account created: | |
[email protected] | |
password......5iveL!fe | |
시스템 부팅시 Gitlab이 자동 시작 되도록 설정. | |
root@ruo91:~# cp lib/support/init.d/gitlab /etc/init.d/gitlab | |
root@ruo91:~# chmod +x /etc/init.d/gitlab | |
root@ruo91:~# update-rc.d gitlab defaults 21 | |
로그가 로테이트 되도록 설정 | |
root@ruo91:~# cp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab | |
- Gitlab 정보 확인 | |
아래처럼 에러 없이 잘 나왔다면 성공임. | |
root@ruo91:~# sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production | |
System information | |
System: Ubuntu 12.04 | |
Current User: git | |
Using RVM: no | |
Ruby Version: 2.1.1p76 | |
Gem Version: 2.2.2 | |
Bundler Version:1.6.2 | |
Rake Version: 10.1.1 | |
Sidekiq Version:2.17.0 | |
GitLab information | |
Version: 6.8.0 | |
Revision: bf855d1 | |
Directory: /home/git/gitlab | |
DB Adapter: mysql2 | |
URL: http://git.yongbok.net | |
HTTP Clone URL: http://git.yongbok.net/some-project.git | |
SSH Clone URL: [email protected]:some-project.git | |
Using LDAP: no | |
Using Omniauth: no | |
GitLab Shell | |
Version: 1.9.3 | |
Repositories: /home/git/repositories/ | |
Hooks: /home/git/gitlab-shell/hooks/ | |
Git: /usr/bin/git | |
- Gitlab 시작 | |
root@ruo91:~# service gitlab start | |
- assets 컴파일 | |
root@ruo91:~# sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production | |
I, [2014-04-23T13:36:20.098589 #1648] INFO -- : Writing /home/git/gitlab/public/assets/Storage-UI-163cdd9142fca6baec4186e689866f40.PNG | |
I, [2014-04-23T13:36:20.125894 #1648] INFO -- : Writing /home/git/gitlab/public/assets/authbuttons/github_32-16a667c9bdb8fe6f235ce8e310bcac7b.png | |
I, [2014-04-23T13:36:20.148857 #1648] INFO -- : Writing /home/git/gitlab/public/assets/authbuttons/github_64-ddee7a4304adaca3c3c6ea5e33c3ffb2.png | |
I, [2014-04-23T13:36:20.173221 #1648] INFO -- : Writing /home/git/gitlab/public/assets/authbuttons/google_32-31ee2fbb097b0ecb0ed459290adeeb78.png | |
I, [2014-04-23T13:36:20.192519 #1648] INFO -- : Writing /home/git/gitlab/public/assets/authbuttons/google_64-a3b0648f8e29ad45c4009e9378e9d9c2.png | |
........... | |
................. Blah blah.... | |
7. Nginx 설치 | |
root@ruo91:~# apt-get -y install nginx | |
root@ruo91:~# cd /home/git/gitlab | |
root@ruo91:~# cp lib/support/nginx/gitlab /etc/nginx/sites-available/gitlab | |
root@ruo91:~# ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab | |
server_name을 적절하게 변경한다. | |
root@ruo91:~# nano /etc/nginx/sites-available/gitlab | |
server { | |
listen *:80 default_server; # e.g., listen 192.168.1.1:80; In most cases *:80 is a good idea | |
server_name git.yongbok.net; # e.g., server_name source.example.com; | |
server_tokens off; # don't show the version number, a security best practice | |
root /home/git/gitlab/public; | |
8. 테스트 | |
지정한 도메인으로 접속하면 gitlab 페이지를 볼수있다. | |
gitlab setup시 출력 되었던 관리자 계정 정보를 통해 로그인 하면 끝. | |
login : [email protected] | |
password : 5iveL!fe | |
- 다른 사용자도 사용 가능하게 하려면? | |
/home/git/gitlab/config/gitlab.yml 파일을 열어 | |
Users management 부분에 signup_enabled: true 옵션과, signin_enabled: true 을 사용하면 됩니다. | |
root@ruo91:~# nano /home/git/gitlab/config/gitlab.yml | |
## Users management | |
# default: false - Account passwords are not sent via the email if signup is enabled. | |
signup_enabled: true | |
# | |
# default: true - If set to false, standard login form won't be shown on the sign-in page | |
signin_enabled: true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment