Support #532
Updated by Daniel Curtis almost 10 years ago
{{>toc}}
h1. Setting up the Environment
* Start by making sure everything is up to date:
<pre>
pkg update
pkg upgrade
</pre>
* Install a few dependencies
<pre>
pkg install git redis ruby krb5 icu libxml2 libxslt python2 bash sudo gcc47 gmake autoconf automake libtool bison readline libyaml sqlite3 gdbm cmake postgresql-libpqxx rubygem-bundler libgit2 libssh2
</pre>
* Add the GitLab user
<pre>
pw add user -n git -m -s /usr/local/bin/bash -c "GitLab"
</pre>
h2. Install Redis
* Start Redis and enable it to start at boot:
<pre>
echo 'redis_enable="YES"' >> /etc/rc.conf
service redis start
</pre>
* Add the following to /usr/local/etc/redis.conf:
<pre>
unixsocket /var/run/redis/redis.sock
unixsocketperm 770
</pre>
* Add git to the redis group:
<pre>
pw usermod git -G redis
</pre>
h2. Install MariaDB 5.5
* This environment will be setup with MariaDB 5.5 for its MySQL server:
<pre>
pkg install mariadb55-server mariadb55-client
</pre>
* Ensure you have MySQL version 5.5.14 or later
<pre>
mysql --version
</pre>
* Start and enable MySQL at boot:
<pre>
echo 'mysql_enable="YES"' >> /etc/rc.conf
service mysql-server start
</pre>
* Secure your installation:
<pre>
mysql_secure_installation
</pre>
* Login to MySQL
<pre>
mysql -u root -p
</pre>
*# Create a user for GitLab
<pre>
CREATE USER 'git'@'localhost' IDENTIFIED BY 'SuperSecretPassword';
</pre>
*NOTE*: Change _+SuperSecretPassword+_ to what ever password desired
*# Ensure you can use the InnoDB engine which is necessary to support long indexes.
<pre>
SET storage_engine=INNODB;
</pre>
*NOTE*: If this fails, check your MySQL config files (e.g. `/etc/mysql/*.cnf`, `/etc/mysql/conf.d/*`) for the setting "innodb = off"
*# Create the GitLab production database
<pre>
CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;
</pre>
*# Grant the GitLab user necessary permissions on the table.
<pre>
GRANT SELECT, LOCK TABLES, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO 'git'@'localhost';
</pre>
*# Quit the database session
<pre>
quit
</pre>
* Try connecting to the new database with the new user
<pre>
sudo -u git -H mysql -u git -p -D gitlabhq_production
</pre>
#* Type the MySQL git password set earlier
<pre>
SuperSecretPassword
</pre>
* You should now see a @mysql>@ prompt, quit the database session:
<pre>
quit
</pre>
*+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.
h1. Install GitLab 7.6
* Change to the git user home directory and download GitLab 7.6
<pre>
su - git
cd
git clone https://gitlab.com/gitlab-org/gitlab-ce.git -b 7-6-stable gitlab
</pre>
* Create a config file
<pre>
cd /home/git/gitlab
cp config/gitlab.yml.example config/gitlab.yml
</pre>
* Edit the gitlat config file:
<pre>
vi config/gitlab.yml
</pre>
#* 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:
<pre>
cp config/unicorn.rb.example config/unicorn.rb
</pre>
* Create a rack_attack.rb file:
<pre>
cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb
</pre>
* Create a database configuration file:
<pre>
cp config/database.yml.mysql config/database.yml
</pre>
* Configure the GitLab system user:
<pre>
git config --global user.name "GitLab"
git config --global user.email "example@example.com"
</pre>
* Setup the directories and permissions:
<pre>
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
</pre>
* Create the gitlab-satellites:
<pre>
mkdir /home/git/gitlab-satellites
chmod u+rwx,g=rx,o-rwx /home/git/gitlab-satellites
</pre>
* Configure Redis connection settings
<pre>
cp config/resque.yml.example config/resque.yml
</pre>
* Configure bundler to build nokogiri using system libraries :
<pre>
bundle config build.nokogiri "--use-system-libraries"
</pre>
*NOTE*: This is required to prevent an error building nokogiri during install
* Configure bundler to build rugged using system libraries :
<pre>
bundle config build.rugged "--use-system-libraries"
</pre>
*NOTE*: This is required to prevent an error building rugged during install
* Install GitLab gems
<pre>
bundle install --deployment --without development test postgresql aws
</pre>
h2. Install GitLab Shell
* Run the installation task for gitlab-shell (replace `REDIS_URL` if needed)
<pre>
bundle exec rake gitlab:shell:install[v2.4.0] REDIS_URL=redis://localhost:6379 RAILS_ENV=production
</pre>
By default, the gitlab-shell config is generated from your main gitlab config.
* *NOTE*: When using GitLab with HTTPS please change the following:
*# Provide paths to the certificates under `ca_file` and `ca_path` options.
*# The `gitlab_url` option must point to the https endpoint of GitLab.
*# 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:
<pre>
vi /home/git/gitlab-shell/config.yml
</pre>
* Initialize Database and Activate Advanced Features
<pre>
bundle exec rake gitlab:setup RAILS_ENV=production
</pre>
* Verify that the install worked:
<pre>
bundle exec rake gitlab:env:info RAILS_ENV=production
</pre>
* Precompile the assets used by GitLab:
<pre>
bundle exec rake assets:precompile RAILS_ENV=production
</pre>
* Exit out of the GitLab user, back into the root account:
<pre>
exit
</pre>
* Create an init script
<pre>
cp /usr/home/git/gitlab/lib/support/init.d/gitlab /usr/local/etc/rc.d/gitlab
</pre>
* Start GitLab
<pre>
service gitlab start
</pre>
* Enable GitLab to start at boot
<pre>
echo 'gitlab_enable="YES"' >> /etc/rc.conf
</pre>
h1. Using Nginx to Host GitLab
* Install nginx:
<pre>
pkg install nginx
</pre>
* Copy the GitLab nginx config into the nginx directory
<pre>
cp /usr/home/git/gitlab/lib/support/nginx/gitlab /usr/local/etc/nginx/gitlab.conf
</pre>
#* 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 “}":
<pre>
include /usr/local/etc/nginx/gitlab.conf;
</pre>
* Prepare the directories needed by nginx:
<pre>
mkdir -p /var/tmp/nginx /var/log/nginx
chown -R www: /var/log/nginx /var/tmp/nginx
</pre>
* Start and enable nginx at boot:
<pre>
echo 'nginx_enable="YES"' >> /etc/rc.conf
service nginx start
</pre>
* Default username and password:
#* user: *root*
#* pass: *5iveL!fe*
h1. (Optional) Using Apache with Passenger to Host GitLab
Running GitLab from an apache server with passenger installed is a simple.
* Edit the virtual host definition and add/modify it according to your needs:
<pre>
vi /usr/local/etc/apache24/Vhosts/git.example.com.conf
</pre>
#* And add/edit the following virtual host definition:
<pre>
<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>
</pre>
* Restart apache:
<pre>
service apache24 restart
</pre>
* Start and enable apache24 at boot:
<pre>
echo 'apache24_enable="YES"' >> /etc/rc.conf
service apache24 start
</pre>
h2. Resources
http://luizgustavo.pro.br/blog/2014/08/21/instalacao-gitlab-no-freebsd/
https://gitlab.com/gitlab-org/gitlab-ce/blob/7-2-stable/doc/install/installation.md
https://gitlab.com/gitlab-org/gitlab-ce/blob/7-2-stable/doc/install/database_mysql.md