Support #679
Updated by Daniel Curtis about 9 years ago
This is a guide on installing GitLab 8 on FreeBSD 10. h2. Prepare the Environment * Make sure the system is up to date: <pre> pkg update && pkg upgrade </pre> * Install a few dependencies: <pre> pkg install sudo bash icu cmake pkgconf git node ruby ruby21-gems logrotate postfix krb5 go wget </pre> * Add the GitLab user <pre> pw add user -n git -m -s /usr/local/bin/bash -c "GitLab" </pre> h2. Install PostgreSQL * Install postgresql94-server: <pre> pkg install postgresql94-server </pre> * Start and enable postgresql at boot: <pre> echo 'postgresql_enable="YES"' >> /etc/rc.conf service postgresql start </pre> Set up the database: * Log in to postgresql user account <pre> su - pgsql </pre> * Initialise postgresql database <pre> initdb /usr/local/pgsql/data </pre> * Connect to postgresql database <pre> psql -d template1 </pre> #* Create a user for GitLab: <pre> CREATE USER git CREATEDB; </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 </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 's/^port .*/port 0/' /usr/local/etc/redis.conf.orig | sudo tee /usr/local/etc/redis.conf </pre> * Enable Redis socket <pre> echo 'unixsocket /usr/local/var/run/redis/redis.sock' | sudo tee -a /usr/local/etc/redis.conf </pre> * Grant permission to the socket to all members of the redis group <pre> echo 'unixsocketperm 770' | sudo tee -a /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 restart </pre> h2. Install GitLab 8 * Switch to the git user: <pre> su - git </pre> * Clone GitLab repository <pre> git clone https://gitlab.com/gitlab-org/gitlab-ce.git -b 8-1-stable gitlab </pre> * Switch to the GitLab installation folder <pre> cd /home/git/gitlab </pre> * Copy the example GitLab config <pre> cp config/gitlab.yml.example config/gitlab.yml </pre> * Update GitLab config file, follow the directions at top of file <pre> vi config/gitlab.yml </pre> * Copy the example secrets file <pre> cp config/secrets.yml.example config/secrets.yml chmod 0600 config/secrets.yml </pre> * Make sure GitLab can write to the log/ and tmp/ directories <pre> sudo chown -R git log/ sudo chown -R git tmp/ sudo chmod -R u+rwX,go-w log/ sudo chmod -R u+rwX tmp/ </pre> * Make sure GitLab can write to the tmp/pids/ and tmp/sockets/ directories <pre> sudo chmod -R u+rwX tmp/pids/ sudo chmod -R u+rwX tmp/sockets/ </pre> * Make sure GitLab can write to the public/uploads/ directory sudo chmod -R u+rwX public/uploads * Change the permissions of the directory where CI build traces are stored sudo chmod -R u+rwX builds/ * Copy the example Unicorn config <pre> cp config/unicorn.rb.example config/unicorn.rb </pre> * Copy the example Rack attack config <pre> cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb </pre> * Configure Git global settings for git user, used when editing via web editor <pre> git config --global core.autocrlf input </pre> * Configure Redis connection settings <pre> cp config/resque.yml.example config/resque.yml </pre> * Change the Redis socket path if you are not using the default Debian / Ubuntu configuration <pre> vi config/resque.yml </pre> * Configure GitLab DB Settings: <pre> cp config/database.yml.postgresql config/database.yml </pre> * Change the database credentials <pre> vi config/database.yml </pre> * Make config/database.yml readable to git only <pre> chmod o-rwx config/database.yml </pre> * Install the gems for PostgreSQL: <pre> bundle install --deployment --without development test mysql aws kerberos </pre> h3. Install GitLab Shell * Run the installation task for gitlab-shell: <pre> bundle exec rake gitlab:shell:install[v2.6.5] REDIS_URL=unix:/var/run/redis/redis.sock RAILS_ENV=production </pre> # By default, the gitlab-shell config is generated from your main GitLab config, double check the settings are correct: <pre> vi /home/git/gitlab-shell/config.yml </pre> h3. Install GitLab HTTP Server * Install the gitlab http server: <pre> cd /home/git sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-git-http-server.git cd gitlab-git-http-server sudo -u git -H git checkout 0.3.0 sudo -u git -H make </pre> h3. Initialize Database * Initialize the database: <pre> bundle exec rake gitlab:setup RAILS_ENV=production </pre> h3. Install schedules * Setup schedules <pre> bundle exec whenever -w RAILS_ENV=production </pre> h3. Install Init Script * Download the init script: <pre> wget -O /usr/local/etc/rc.d/gitlab https://gitlab.com/gitlab-org/gitlab-recipes/raw/master/init/init/freebsd/gitlab-unicorn </pre> h3. Check Configuration and Compile Assets * Check the configuration: <pre> cd /home/git/gitlab bundle exec rake gitlab:env:info RAILS_ENV=production </pre> * Compile all of the assets for GitLab: <pre> bundle exec rake assets:precompile RAILS_ENV=production </pre> h2. Resources * http://doc.gitlab.com/ce/install/installation.html * https://github.com/gitlabhq/gitlab-recipes/blob/master/install/freebsd/freebsd-10.md