A guide on setting up GitLab on Fedora 22

Published by moxlotus on

GitLab
I believe that most developers should have heard of/used GitHub. One of the main issues with GitHub is the lack of private repository for free users(except for student account). In the event that one needs a private repository, some will use BitBucket instead of GitHub. Alternatively, one can host a git server on his/her own machine. Here I am presenting another solution known as GitLab, which is pretty similar to GitHub except that it allows you to host the software on third-party server which is perfect for personal use. As GitLab does not have official support on Fedora. It will take a few more steps than usual to get it up and running on a Fedora server.

  1. Installing Pre-requisties

    sudo dnf install sendmail sendmail-cf curl openssh-server
    
  2. Starting and Enabling Services

    sudo systemctl start sshd
    sudo systemctl enable sshd
    
  3. Downloading GitLab

    curl https://packages.gitlab.com/gitlab/gitlab-ce/packages/el/7/gitlab-ce-8.1.2-ce.0.el7.x86_64.rpm/download
    
  4. GitLab Installation

    dnf install gitlab-ce-8.1.2-ce.0.el7.x86_64.rpm
    
  5. Configuring and Starting GitLab
    Before running the gitlab, we will need to edit the configuration file.

    sudo -e /etc/gitlab/gitlab.rb
    

    Change the external url to your domain.

     external_url 'http://mydomain.com'
    

    Run the following to have gitlab reconfigured and restarted.

    sudo gitlab-ctl reconfigure
    
  6. Configure Firewall Setting

    sudo firewall-cmd --permanent --add-service=http
    sudo firewall-cmd --reload
    
  7. Configure Sendmail
    In this example, gmail is used as the mailing agent.
    Before you make changes, make sure a back up of sendmail.mc and sendmail.cf is created.

    cd /etc/mail
    sudo cp sendmail.mc sendmail.mc.bak
    sudo cp sendmail.cf sendmail.cf.bak
    

    Add the following lines to the top of the first Mailer in /etc/mail/sendmail.mc

    define(`SMART_HOST',`[smtp.gmail.com]')dnl
    define(`RELAY_MAILER_ARGS', `TCP $h 587')dnl
    define(`ESMTP_MAILER_ARGS', `TCP $h 587')dnl
    define(`confAUTH_OPTIONS', `A p')dnl
    TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
    define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
    FEATURE(`authinfo',`hash -o /etc/mail/authinfo/gmail-auth.db')dnl
    

    Now we will need to create the gmail-auth.db so that sendmail can login to the gmail mailing server with the credentials

    sudo mkdir -m 700 /etc/mail/authinfo/
    sudo cd /etc/mail/authinfo/
    

    Create the file gmail-auth and insert the following line.

    AuthInfo: "U:root" "I:EMAIL ADDRESS" "P:PASSWORD"
    

    Next we will need to create the hash file. (you may wanna delete original gmail-auth for security reason)

    makemap hash gmail-auth < gmail-auth
    

    Next, we will need to have sendmail reconfigured and restarted.

    m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
    sudo service sendmail restart
    
  8. Accessing GitLab Web Interface
    Now that everything has been configured, you may try to access the web interface via the external URL that you have specified in the beginning.
    Try making an account and see if you actually receives a confirmation email. If everything works fine, you can start creating code repository on your very own git server.
    In the event that sendmail fails to send the confirmation email. you may want to check the log in /var/log/maillog for more information.
  9. Share it with others
Categories: Tools