gitlab-sei.txt 12 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420

Gitlab
======


Install postgresql

.. code-block::

    sudo yum localinstall http://yum.postgresql.org/9.3/redhat/rhel-6-x86_64/pgdg-centos93-9.3-1.noarch.rpm -y
    sudo yum install postgresql93 postgresql93-devel postgresql93-libs postgresql93-server -y

Initialize database

.. code-block::

    sudo service postgresql-9.3 initdb

Start postgresql with the system

.. code-block::

    sudo chkconfig postgresql-9.3 on

Start postgresql

.. code-block::

    sudo service postgresql-9.3 start


Add EPEL repository

.. code-block::

    sudo yum  -y install wget vim
    sudo wget -O /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 https://www.fedoraproject.org/static/0608B895.txt
    sudo rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

Add PUIAS Computational repository (necessary to download some exclusive dependencies)

.. code-block::

    sudo rpm -Uvh https://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
    sudo wget -O /etc/yum.repos.d/PUIAS_6_computational.repo https://gitlab.com/gitlab-org/gitlab-recipes/raw/master/install/centos/PUIAS_6_computational.repo
    sudo wget -O /etc/pki/rpm-gpg/RPM-GPG-KEY-puias http://springdale.math.ias.edu/data/puias/6/x86_64/os/RPM-GPG-KEY-puias
    sudo rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-puias
    
Enable PUIAS repository

.. code-block::

    sudo yum -y install yum-utils
    sudo yum-config-manager --enable epel --enable PUIAS_6_computational
    
Update all packages, and install some addtional packages

.. code-block::

    sudo yum -y update
    sudo yum -y groupinstall 'Development Tools'
    sudo yum -y install readline readline-devel ncurses-devel gdbm-devel glibc-devel tcl-devel openssl-devel curl-devel expat-devel db4-devel byacc sqlite-devel libyaml libyaml-devel libffi libffi-devel libxml2 libxml2-devel libxslt libxslt-devel libicu libicu-devel system-config-firewall-tui redis sudo wget crontabs logwatch logrotate perl-Time-HiRes

Add redis to start with the system, and start it

.. code-block::

    sudo chkconfig redis on
    sudo service redis start

Install the mail server ``postfix``
    
.. code-block::

    sudo yum -y install postfix

Remove any git package that you may had install

.. code-block::

    sudo yum -y remove git

Install git 1.9.0 and its dependencies
    
.. code-block::

    sudo yum -y install zlib-devel perl-CPAN gettext curl-devel expat-devel gettext-devel openssl-devel
    sudo mkdir /tmp/git && cd /tmp/git
    sudo wget https://git-core.googlecode.com/files/git-1.9.0.tar.gz
    sudo tar xzf git-1.9.0.tar.gz
    cd git-1.9.0/
    sudo ./configure
    sudo make
    sudo make prefix=/usr/local install

Remove any ruby installed before, and download ``ruby-2.0.0-p451``

.. code-block::

    sudo yum remove ruby -y
    mkdir /tmp/ruby && cd /tmp/ruby
    sudo curl --progress ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p451.tar.gz | tar xz
    
*NOTE:*

    If you can't reach the host from ``ruby-2.0.0-p451``, you also can try this command: sudo curl --progress http://cache.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p451.tar.bz2 | tar xj
    
Install ruby 2.0.0

.. code-block::

    cd ruby-2.0.0-p451
    ./configure --disable-install-rdoc
    make
    sudo make prefix=/usr/local install
    
Install the bundler gem

.. code-block::

    sudo /usr/local/bin/gem install bundler --no-ri --no-rdoc

Create the user ``git`` to give the rights permissions to Gitlab application

.. code-block::

    sudo adduser --system --shell /bin/bash --comment 'GitLab' --create-home --home-dir /home/git/ git
    
Clone the gitlab-shell repository

.. code-block::

    sudo su
    cd /home/git
    sudo -u git -H /usr/local/bin/git clone https://gitlab.com/gitlab-org/gitlab-shell.git
    cd gitlab-shell/
    /usr/local/bin/git reset --hard v1.9.3

Configure the host name and install gitlab-shell

.. code-block::

    sudo -u git -H cp config.yml.example config.yml
    sudo -u git -H vim config.yml
    sudo -u git -H /usr/local/bin/ruby ./bin/install
    restorecon -Rv /home/git/.ssh
 
Create database ``gitlabhq_production``, and if you're going to develop to gitlab also create ``gitlabhq_development`` and ``gitlabhq_test``

.. code-block::

    sudo -u postgres psql -d template1
    CREATE USER git;
    CREATE DATABASE gitlabhq_production OWNER git;
    CREATE DATABASE gitlabhq_development OWNER git;
    CREATE DATABASE gitlabhq_test OWNER git;
    \q

Add the git user in pg_hba.conf to grant the permissions

.. code-block::

    vim /var/lib/pgsql/9.3/data/pg_hba.conf

The end of file should seems like the piece of code below, if you're following this whole tutorial you must already have the ``colab`` and ``postgres`` set up, if you are not set up ``postgres`` and ``git`` users.

.. code-block::

    # TYPE  DATABASE        USER            ADDRESS                 METHOD
    # "local" is for Unix domain socket connections only
    local   all             postgres                                     peer
    local   all             git                                     trust
    # IPv4 local connections:
    host    all             postgres             127.0.0.1/32            ident
    host    all             git             127.0.0.1/32            trust
    # IPv6 local connections:
    host    all             postgres             ::1/128                 ident
    host    all             git             ::1/128                 trust

.. code-block::

    [ESC]:wq!

Restart postgresql

.. code-block::

    service postgresql-9.3 restart

Clone and configure the ``gitlab`` repository

.. code-block::

    cd /home/git
    sudo -u git -H /usr/local/bin/git clone https://github.com/colab-community/gitlabhq.git -b 7-0-stable gitlab
    cd /home/git/gitlab
    sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml
    chown -R git {log,tmp}
    chmod -R u+rwX {log,tmp}
    sudo -u git -H mkdir /home/git/gitlab-satellites
    chmod u+rwx,g+rx,o-rwx /home/git/gitlab-satellites
    chmod -R u+rwX tmp/{pids,sockets}
    chmod -R u+rwX public/uploads
    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

Change the port you're using for gitlab, in this case we use 8090

.. code-block::

    sudo vim /home/git/gitlab/config/unicorn.rb
    
Change

.. code-block::

    listen "127.0.0.1:8080", :tcp_nopush => true

To

.. code-block::

    listen "127.0.0.1:8090", :tcp_nopush => true

.. code-block::

    [ESC]:wq!


Change defautl URL in gitlab-shell/config.yml

.. code-block::

    sudo vim /home/git/gitlab-shell/config.yml

Change the following line, From:

.. code-block::

    gitlab_url: "http://127.0.0.1:8090/gitlab"

To, using the your IP:

.. code-block::

    gitlab_url: "http://127.0.0.1:8090/"


Configure git and database

.. code-block::

    sudo -u git -H /usr/local/bin/git config --global user.name "GitLab"
    sudo -u git -H /usr/local/bin/git config --global user.email "gitlab@localhost"
    sudo -u git -H /usr/local/bin/git config --global core.autocrlf input
    sudo -u git cp config/database.yml.postgresql config/database.yml
    sudo -u git -H chmod o-rwx config/database.yml

Configure the bundle

.. code-block::

    cd /home/git/gitlab
    sudo -u git -H /usr/local/bin/bundle config build.pg --with-pg-config=/usr/pgsql-9.3/bin/pg_config
    sudo -u git -H /usr/local/bin/bundle config build.nokogiri --use-system-libraries



Edit sudores file to let ``bundle``, ``git`` and ``gem`` execute in sudo mode. 

*NOTE:*

    The path ``/usr/bin:/usr/pgsql-9.3/bin/`` will be only in this file if you installed postgresql before, if you didn't just remove it from those lines.

.. code-block::

    sudo vim /etc/sudoers

Change the line

.. code-block::

    Defaults    secure_path = /sbin:/bin:/usr/sbin:/usr/bin:/usr/pgsql-9.3/bin/
    
To

.. code-block::

    Defaults    secure_path = /sbin:/bin:/usr/sbin:/usr/bin:/usr/pgsql-9.3/bin/:/usr/local/bin/
    
.. code-block::

    [ESC]:wq!

Give the bundle install to install the required gems, if you are going to devel to gitlab change the env to ``RAILS_ENV=development``

.. code-block::

    sudo -u git -H /usr/local/bin/bundle install --deployment --without development test mysql aws
    sudo -u git -H /usr/local/bin/bundle exec rake gitlab:setup RAILS_ENV=production

Type ``yes`` to create the database tables

*NOTE:*
    
    Admin login and password -- login: admin@local.host -- password: 5iveL!fe

Add gitlab to start with system, this step is not require to development mode

.. code-block::

    wget -O /etc/init.d/gitlab https://gitlab.com/gitlab-org/gitlab-recipes/raw/master/init/sysvinit/centos/gitlab-unicorn
    chmod +x /etc/init.d/gitlab
    chkconfig --add gitlab
    chkconfig gitlab on
    cp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab
    service gitlab start
    
Compile the asstes, to development change the env to ``RAILS_ENV=development``

.. code-block::

    sudo -u git -H /usr/local/bin/bundle exec rake assets:precompile RAILS_ENV=production

Change group permissions

    chmod g+rx /home/git/
    

Altering the line 

.. code-block::

  env:
    enabled: true

to

.. code-block::

  env:
    enabled: false

Change these lines  :

.. code-block::
  issues_tracker:
    # redmine:
    #   title: "Redmine"
    #   ## If not nil, link 'Issues' on project page will be replaced with this
    #   ## Use placeholders:
    #   ##  :project_id        - GitLab project identifier
    #   ##  :issues_tracker_id - Project Name or Id in external issue tracker
    #   project_url: "http://redmine.sample/projects/:issues_tracker_id"
    #
    #   ## If not nil, links from /#\d/ entities from commit messages will replaced with this
    #   ## Use placeholders:
    #   ##  :project_id        - GitLab project identifier
    #   ##  :issues_tracker_id - Project Name or Id in external issue tracker
    #   ##  :id                - Issue id (from commit messages)
    #   issues_url: "http://redmine.sample/issues/:id"
    #
    #   ## If not nil, links to creating new issues will be replaced with this
    #   ## Use placeholders:
    #   ##  :project_id        - GitLab project identifier
    #   ##  :issues_tracker_id - Project Name or Id in external issue tracker
    #   new_issue_url: "http://redmine.sample/projects/:issues_tracker_id/issues/new"
    #
    # jira:
    #   title: "Atlassian Jira"
    #   project_url: "http://jira.sample/issues/?jql=project=:issues_tracker_id"
    #   issues_url: "http://jira.sample/browse/:id"
    #   new_issue_url: "http://jira.sample/secure/CreateIssue.jspa"

to

.. code-block::


  issues_tracker:
     redmine:
       title: "Redmine"
       ## If not nil, link 'Issues' on project page will be replaced with this
       ## Use placeholders:
       ##  :project_id        - GitLab project identifier
       ##  :issues_tracker_id - Project Name or Id in external issue tracker
       project_url: "http://redmine.sample/projects/:issues_tracker_id"
    
       ## If not nil, links from /#\d/ entities from commit messages will replaced with this
       ## Use placeholders:
       ##  :project_id        - GitLab project identifier
       ##  :issues_tracker_id - Project Name or Id in external issue tracker
       ##  :id                - Issue id (from commit messages)
       issues_url: "http://redmine.sample/issues/:id"
    
       ## If not nil, links to creating new issues will be replaced with this
       ## Use placeholders:
       ##  :project_id        - GitLab project identifier
       ##  :issues_tracker_id - Project Name or Id in external issue tracker
       new_issue_url: "http://redmine.sample/projects/:issues_tracker_id/issues/new"
    
    # jira:
    #   title: "Atlassian Jira"
    #   project_url: "http://jira.sample/issues/?jql=project=:issues_tracker_id"
    #   issues_url: "http://jira.sample/browse/:id"
    #   new_issue_url: "http://jira.sample/secure/CreateIssue.jspa"

*NOTE:*
	 Change all redmine.sample to your redmine server 


Restart gitlab

.. code-block::

    sudo service gitlab restart

*NOTE:*

    You can access gitlab in this url: `http://localhost:8090/gitlab, but it won't log-in without the REMOTE_USER provided by colab