Installing Gitlab on CentOS

Source: Internet
Author: User
Tags tar xz domain name server ssl certificate

Description: Before the company because of the work needs, need to build a git-based project management platform, it is best to be closer to the management of GitHub, from the Internet to find Gitlab this open-source project, whether from the interface or function is also good, Results The company's server is win ...

Before the company because of work needs, need to build a git-based project management platform, preferably can be compared to the management of GitHub, from the Internet to find Gitlab this open source project, whether from the interface or from the function is also good, the results of the company's server is win ... On their own VPS build, my server system version is Ubuntu 10.04 LTS, very convenient to upgrade to 12.04 Lts, now Ubuntu is really good, feel all aspects of doing a lot better. However, in accordance with the official documents to build Gitlab time still encountered some problems, mainly related to the software version, file permissions and other comparison of the egg pain configuration, of course, this is not how I did the backstage. This is the project team on the server to build Gitlab, the system version of the server is CentOS, the installation process and Ubuntu is similar, here in the context of the background knowledge to write this tutorial, but also hope to bring convenience to others (Ubuntu directly refer to the official bar, The official has a CentOS one-click installation script, but you can use it if you dare to use it.

Installing Epel and dependent libraries

First install the third-party software library Epel and compile the dependent library, Epel directly install the RPM package can be.

¥ rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm$ yum -y update$ yum -y install gcc gcc-c++ make autoconf libyaml-devel gdbm-devel ncurses-devel openssl-devel zlib-devel readline-devel curl-devel expat-devel gettext-devel  tk-devel libxml2-devel libffi-devel libxslt-devel libicu-devel sendmail patch libyaml* pcre-devel sqlite-devel vim
python2.7+
$ mkdir /tmp/gitlab && cd /tmp/gitlab$ curl --progress http://python.org/ftp/python/2.7.5/Python-2.7.5.tgz | tar xvf$ cd Python-2.7.5$ ./configure --prefix=/usr/local$ make && make install

Once installed, it is important to use the LN command to create the connection so that the system's default path address will be able to find the latest version (the default /usr/local/bin).

$ sudo ln -s /usr/local/bin/python2.7 /usr/local/bin/python
Ruby2.0
$ cd /tmp/gitlab$ curl --progress http://cache.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p247.tar.gz | tar xz$ cd ruby-2.0.0-p247$ ./configure$ make$ make install

Ruby2.0 has built-in gems (the standard package for managing Ruby libraries and programs), so you only need to install bundler (a source library for image processing, which you don't know what to do with).

$ gem install bundler

If you have network problems (you know), rubygems.org stored on Amazon S3 fails to connect intermittently, (http://ruby.taobao.org/), if you are having networks Connected error. This image source is quite good, modify the address in the gemfile to this, and then continue to add the connection.

$ ln -s /usr/local/bin/ruby /usr/bin/ruby$ ln -s /usr/local/bin/gem /usr/bin/gem$ ln -s /usr/local/bin/bundle /usr/bin/bundle
Git and Gitolite

If you have git installed on your system, make sure that the version is larger than 1.7.10,github and that many git services rely on a git version that is less than this version, but the CentOS 6.4 default version of Epel installation is less than this version, This can be updated with a binary package from the Rpmforge source (as well as a third-party yum source, like Epel).

// 安装rpmforge源$ wget ‘http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm‘$ rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt$ rpm -i ‘http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm‘$ yum clean all// change the enabled=0 flag to enabled=1 in the section labelled [rpmforge-extras].$ cd /etc/yum.repos.d$ vim (or whatever) rpmforge.repo// 安装新版本Git$ yum  update$ yum provides git$ yum install git-1.7.11.3-1.el6.rfx.x86_64$ yum -y install git-all gitolite
MySQL and Redis

Gitlab supports MySQL and PostgreSQL, and Redis must be installed (a bit of remorse about the database was not studied well, and now sometimes you have to teach yourself).

$ yum -y install mysql mysql-devel mysql-server redis$ service mysqld start$ mysql -u root$ mysql> CREATE USER ‘gitlab‘@‘localhost‘ IDENTIFIED BY ‘gitlab‘;$ mysql> CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;$ mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO ‘gitlab‘@‘localhost‘;$ mysql> \q$ service redis start
Nginx

Gtilab of course also support Apache, but after all, nginx performance is much better (according to the relevant test, high concurrent connection, nginx performance can be better than 10 times times the Apache).

$ yum -y install nginx $ service nginx start

At this point, the main package has been installed, the following will be configured.

GitLab UESR
$ useradd -c ‘GitLab‘ git$ passwd -l git$ su git

After the direct switch to the GIT account operation, you can save the file permissions of some problems, if still out of permission some problems, directly using the Chown command to modify it.

GitLab Shell
$ cd /home/git$ git clone https://github.com/gitlabhq/gitlab-shell.git$ cd gitlab-shell

Use git tag to view the latest version and switch

$ git checkout v1.7.9

Modify the configuration file, add your own domain after installation.

$ vi config.yml$ ./bin/install
GitLab
$ cd /home/git$ git clone https://github.com/gitlabhq/gitlabhq.git gitlab$ cd /home/git/gitlab$ git checkout 6-3-stable$ cd /home/git/gitlab$ cp config.yml{.example,}$ vi config/gitlab.yml$ mkdir tmp/pids/$ mkdir tmp/sockets/$ 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/

Create the satellites directory and save the individual users ' warehouses.

$ mkdir /home/git/gitlab-satellites$ mkdir public/uploads$ chmod -R u+rwX  public/uploads

To modify the Unicorn configuration file:

$ cd /home/git/gitlab$ cp config/unicorn.rb{.example,}$ vi config/unicorn.rb

To set the global configuration parameters for Git:

$ git config --global user.name "GitLab"$ git config --global user.email "[email protected]"$ git config --global core.autocrlf input

To set up a Gitlab database:

$ cp config/database.yml{.mysql,}$ vi config/database.yml$ chmod o-rwx config/database.yml

Install the relevant Ruby gems dependency package;

$ cd /home/git/gitlab$ [sudo] gem install charlock_holmes --version ‘0.6.9.4‘$ bundle install --deployment --without development test postgres aws// 初始化数据库数据$ bundle exec rake gitlab:setup RAILS_ENV=production

To set the init script:

$ sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab$ sudo chmod +x /etc/init.d/gitlab
GitLab Check
$ bundle exec rake gitlab:env:info RAILS_ENV=production$ sudo service gitlab start$ bundle exec rake gitlab:check RAILS_ENV=production

Be sure to check with the last check, note that switching to a GIT account, especially for IP address and port modification, requires a re-check.

Configure Nginx

It is important to note that Ubuntu under the default download of the Nginx version and CentOS is different, the distribution of different configuration structure is a certain difference.

$ mkdir -p /etc/nginx/sites-available/$ mkdir -p /etc/nginx/sites-enabled/$ cp lib/support/nginx/gitlab /etc/nginx/sites-available/gitlab$ ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab

When loading the configuration file, determine which directory the profile of the nginx.conf index is in, including if you want to modify the port (Nginx and Apaache 80 port conflict) is also to be aware of the Nginx release loaded configuration file is listening to which port. The Nginx version I used was 1.0.15, modified the default.conf port listener and nginx.conf to load its own configuration file.

$ http {$ …$ # Load config files from the /etc/nginx/conf.d directory$ # The default server is in conf.d/default.conf$ include /etc/nginx/conf.d/*.conf;$ include /etc/nginx/sites-enabled/*;$ …$ }

To restart the services:

$ sudo service nginx restart$ sudo service gitlab restart

If Nginx does not restart, prompt 80 port occupancy, the description of the port modification is not correct.

Done

Now access to their domain can see the Gitlab landing interface, in order to speed up the speed of domain name resolution can be configured under the Hosts file.

$ echo "127.0.0.1 YOUR_DOMAIN" >> /etc/hosts

Default user name and password:

[email protected]5iveL!fe
Modify Port

To modify the port occupied by the HTTP Server unicorn:

$ vi /home/git/gitlab/config/unicorn.rb# listen "127.0.0.1:9292", :tcp_nopush => true

To modify the Gitlab's publishing port:

$ vi /etc/nginx/sites-enabled/gitlab# listen *:888 default_server;$ vi /home/git/gitlab/config/gitlab.yml# port: 888$ vi /home/git/gitlab-shell/config.yml# gitlab_url: "http://mygitdomain.com:888"
Add SSL

Let's say we've prepared the server's key Server.key and certificate server.crt and root certificate ca.crt (how to get the certificate reference SSL certificate generation), and place these files under/etc/nginx/sites-available/.

# Add the following to/etc/nginx/sites-available/gitlab last.    # Replace the server_name specified by the domain name server {Listen *:443;    SSL on;    SSL_CERTIFICATE/ETC/NGINX/SITES-AVAILABLE/SERVER.CRT;    Ssl_certificate_key/etc/nginx/sites-available/server.key;    server_name mygitdomain.com;     #ubuntu1204-dell source.cml.com;    # e.g, server_name source.example.com;    Root/home/gitlab/gitlab/public;    # individual Nginx logs for this gitlab vhost Access_log/var/log/nginx/gitlab_ssl_access.log;    Error_log/var/log/nginx/gitlab_ssl_error.log;      Location/{# serve static files from defined root folder;. # @gitlab is a named location for the upstream fallback, see below Try_files $uri $uri/index.html $uri. html @gi    Tlab; # If a file, which is not found in the root folder was requested, # then the proxy pass the request to the Upsteam (Gitlab Unicorn) location @gitlab {proxy_read_timeout; # https://github.com/gitlabhq/gitlabhq/issues/694 Pro XY_connect_timeout 300;    # https://github.com/gitlabhq/gitlabhq/issues/694 Proxy_redirect off;      Proxy_set_header X-forwarded-proto $scheme;      Proxy_set_header Host $http _host;    Proxy_set_header X-real-ip $remote _addr;  Proxy_pass Http://gitlab; }}

Installing Gitlab on CentOS

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.