Support #461
Updated by Daniel Curtis about 10 years ago
h1. h2. 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 -y git redis icu libxml2 libxslt python2 bash sudo gcc47 gmake autoconf automake libtool bison readline libyaml sqlite3 gdbm cmake postgresql-libpqxx </pre> * Add the GitLab user <pre> pw add user -n git -m -s /usr/local/bin/bash -c "GitLab" </pre> h2. h3. Install Redis * Start Redis and enable it to start at boot: <pre> echo 'redis_enable="YES"' >> /etc/rc.conf service redis start </pre> h2. h3. 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. h2. h3. Ruby * Switch to the GitLab user and install RVM: <pre> su - git curl -sSL https://get.rvm.io | bash -s stable source /home/git/.rvm/scripts/rvm </pre> * Install Ruby 2.1.2 using RVM: <pre> rvm install 2.1.2 </pre> * Check the Ruby install path: <pre> which ruby </pre> #* Example output: <pre> /home/git/.rvm/rubies/ruby-2.1.2/bin/ruby </pre> * Check the installed Ruby version: <pre> ruby -v </pre> #* Example output: <pre> ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-freebsd10.0] </pre> h1. h2. Install GitLab 7.2 * Change to the git user home directory and download GitLab 7.2 <pre> cd git clone https://gitlab.com/gitlab-org/gitlab-ce.git -b 7-2-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 host: git.example.com #* If using https change the @port@ from 80 to *443* #* Change the @bin_path@: */usr/local/bin/git* * 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> * Install bundler: <pre> gem install bundler export CC=gcc47 export CXX=c++47 export CPP=cpp47 </pre> * Install GitLab gems <pre> bundle install --deployment --without development test postgresql aws </pre> h2. h3. Install GitLab Shell * Run the installation task for gitlab-shell (replace `REDIS_URL` if needed): <pre> bundle exec rake gitlab:shell:install[v1.9.7] 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.sh </pre> * Start GitLab <pre> /usr/local/etc/rc.d/gitlab.sh start </pre> h1. h2. Install Nginx * Install nginx: <pre> pkg install -y 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 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 /home/git/.rvm/wrappers/ruby-2.1.2/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> 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