-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
Gitlab Cookbook
By :
In this recipe, I will help you install GitLab from source. Installing from source means that we will take the source code from gitlab.com and use that to code in order to install it on our server.
At the time of writing, 7.4 is the latest version. If you want to be sure that you have the latest version, please check https://gitlab.com/gitlab-org/gitlab-ce/blob/master/VERSION.
If you want the latest bleeding edge version, you can change 7.4 to master in this recipe.
To install GitLab on your own server, you need to have a few things installed already. Here is a list of prerequisites:
Follow these steps to install GitLab from source:
$ cd /home/git $ sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-ce.git -b 6-9-stable gitlab
config/gitlab.yml, we need to change the host to the fully-qualified domain name of your GitLab instance. Also change the email_from to the e-mail address you want to use as a from address for all the e-mails that are sent by GitLab:$ cd /home/git/gitlab $ sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml $ sudo -u git -H editor config/gitlab.yml
$ sudo chown -R git log/ $ sudo chown -R git tmp/ $ sudo chmod -R u+rwX log/ $ sudo chmod -R u+rwX tmp/ $ sudo chmod -R u+rwX tmp/pids/ $ sudo chmod -R u+rwX tmp/sockets/ $ sudo chmod -R u+rwX public/uploads
$ sudo -u git -H mkdir /home/git/gitlab-satellites $ sudo chmod u+rwx,g+rx,o-rwx /home/git/gitlab-satellites
$ sudo -u git -H cp config/unicorn.rb.example config/unicorn.rb
$ sudo -u git -H cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb
init script and make GitLab start on boot:$ sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab $ sudo update-rc.d gitlab defaults 21
$ sudo cp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab
user.email is the same as the e-mail address you entered in step 8:$ sudo -u git -H git config --global user.name "GitLab" $ sudo -u git -H git config --global user.email "[email protected]" $ sudo -u git -H git config --global core.autocrlf input
$ sudo -u git -H cp config/database.yml.postgresql config/database.yml
database.yml file is only readable for the git user:$ sudo -u git -H chmod o-rwx config/database.yml
$ sudo -u git -H bundle install --deployment --without development test mysql aws
$ sudo -u git -H bundle exec rake gitlab:shell:install[v1.9.4] REDIS_URL=redis://localhost:6379 RAILS_ENV=production
$ sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production force=yes
$ sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production
$ sudo /etc/init.d/gitlab restart
We have just installed GitLab on our server. We have done this by downloading the source code from gitlab.com and performing the preceding steps.
Let's take a look at what we did in every step.
In step 1, we downloaded the source code for GitLab. We haven't done anything with it yet, just downloaded it.
In step 2, we done the basic configuration of GitLab. We have changed the hostname to the fully-qualified domain name you want to access your GitLab on, for example, gitlab.example.com. Also, we have configured the e-mail addresses that GitLab will send mails from. The email_from will be used as the from address of all the e-mails that are sent via GitLab.
Next was the setup for the satellite directory. Satellites are used when you create a merge request, and GitLab has to check whether it is mergeable, and perform the actual merge. A satellite is just checking out of the repository that GitLab has access to.
We then went on to copy some files. The first file was the Unicorn configuration file. Unicorn was used as the application server and we copied the Rack Attack files. Rack Attack is used in order to prevent abusive requests to your GitLab server. One way to make sure that no harmful requests make it to your server is by request throttling. This means that we only allow 10 requests per 60 seconds to certain URLs.
The next important step is the configuration of the database. As we are using PostgreSQL on the same machine, the configuration is really straightforward: just copy the right database.yml file and we are done, well almost; we also need to protect our database.yml file so that it's only readable for the Git user.
The dependency installation is done via Bundler. Bundler is the package manager for Ruby. We have passed the flags --deployment and --without development test mysql aws. The first flag is passed to make sure that the dependencies are installed in the context of GitLab and not in a system-wide context. The second flag is passed to make sure that only the necessary dependencies are installed. If you want to learn more about Bundler, take a look at www.bundler.io.
GitLab has its own Git wrapper to perform Git commands on the server. This wrapper is called GitLab Shell. In step 11, we tell GitLab to fetch the code for GitLab Shell and install it.
In step 12, we set up the database. We create the database and load the database schema. We also create the first user, so that you can log in to your server.
Change the font size
Change margin width
Change background colour