⬆️ ⬇️

Installing GitLab on Slackware



Good day. I have a small server at hand that is used as a git server to show the project to the client, etc. The server runs on the Slackware v.13.1.0 operating system, the linux family. Why not Debian or Ubuntu is historically so. To view the git repositories, I used cgit. Recently there was a need to start using GitLab. If interested - welcome under cat.



So what is GitLab? If you are familiar with GitHub, then this is a similar structure, only on your server and under your control.



To make GitLab work for us, you need to install Ruby 2+, MySQL, Git, Apache 2+, as well as Python 2.6+ and the last Redis. I will miss the mysql installation process.



So, in order.

')

Required components




Install Python



Put first Python . Shrink from here package.

Action plan
#   sudo chmod +x python.SlackBuild #  sudo ./python.SlackBuild #  sudo installpkg python 






Install Ruby



Next, install the cut. The process is similar to installing Python, download files from here .

Action plan
 #   sudo chmod +x ruby.SlackBuild #  sudo ./ruby.SlackBuild #  sudo installpkg ruby 




Alternative way to install ruby:

Alternative Action Plan
 #       mkdir /tmp/ruby && cd /tmp/ruby #      curl --progress ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p353.tar.gz | tar xz #         cd ruby-2.0.0-p353 ./configure --prefix=/usr/local/ make sudo make install 


Regardless of the way in which ruby ​​was installed, check what we have established:

 #    which ruby #   ruby --version # bundler,    gem install bundler --no-ri --no-rdoc 




Install Redis



The Redis installation procedure is different from the previous two.

Action plan
 #    cd /tmp #       mkdir redis cd redis #     wget http://download.redis.io/redis-stable.tar.gz tar xvzf redis-stable.tar.gz cd redis-stable #    make #       cd src sudo cp redis-server /usr/local/bin/ sudo cp redis-cli /usr/local/bin/ 




That's not all. In order for the radish service to come up when the server starts, you need to correct the /etc/local.conf file:

 #      sudo nano /etc/local.conf #    [components]     /usr/local/bin/redis-server 


We start redis-server simply by executing the “redis-server” command (without quotes). In another terminal, we’ll check that the radish server is up:

 #  redis-cli ping # PONG 


Install Git



It remains to install git.

 #      cd /tmp && curl --progress https://git-core.googlecode.com/files/git-1.9.0.tar.gz | tar xz #    cd git-1.9.0/ #    make prefix=/usr/local all # git sudo make prefix=/usr/local install 




Gitlab




We proceed directly to the process of installing GitLab.



Add git user to system



If you have not yet created a git user in the system, then you need to start with this. To do this, execute the command in the terminal:

 sudo /usr/sbin/adduser --disabled-login git 


We pass step by step creation of a user profile. After creation, we check that we have created a new user’s folder in / home with the name git (if you specified another username, for example gitlab, then the folder name will be gitlab, and at the end of the article there will be notes where and what needs to be changed in gitlab and gitlab-shell to make it work).



Install and configure gitlab-shell



First we need to install and install the gitlab-shell:

Action plan
 #    git cd /home/git #    sudo -u git -H git clone https://github.com/gitlabhq/gitlab-shell.git cd gitlab-shell # VERSION   ,      v1.9.0 sudo -u git -H git checkout VERSION #   sudo -u git -H cp config.yml.example config.yml #  nano config.yml #  #gitlab_url: "http://localhost/" #  http://localhost/    #     git sudo -u git -H ./bin/install 




Create mysql user and db



Next you need to create plates for gitlab in mysql. Create a temporary file, for example gitlab_tables.sql and save the following in it:

sql
 --   USER_PASSWORD      CREATE USER 'gitlab'@'localhost' IDENTIFIED BY 'USER_PASSWORD'; CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`; GRANT SELECT, LOCK TABLES, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO 'gitlab'@'localhost'; 






Login to mysql as root and execute a non-tricky command

 -- gitlab_tables.sql -    source gitlab_tables.sql; 


With a flick of the wrist, we created a user named gitlab and a database gitlabhq_production, and also gave the rights to the user to this database.

More this file is not needed, we can safely delete it.



Install and configure gitlab



Now let's proceed to installing and configuring gitlab itself:

Action plan
 #      git cd /home/git #  gitlab   gitlab       sudo -u git -H git clone https://github.com/gitlabhq/gitlabhq.git gitlab cd /home/git/gitlab # VERSION   ,      7-2-stable sudo -u git -H git checkout VERSION #      sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml #     sudo -u git -H nano config/gitlab.yml #  localhost    ## Web server settings host: localhost port: 80 https: false #    sudo -u git cp config/database.yml.mysql config/database.yml #    gitlab    mysql  sudo -u git -H nano config/database.yml #        ,          mysql   database: gitlabhq_production username: root password: "secure password" 




Set permissions on files and folders inside / home / git / gitlab:

Action plan
 cd /home/git/gitlab sudo chown -R git log/ sudo chown -R git tmp/ sudo chmod -R u+rwX log/ sudo chmod -R u+rwX tmp/ sudo -u git -H mkdir /home/git/gitlab-satellites sudo -u git -H mkdir tmp/pids/ sudo -u git -H mkdir tmp/sockets/ sudo chmod -R u+rwX tmp/pids/ sudo chmod -R u+rwX tmp/sockets/ sudo -u git -H mkdir public/uploads sudo chmod -R u+rwX public/uploads sudo -u git -H cp config/unicorn.rb.example config/unicorn.rb sudo -u git -H git config --global user.name "GitLab" sudo -u git -H git config --global user.email "gitlab@localhost" sudo -u git -H git config --global core.autocrlf input sudo -u git -H chmod o-rwx config/database.yml 




Install ruby ​​gems



The next step is to install ruby ​​gems:

 #   gitlab     git cd /home/git/gitlab # charlock_holmes,       0.7.3 sudo gem install charlock_holmes --version '0.7.3' #    (     ,  ) sudo -u git -H bundle install --deployment --without development test postgres aws 


Run the gitlab installation



It remains only to start the installation and configuration of gitlab itself:

 #    root -  ,        ,      #     -  'yes' sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production 


At the end of the installation, if everything went well, the following will be displayed in the console:

 Administrator account created: login.........root password......5iveL!fe 


Check the validity of the gitlab configuration



There is not much left. Let's check that everything is configured correctly and configure the configuration so that when the server starts, gitlab starts automatically:

Action plan
 #    gitlab sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production #     ,  ,    #  sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab #   sudo chmod +x /etc/init.d/gitlab #   local.conf: sudo nano /etc/local.conf #    [components]     git@/etc/init.d/gitlab #git -        




Start gitlab



Now it's time to start gitlab, for this we execute the following command:

 sudo -u git -H /etc/init.d/gitlab start 


If everything is good, then in the console we will see the following:

 The GitLab Unicorn web server with pid 15869 is running. The GitLab Sidekiq job dispatcher with pid 16468 is running. GitLab and all its components are up and running. 




By default, gitlab rotates through unicorn on port 8080 and we can verify this:

 #  lynx lynx localhost:8080 


The result of lynx will be the output of the page for user authorization. Enter the login 'root' and the password '5iveL! Fe' (all without quotes). Submit the form and see the offer from gitlab to change the current password, change it.



Configuring Apache config for gitlab



It remains to configure Apache. Go to the / etc / httpd / sites-available folder and create a gitlab file with the following contents:

The contents of the config file gitlab for Apache
 <VirtualHost *:80> ServerName OUR_COOL_URL ServerSignature Off ProxyPreserveHost On # Ensure that encoded slashes are not decoded but left in their encoded state. AllowEncodedSlashes Off <Location /gitlab> Order deny,allow Allow from all ProxyPassReverse http://127.0.0.1:8080 ProxyPassReverse http://OUR_COOL_URL/ </Location> # apache equivalent of nginx try files RewriteEngine on RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f RewriteRule .* http://127.0.0.1:8080%{REQUEST_URI} [P,QSA] # needed for downloading attachments DocumentRoot /home/git/gitlab/public Alias /gitlab /home/git/gitlab/public <Directory /home/git/gitlab/public> Options All -Indexes AllowOverride All Order deny,allow Allow from all </Directory> <Directory /home/git/gitlab/public/assets> Options All -Indexes AllowOverride All Order deny,allow Allow from all </Directory> LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b" common_forwarded ErrorLog /var/log/httpd/gitlab_error.log LogLevel warn CustomLog /var/log/httpd/gitlab_access.log combined env=!dontlog CustomLog /var/log/httpd/gitlab combined </VirtualHost> 






Useful notes




Problems that may be encountered during installation and after





Useful resources



Source: https://habr.com/ru/post/235591/



All Articles