Support #814
Install GitLab 8 on FreeBSD
Status:
Closed
Priority:
Normal
Assignee:
Category:
Source Code Management
Target version:
Description
- Table of contents
- Prepare the Environment
- Install PostgreSQL
- Install Redis
- Install GitLab 8
- Install Nginx
- Resources
This is a guide on installing GitLab 8.5 with continuous integration on FreeBSD 10.
Prepare the Environment¶
- Make sure the system is up to date:
pkg update && pkg upgrade
Install PostgreSQL¶
- Install postgresql:
pkg install postgresql94-server
- Initialize, start, and enable postgresql at boot:
echo 'postgresql_enable="YES"' >> /etc/rc.conf service postgresql initdb service postgresql start
- Log in to postgresql user account
su - pgsql
- Connect to postgresql database
psql -d template1
- Create a user for GitLab:
CREATE USER git WITH PASSWORD 'SuperSecretPassword' CREATEDB SUPERUSER;
- Create the GitLab production database & grant all privileges on database
CREATE DATABASE gitlabhq_production OWNER git encoding='UTF8';
- Quit the database session
\q exit
- Create a user for GitLab:
Install Redis¶
- Install redis:
pkg install redis
- Back up the original Redis config file:
cp /usr/local/etc/redis.conf /usr/local/etc/redis.conf.orig
- Disable Redis listening on TCP by setting 'port' to 0
sed -i '' -e 's/^port .*/port 0/' /usr/local/etc/redis.conf
- Enable Redis socket
echo 'unixsocket /var/run/redis/redis.sock' >> /usr/local/etc/redis.conf
- Grant permission to the socket to all members of the redis group
echo 'unixsocketperm 770' >> /usr/local/etc/redis.conf
- Create the directory which contains the socket
mkdir -p /var/run/redis chown redis:redis /var/run/redis chmod 755 /var/run/redis
- Start and enable redis at boot:
echo 'redis_enable="YES"' >> /etc/rc.conf service redis start
Install GitLab 8¶
- Install gitlab:
pkg install gitlab
- Add git user to redis group
pw groupmod redis -m git
- Go to GitLab installation folder
cd /usr/local/www/gitlab
- Update GitLab config file, follow the directions at the top of the file
vi config/gitlab.yml
- Find number of cores
sysctl hw.ncpu
- Enable cluster mode if you expect to have a high load instance, set the number of workers to at least the number of cores:
vi config/unicorn.rb
- Edit the gitlab-shell config file:
vi /usr/local/share/gitlab-shell/config.yml
- And make sure the following configuration parameters are set:
repos_path: "/usr/home/git/repositories" redis: bin: /usr/local/bin/redis-cli
- And make sure the following configuration parameters are set:
- Create the uploads directory and harden its permissions:
sudo -u git mkdir /usr/local/www/gitlab/public/uploads chmod 700 /usr/local/www/gitlab/public/uploads
- Configure Git global settings for git user:
git config --global core.autocrlf input
- Disable 'git gc --auto' because GitLab already runs 'git gc' when needed:
git config --global gc.auto 0
- Configure GitLab DB settings
vi config/database.yml
- Initialize database and activate advanced features:
rake gitlab:setup RAILS_ENV=production
- Type yes to create the database tables.
- When done you see Administrator account created:
- Check if GitLab and its environment are configured correctly:
rake gitlab:env:info RAILS_ENV=production
- Compile Assets
rake assets:precompile RAILS_ENV=production
- Start and enable gitlab at boot:
echo 'gitlab_enable="YES"' >> /etc/rc.conf service gitlab start
Generate SSH keys¶
- Switch to the gitlab user:
su - git
- Generate an SSH key pair:
shs-keygen -t ed25519
- And link the .ssh folder into the git home directory:
ln -s /usr/local/git/.ssh /home/git/
Install Nginx¶
- Install nginx:
pkg install nginx
- Start and enable nginx at boot:
echo 'nginx_enable="YES"' >> /etc/rc.conf service nginx start
- Create a configuration directory to make managing individual server blocks easier
mkdir /usr/local/etc/nginx/conf.d
- Edit the main nginx config file:
vi /usr/local/etc/nginx/nginx.conf
- And strip down the config file and add the include statement at the end to make it easier to handle various server blocks:
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; }
- And strip down the config file and add the include statement at the end to make it easier to handle various server blocks:
- Create the gitlab nginx config:
vi /usr/local/etc/nginx/conf.d/gitlab.example.com.conf
- And add the following:
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; } }
- And add the following: