Project

General

Profile

Support #814

Updated by Daniel Curtis almost 8 years ago

{{>toc}} 

 This is a guide on installing GitLab 8.5 with continuous integration on FreeBSD 10. 

 h2. Prepare the Environment 

 * Make sure the system is up to date: 
 <pre> 
 pkg update && pkg upgrade 
 </pre> 

 h2. Install PostgreSQL 

 * Initialize, start, and enable postgresql at boot: 
 <pre> 
 echo 'postgresql_enable="YES"' >> /etc/rc.conf 
 service postgresql initdb 
 service postgresql start 
 </pre> 

 * Log in to postgresql user account 
 <pre> 
 su - pgsql 
 </pre> 

 * Connect to postgresql database 
 <pre> 
 psql -d template1 
 </pre> 
 #* Create a user for GitLab: 
 <pre> 
 CREATE USER git WITH PASSWORD 'SuperSecretPassword' CREATEDB SUPERUSER; 
 </pre> 
 #* Create the GitLab production database & grant all privileges on database 
 <pre> 
 CREATE DATABASE gitlabhq_production OWNER git encoding='UTF8'; 
 </pre> 
 #* Quit the database session 
 <pre> 
 \q 
 exit 
 </pre> 

 h2. Install Redis 

 * Install redis: 
 <pre> 
 pkg install redis 
 </pre> 

 * Back up the original Redis config file: 
 <pre> 
 cp /usr/local/etc/redis.conf /usr/local/etc/redis.conf.orig 
 </pre> 

 * Disable Redis listening on TCP by setting 'port' to 0 
 <pre> 
 sed -i '' -e 's/^port .*/port 0/' /usr/local/etc/redis.conf 
 </pre> 

 * Enable Redis socket 
 <pre> 
 echo 'unixsocket /usr/local/var/run/redis/redis.sock' >> /usr/local/etc/redis.conf 
 </pre> 

 * Grant permission to the socket to all members of the redis group 
 <pre> 
 echo 'unixsocketperm 770' >> /usr/local/etc/redis.conf 
 </pre> 

 * Create the directory which contains the socket 
 <pre> 
 mkdir -p /usr/local/var/run/redis 
 chown redis:redis /usr/local/var/run/redis 
 chmod 755 /usr/local/var/run/redis 
 </pre> 

 * Start and enable redis at boot: 
 <pre> 
 echo 'redis_enable="YES"' >> /etc/rc.conf 
 service redis start 
 </pre> 

 h2. Install GitLab 8 

 * Install gitlab: 
 <pre> 
 pkg install gitlab 
 </pre> 

 * Add git user to redis group 
 <pre> 
 pw groupmod redis -m git 
 </pre> 

 * Go to GitLab installation folder 
 <pre> 
 cd /usr/local/www/gitlab 
 </pre> 

 * Update GitLab config file, follow the directions at the top of the file 
 <pre> 
 vi config/gitlab.yml 
 </pre> 

 * Find number of cores 
 <pre> 
 sysctl hw.ncpu 
 </pre> 

 * Enable cluster mode if you expect to have a high load instance, set the number of workers to at least the number of cores: 
 <pre> 
 vi config/unicorn.rb 
 </pre> 

 * Configure Git global settings for git user: 
 <pre> 
 git config --global core.autocrlf input 
 </pre> 

 * Disable 'git gc --auto' because GitLab already runs 'git gc' when needed: 
 <pre> 
 git config --global gc.auto 0 
 </pre> 

 * Configure GitLab DB settings 
 <pre> 
 vi config/database.yml 
 </pre> 

 * Initialize database and activate advanced features: 
 <pre> 
 rake gitlab:setup RAILS_ENV=production 
 </pre> 
 *# Type *yes* to create the database tables. 
 *# When done you see _Administrator account created:_ 

 * Check if GitLab and its environment are configured correctly: 
 <pre> 
 rake gitlab:env:info RAILS_ENV=production 
 </pre> 

 * Compile Assets 
 <pre> 
 rake assets:precompile RAILS_ENV=production 
 </pre> 

 * Start and enable gitlab at boot: 
 <pre> 
 echo 'gitlab_enable="YES"' >> /etc/rc.conf 
 service gitlab start 
 </pre> 

 h2. Install Nginx 

 * Install nginx: 
 <pre> 
 pkg install nginx 
 </pre> 

 * Start and enable nginx at boot: 
 <pre> 
 echo 'nginx_enable="YES"' >> /etc/rc.conf 
 service nginx start 
 </pre> 

 * Create a configuration directory to make managing individual server blocks easier 
 <pre> 
 mkdir /usr/local/etc/nginx/conf.d 
 </pre> 

 * Edit the main nginx config file: 
 <pre> 
 vi /usr/local/etc/nginx/nginx.conf 
 </pre> 
 #* And strip down the config file and add the include statement at the end to make it easier to handle various server blocks: 
 <pre> 
 worker_processes    1; 
 error_log    /var/log/nginx-error.log; 

 events { 
     worker_connections    1024; 
 } 

 http { 
     include         mime.types; 
     default_type    application/octet-stream; 
     sendfile          on; 
     keepalive_timeout    65; 

     # Load config files from the /etc/nginx/conf.d directory 
     include /usr/local/etc/nginx/conf.d/*.conf; 
 } 
 </pre> 

 * Create the gitlab nginx config: 
 <pre> 
 vi /usr/local/etc/nginx/conf.d/gitlab.example.com.conf 
 </pre> 
 #* And add the following: 
 <pre> 
 upstream gitlab-workhorse { 
   server unix:/usr/local/www/gitlab/tmp/sockets/gitlab-workhorse.socket fail_timeout=0; 
 } 

 server { 
   listen 80; 
   server_name gitlab.example.com; 
   server_tokens off; 
   root /usr/local/www/gitlab/public; 
   access_log    /var/log/gitlab.example.com-access.log; 
   error_log     /var/log/gitlab.example.com-error.log; 

   location / { 
     client_max_body_size 0; 
     gzip off; 

     proxy_read_timeout        300; 
     proxy_connect_timeout     300; 
     proxy_redirect            off; 

     proxy_http_version 1.1; 

     proxy_set_header      Host                  $http_host; 
     proxy_set_header      X-Real-IP             $remote_addr; 
     proxy_set_header      X-Forwarded-For       $proxy_add_x_forwarded_for; 
     proxy_set_header      X-Forwarded-Proto     $scheme; 

     proxy_pass http://gitlab-workhorse; 
   } 
 } 
 </pre> 

 h2. Resources 

 * https://github.com/gitlabhq/gitlabhq/blob/master/doc/install/installation.md 
 * https://github.com/t-zuehlsdorff/gitlabhq/blob/master/doc/install/installation-freebsd.md

Back