Project

General

Profile

Support #624

Updated by Daniel Curtis over 8 years ago

{{>toc}} 

 h1. Setting up the Environment 

 * Start by making sure everything is up to date: 
 <pre> 
 pkg update && pkg upgrade 
 portsnap fetch extract 
 pkg2ng 
 </pre> 

 * Install portmaster: 
 <pre> 
 cd /usr/ports/ports-mgmt/portmaster 
 make install clean 
 </pre> 

 * Install a few dependencies 
 <pre> 
 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/postgresql94-client databases/postgresql-libpqxx sysutils/rubygem-bundler devel/libgit2 security/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 PostgreSQL 

 * This environment will be setup with PostgreSQL 9.4: MariaDB 5.5 for its MySQL server: 
 <pre> 
 portmaster databases/postgresql94-server 
 </pre> 

 * Login to PostgreSQL: 
 <pre> 
 sudo -u postgres 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; 
 </pre> 
 #* Quit the database session 
 <pre> 
 \q 
 </pre> 

 * Try connecting to the new database with the new user 
 <pre> 
 sudo -u git -H psql -d gitlabhq_production 
 </pre> 

 * Quit the database session 
 <pre> 
 \q 
 </pre>  

 h1. Install GitLab 7.11 

 * Change to the git user home directory and download GitLab 7.11 
 <pre> 
 su - git 
 cd 
 git clone https://gitlab.com/gitlab-org/gitlab-ce.git -b 7-11-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.postgresql 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 mysql 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.6.3] REDIS_URL=redis://localhost:6379 RAILS_ENV=production 
 </pre> 

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

 * You can review (and modify) the gitlab-shell config as follows: 
 <pre> 
 vi /home/git/gitlab-shell/config.yml 
 </pre> 
 #* *NOTE*: I needed to set the @gitlab_url@ parameter to http://localhost:8080 for the gitlab-shell API backend to work properly.  

 * 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. GitLab on Nginx 

 h2. Install Nginx 

 * Install Nginx 
 <pre> 
 portmaster www/nginx 
 </pre> 
 #* *NOTE*: Make sure to enable *@[X]PASSENGER@* during the port configuration 

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

 h2. Install Phusion Passenger 

 * Reinstall Nginx with Passenger support 
 <pre> 
 portmaster www/rubygem-passenger 
 </pre> 
 #* *NOTE*: Make sure to enable *@[X]NGINX@* during the port configuration 
 #* _Optional_: Enable *@[X]SYMLINK@* during the port configuration to make upgrading passenger easier later on. 

 * Edit the main nginx config file: 
 <pre> 
 vi /usr/local/etc/nginx/nginx.conf 
 </pre> 
 #* And add the Passenger config parameters: 
 <pre> 
 #user    nobody; 
 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; 
   #tcp_nopush       on; 

   #keepalive_timeout    0; 
   keepalive_timeout    65; 

   #gzip    on; 

   # Load Phusion Passenger module globally 
   passenger_root /usr/local/lib/ruby/gems/2.1/gems/passenger; 
   passenger_ruby /usr/local/bin/ruby21; 
   passenger_max_pool_size 15; 
   passenger_pool_idle_time 300; 

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

 } 
 </pre> 
 #* *NOTE*: The above config assumes [X]SYMLINK was enabled during the port configuration. Match the config according to which ever version of passenger is installed at @/usr/local/lib/ruby/gems/2.1/gems@. 

 * Now create a git server block: 
 <pre> 
 vi /usr/local/etc/nginx/conf.d/git.example.com.conf 
 </pre> 
 #* And add the following: 
 <pre> 
 server { 
   listen 80; 
   server_name git.example.com; 
   # enforce https 
   return 301 https://$server_name$request_uri; 
 } 

 server { 
   listen 443 ssl; 
   server_name git.example.com; 

   ssl_certificate /usr/local/etc/nginx/ssl/git.example.com.crt; 
   ssl_certificate_key /usr/local/etc/nginx/ssl/git.example.com.key; 

   root /home/git/gitlab/public; 
   passenger_enabled on; 
   passenger_user git; 
   passenger_group git; 

   # set max upload size 
   client_max_body_size 1G; 
   fastcgi_buffers 64 4K; 
 } 
 </pre> 

 h1. 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: 
 <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> 

 h1. Initial Login 

 The default username and password: 
 * user: *root* 
 * pass: *5iveL!fe* 

 h1. 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

Back