Project

General

Profile

Support #584

Install GitLab 7.8 on FreeBSD

Added by Daniel Curtis about 9 years ago. Updated almost 9 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Source Code Management
Target version:
Start date:
09/21/2014
Due date:
% Done:

100%

Estimated time:
2.00 h
Spent time:

Description

Setting up the Environment

  • Start by making sure everything is up to date:
    pkg update && pkg upgrade
    portsnap fetch extract
    pkg2ng
    
  • Install portmaster:
    cd /usr/ports/ports-mgmt/portmaster
    make install clean
    
  • Install a few dependencies
    portmaster devel/git databases/redis lang/ruby21 security/krb5 devel/icu textproc/libxml2 textproc/libxslt lang/python2 shells/bash security/sudo lang/gcc48 devel/gmake devel/autoconf devel/automake devel/libtool devel/bison devel/readline textproc/libyaml databases/sqlite3 databases/gdbm devel/cmake databases/postgresql-libpqxx sysutils/rubygem-bundler devel/libgit2 security/libssh2
    
  • Add the GitLab user
    pw add user -n git -m -s /usr/local/bin/bash -c "GitLab" 
    

Install Redis

  • Start Redis and enable it to start at boot:
    echo 'redis_enable="YES"' >> /etc/rc.conf
    service redis start
    
  • Add the following to /usr/local/etc/redis.conf:
    unixsocket /var/run/redis/redis.sock
    unixsocketperm 770
    
  • Add git to the redis group:
    pw usermod git -G redis
    

Install MariaDB 5.5

  • This environment will be setup with MariaDB 5.5 for its MySQL server:
    portmaster databases/mariadb55-server databases/mariadb55-client
    
  • Ensure you have MySQL version 5.5.14 or later
    mysql --version
    
  • Start and enable MySQL at boot:
    echo 'mysql_enable="YES"' >> /etc/rc.conf
    service mysql-server start
    
  • Secure your installation:
    mysql_secure_installation
    
  • Login to MySQL
    mysql -u root -p
    
    1. Create a user for GitLab
      CREATE USER 'git'@'localhost' IDENTIFIED BY 'SuperSecretPassword';
      

      NOTE: Change SuperSecretPassword to what ever password desired
    2. Ensure you can use the InnoDB engine which is necessary to support long indexes.
      SET storage_engine=INNODB;
      

      NOTE: If this fails, check your MySQL config files (e.g. `/etc/mysql/*.cnf`, `/etc/mysql/conf.d/*`) for the setting "innodb = off"
    3. Create the GitLab production database
      CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;
      
    4. Grant the GitLab user necessary permissions on the table.
      GRANT SELECT, LOCK TABLES, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO 'git'@'localhost';
      
    5. Quit the database session
      quit
      
  • Try connecting to the new database with the new user
    sudo -u git -H mysql -u git -p -D gitlabhq_production
    
    • Type the MySQL git password set earlier
      SuperSecretPassword
      
  • You should now see a mysql> prompt, quit the database session:
    quit
    

WARNING: GitLab suggests using PostgreSQL for the database used; this is due to the inability to support case-sensitive table names. Since my use case is small, I will not need case-sensitivity, and will use a MySQL derivative instead.

Install GitLab 7.8

  • Change to the git user home directory and download GitLab 7.8
    su - git
    cd
    git clone https://gitlab.com/gitlab-org/gitlab-ce.git -b 7-8-stable gitlab
    
  • Create a config file
    cd /home/git/gitlab
    cp config/gitlab.yml.example config/gitlab.yml
    
  • Edit the gitlat config file:
    vi config/gitlab.yml
    
    • Change the gitlab: host: to git.example.com
    • If using https change the gitlab: port: from 80 to 443
    • Change the git: bin_path: to /usr/local/bin/git
    • Change the satellites: path: to /usr/home/git/gitlab-satellites/
    • Change the gitlab_shell: path: to /usr/home/git/gitlab-shell/
    • Change the gitlab_shell: repos_path: to /usr/home/git/repositories/
    • Change the gitlab_shell: hooks_path: to /usr/home/git/gitlab-shell/hooks/
  • Create a unicorn.rb file:
    cp config/unicorn.rb.example config/unicorn.rb
    
  • Create a rack_attack.rb file:
    cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb
    
  • Create a database configuration file:
    cp config/database.yml.mysql config/database.yml
    
  • Configure the GitLab system user:
    git config --global user.name "GitLab" 
    git config --global user.email "example@example.com" 
    
  • Setup the directories and permissions:
    chown -R git log/
    chown -R git tmp/
    chmod -R u+rwX log/
    chmod -R u+rwX tmp/
    chmod -R u+rwX tmp/pids/
    chmod -R u+rwX tmp/sockets/
    chmod -R u+rwX  public/uploads
    
  • Create the gitlab-satellites:
    mkdir /home/git/gitlab-satellites
    chmod u+rwx,g=rx,o-rwx /home/git/gitlab-satellites
    
  • Configure Redis connection settings
    cp config/resque.yml.example config/resque.yml
    
  • Configure bundler to build nokogiri using system libraries :
    bundle config build.nokogiri "--use-system-libraries" 
    

    NOTE: This is required to prevent an error building nokogiri during install
  • Configure bundler to build rugged using system libraries :
    bundle config build.rugged "--use-system-libraries" 
    

    NOTE: This is required to prevent an error building rugged during install
  • Install GitLab gems
    bundle install --deployment --without development test postgresql aws
    

Install GitLab Shell

  • Run the installation task for gitlab-shell (replace `REDIS_URL` if needed)
    bundle exec rake gitlab:shell:install[v2.5.4] REDIS_URL=redis://localhost:6379 RAILS_ENV=production
    

By default, the gitlab-shell config is generated from your main gitlab config.

  • NOTE: When using GitLab with HTTPS please change the following:
    1. Provide paths to the certificates under `ca_file` and `ca_path` options.
    2. The `gitlab_url` option must point to the https endpoint of GitLab.
    3. In case you are using self signed certificate set `self_signed_cert` to `true`.
  • You can review (and modify) the gitlab-shell config as follows:
    vi /home/git/gitlab-shell/config.yml
    
  • Initialize Database and Activate Advanced Features
    bundle exec rake gitlab:setup RAILS_ENV=production
    
  • Verify that the install worked:
    bundle exec rake gitlab:env:info RAILS_ENV=production
    
  • Precompile the assets used by GitLab:
    bundle exec rake assets:precompile RAILS_ENV=production
    
  • Exit out of the GitLab user, back into the root account:
    exit
    
  • Create an init script
    cp /usr/home/git/gitlab/lib/support/init.d/gitlab /usr/local/etc/rc.d/gitlab
    
  • Start GitLab
    service gitlab start
    
  • Enable GitLab to start at boot
    echo 'gitlab_enable="YES"' >> /etc/rc.conf
    

Running GitLab on Nginx

Running GitLab from an nginx server using phusion passenger is simple.

  • Install nginx:
    portmaster www/nginx
    
  • Copy the GitLab nginx config into the nginx directory
    cp /usr/home/git/gitlab/lib/support/nginx/gitlab /usr/local/etc/nginx/gitlab.conf
    
    • Change the hostname: git.example.com
    • Change the proxy_pass to the correct address and port: http://127.0.0.1:8080
  • Add the following piece of code in /usr/local/etc/nginx/nginx.conf, before the last “}":
    include /usr/local/etc/nginx/gitlab.conf;
    
  • Prepare the directories needed by nginx:
    mkdir -p /var/tmp/nginx /var/log/nginx
    chown -R www: /var/log/nginx /var/tmp/nginx
    
  • Start and enable nginx at boot:
    echo 'nginx_enable="YES"' >> /etc/rc.conf
    service nginx start
    
  • Default username and password:
    • user: root
    • pass: 5iveL!fe

Running GitLab on Apache

Running GitLab from an apache server using phusion passenger is simple.

  • Edit the virtual host definition and add/modify it according to your needs:
    vi /usr/local/etc/apache24/Vhosts/git.example.com.conf
    
    • And add/edit the following virtual host definition:
      <VirtualHost *:80>
        DocumentRoot "/home/git/gitlab/public" 
        ServerName git.example.com 
        ErrorLog "/var/log/git.example.com-error_log" 
        CustomLog "/var/log/git.example.com-access_log" common
        PassengerRuby /usr/local/bin/ruby
      
        <Directory /home/git/gitlab/public>
            Options -MultiViews
            AllowOverride All
            Order allow,deny
            Allow from all
            Require all granted
        </Directory>
      </VirtualHost>
      
  • Restart apache:
    service apache24 restart
    
  • Start and enable apache24 at boot:
    echo 'apache24_enable="YES"' >> /etc/rc.conf
    service apache24 start
    

Resources

http://luizgustavo.pro.br/blog/2014/08/21/instalacao-gitlab-no-freebsd/
https://gitlab.com/gitlab-org/gitlab-ce/blob/7-8-stable/doc/install/installation.md
https://gitlab.com/gitlab-org/gitlab-ce/blob/7-8-stable/doc/install/database_mysql.md


Related issues

Copied from FreeBSD Administration - Support #532: Installing GitLab 7.6 on FreeBSDClosedDaniel Curtis09/21/2014

Actions
Copied to FreeBSD Administration - Support #624: Install GitLab 7.11 on FreeBSDClosedDaniel Curtis09/21/2014

Actions
#1

Updated by Daniel Curtis about 9 years ago

  • Copied from Support #532: Installing GitLab 7.6 on FreeBSD added
#2

Updated by Daniel Curtis about 9 years ago

  • Description updated (diff)
  • Status changed from New to In Progress
  • % Done changed from 0 to 10
#3

Updated by Daniel Curtis about 9 years ago

  • Description updated (diff)
#4

Updated by Daniel Curtis about 9 years ago

  • Description updated (diff)
  • % Done changed from 10 to 30
#5

Updated by Daniel Curtis about 9 years ago

  • Description updated (diff)
#6

Updated by Daniel Curtis about 9 years ago

  • Status changed from In Progress to Resolved
  • % Done changed from 30 to 100
#7

Updated by Daniel Curtis about 9 years ago

  • Description updated (diff)
#8

Updated by Daniel Curtis about 9 years ago

  • Status changed from Resolved to Closed
#9

Updated by Daniel Curtis almost 9 years ago

  • Description updated (diff)
#10

Updated by Daniel Curtis almost 9 years ago

  • Copied to Support #624: Install GitLab 7.11 on FreeBSD added

Also available in: Atom PDF