티스토리 뷰


apt-get으로 GitLab을 설치하면, nginx가 bundle로 따라와 실행된다.
난 Apache2를 기본 웹 서버 엔진으로 동작시키고 싶기 때문에, 그에 따른 해결책으로 아래와 같이 설정하였다.
자세한 것은 아래 링크를 참조하면 된다.
링크 : GitLab 공식페이지 Ubuntu 설치방법
 
 

GitLab 설치 준비


sudo apt-get install -y curl openssh-server ca-certificates postfix

 

GitLab CE 설치


curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
sudo apt-get install gitlab-ce

 

gitlab.rb 수정


external_url을 제외하고 모두 주석처리가 되어 있다.
필요한 것만 주석을 제거하면서 수정하면 된다.
(사실 rail에도 무엇인가 더 수정해야 할 것 같은데, 일단은 동작하니까 문제 발생하면 추가 수정하도록 한다.)

sudo vi /etc/gitlab/gitlab.rb

GITLAB_URL에는 외부로부터 접근하게되는 Domain Name을 적는다.

external_url 'http://GITLAB_URL'

gitlab_workhorse['listen_network'] = "tcp"
gitlab_workhorse['listen_addr'] = "127.0.0.1:8181"

web_server['external_users'] = ['www-data']

nginx['enable'] = false
sudo /opt/gitlab/embedded/bin/runsvdir-start &
sudo gitlab-ctl reconfigure

 

Apache2 – Module 추가


sudo a2enmod rewrite
sudo a2enmod proxy
sudo a2enmod proxy_http

 

Apache2 – Site 추가


먼저 apache에 적용할 site에 대한 정보를 작성한다.

sudo vi /etc/apache2/sites-available/GITLAB_URL.conf
<VirtualHost *:80>
    ServerName GITLAB_URL
    ServerSignature Off

    ProxyPreserveHost On

    # Ensure that encoded slashes are not decoded but left in their encoded state.
    AllowEncodedSlashes NoDecode

    <Location />
        # New authorization commands for apache 2.4 and up
        # http://httpd.apache.org/docs/2.4/upgrading.html#access
        Require all granted

        #Allow forwarding to gitlab-workhorse
        ProxyPassReverse http://127.0.0.1:8181
        ProxyPassReverse http://GITLAB_URL/
    </Location>

    # Apache equivalent of nginx try files
    RewriteEngine on

    #Forward all requests to gitlab-workhorse except existing files like error documents
    RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f [OR]
    RewriteCond %{REQUEST_URI} ^/uploads/.*
    RewriteRule .* http://127.0.0.1:8181%{REQUEST_URI} [P,QSA,NE]

    # needed for downloading attachments
    DocumentRoot /opt/gitlab/embedded/service/gitlab-rails/public

    # Error Page
    ErrorDocument 404 /404.html
    ErrorDocument 422 /422.html
    ErrorDocument 500 /500.html
    ErrorDocument 502 /502.html
    ErrorDocument 503 /503.html

    # Log
    LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b" common_forwarded
    ErrorLog /var/log/apache2/GITLAB_URL_error.log
    CustomLog /var/log/apache2/GITLAB_URL_forwarded.log common_forwarded
    CustomLog /var/log/apache2/GITLAB_URL_access.log combined env=!dontlog
    CustomLog /var/log/apache2/GITLAB_URL.log combined
</VirtualHost>

GITLAB_URL.conf 파일을 site로 추가하고, apache를 재시작한다.

sudo a2ensite GITLAB_URL.conf
sudo service apache2 restart

 

Test


http://GITLAB_URL에 접속하여, root 계정 비밀번호를 설정하면 끝이다.

댓글