Gitlab is an open source Git repository service written in Ruby on Rails that can either be self-hosted, or purchased as a service. Hosting Gitlab is fairly easy, especially since it comes in a per-configured "Omnibus" package.
InstallationThe Gitlab developers have made it relatively easy to install with a package repository and install scripts, so the first thing to do is update Ubuntu and install the required dependencies.
$ sudo apt-get install curl openssh-server ca-certificates postfixNext, get the Gitlab install script with
curland run it. The script will add the Gitlab repository to your system for easy installs and updates in the future. Once the script is finished, use Apt to install the Gitlab Community Edition package.
# curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash # sudo apt-get install gitlab-ceThe install shouldn’t take that long, and when it completes, Gitlab needs to be configured. The Gitlab “Omnibus” package contains all of the software needed to get Gitlab running, including the Ruby on Rails project, a database, and a web server. The configuration utility will automatically configure all of that for your system. Don’t worry if you wan something specific. That can be changed later.
# sudo gitlab-ctl reconfigureThe configuration will take several minutes, since it needs to go through a ton of different things to get Gitlab working. The good news is, once it’s done, you really don’t have to configure anything, if you don’t want to. Also, because Ubuntu is a Debian based distribution, Gitlab will start as soon as the configuration finishes.
localhostthrough the browser. This can be changed with configuration later on. Once you get there, you will be prompted to create a new password and log in. The default user is
root, so the password that you would be setting is the root password for the Gitlab install. Once you do that, you can sign out and make your user account. Once you create the account, you will be signed in to your "Welcome" screen.
From the “Welcome” screen, you can create a new project repository. When you start a project, you will be taken to a simple screen that allows you to name the project and set the level of access that others will have to it.
SSH KeysIn order to securely connect to your Gitlab repository, you need to use SSH keys, If you already have one that you would like to use, skip down a bit. If not, you can create them easily with one command. To create an SSH key, type the following linux command in the terminal.
$ cat ~/.ssh/id_rsa.pubYou should see a long string of characters. From that file, copy the line that begins with
ssh-rsa. Back in the browser, pull down the menu, and navigate to "Profile Settings". From there, select "SSH Keys” from the menu across the top. Paste your key into the box marked, "Key" and give it a name before saving it. After that, your repository should be set up to use like any other web-based Git hosting service.