GitLab, an open source application developed using Ruby on Rails, is similar to GitHub, able to browse the source code, manage flaws and annotations, and is ideal for use within a team.
The official only provides the installation instructions under the Debian/ubuntu system, if you need to install under CentOS, you can refer to this article: https://github.com/gitlabhq/gitlab-recipes/tree/master/ Install/centos, the author of this article, according to the instructions, successfully installed on the CentOS system Gitlab, share their own installation process and encountered problems.
First show the results after the installation is complete.
Before you begin
Before you begin, check out the official documentation: HTTPS://GITHUB.COM/GITLABHQ/GITLABHQ/BLOB/MASTER/DOC/INSTALL/REQUIREMENTS.MD, which describes the system, Requirements for software and hardware. A detailed understanding of these can avoid a lot of weird problems.
Installation Steps Overview
Base Operating System (CentOS 6.4 Minimal, 6.5 after upgrade)
Ruby (version: 2.0.0p353)
Create a project run user (create Git account for easy rights Management)
GitLab Shell (version: 1.8.0)
Database (can support MySQL and PostgreSQL, MySQL is used here, version: 5.1.17)
GitLab (version: 6.3.1)
Web server (can support Nginx and Apache, use Nginx here, version: 1.0.15)
Firewall (iptables)
1. Install the operating system
This is relatively simple, after the installation is completed, remember the network configuration, so that it can be automatically connected at startup. Then you need to upgrade the system and install some of the corresponding software and dependency packages, described below.
Tips: If you are unable to connect to a foreign network, there are frequent network errors or errors such as couldn ' t not resolve host, we recommend that you modify the DNS server to 8.8.8.8 and 8.8.4.4.
A, upgrade the operating system and install wget
$ sudo yum-y update
$ sudo yum-y install wget
After the upgrade is complete, the system version is 6.5.
The author notes: and the English document is different, the author here is the first upgrade system and install wget, otherwise the operation will prompt wget command to find.
b, increase the Epel installation source
EPEL, extra Packages for Enterprise Linux, which has a lot of very common software in this repository and is designed specifically for Rhel, is a good addition to the Rhel standard Yum source and is completely free to use, maintained by the Fedora Project, So if you are using Rhel, or centos,scientific and other Rhel-system Linux, you can use Epel's Yum source with great ease.
Download and install GPG key
$ sudo wget-o/etc/pki/rpm-gpg/rpm-gpg-key-epel-6 https://www.fedoraproject.org/static/0608B895.txt
$ sudo rpm--import/etc/pki/rpm-gpg/rpm-gpg-key-epel-6
Verify the installation is successful
$ sudo rpm-qa gpg*
Installing the Epel-release-6-8.noarch Package
$ sudo rpm-uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
Tip: Don't mind the x86_64, as can be used on i686 machines.
c, increase the Puias installation source
Puias Linux is a complete operating system for desktops and servers, and it is created by compiling the source code package for red Hat Enterprise Linux. In addition to these upstream packages, the project also provides some other repositories: "Addons" contains additional packages that are not included in the usual Red Hat release, "computational" provides software specifically for scientific computing, "unsupported" A variety of test packages are generated. The issue is maintained by the Institute of Advanced Studies at Princeton University in the United States.
Create the/etc/yum.repos.d/puias_6_computational.repo and add the following:
[Puias_6_computational]
Name=puias Computational Base $releasever-$basearch
mirrorlist=http://puias.math.ias.edu/data/puias/computational/$releasever/$basearch/mirrorlist
#baseurl =http://puias.math.ias.edu/data/puias/computational/$releasever/$basearch
Gpgcheck=1
Gpgkey=file:///etc/pki/rpm-gpg/rpm-gpg-key-puias
Download and install GPG key
$ sudo wget-o/etc/pki/rpm-gpg/rpm-gpg-key-puias http://springdale.math.ias.edu/data/puias/6/x86_64/os/RPM-GPG-KEY-puias
$ sudo rpm--import/etc/pki/rpm-gpg/rpm-gpg-key-puias
Verify the installation is successful
$ sudo rpm-qa gpg*
Tips: After installing the Epel and Puias two sources, you can detect:
$ sudo yum repolist
D. The required dependencies and tools for installing Gitlab
$ Su-
$ yum-y groupinstall ' development Tools '
$ yum-y Install vim-enhanced readline readline-devel ncurses-devel gdbm-devel glibc-devel tcl-devel openssl-devel curl-de Vel expat-devel db4-devel byacc sqlite-devel gcc-c++ libyaml libyaml-devel libffi libffi-devel libxml2 libxml2-devel Libxs Lt Libxslt-devel Libicu libicu-devel system-config-firewall-tui python-devel redis sudo wget crontabs logwatch logrotate p Erl-time-hires git
Rhel Tips
If some packages cannot be installed, for example: eg. Gdbm-devel, Libffi-devel and libicu-devel, then increase the RHEL6 installation source.
$ Yum-config-manager--enable Rhel-6-server-optional-rpms
E, configuring Redis
Configure Redis to boot at boot time:
$ sudo chkconfig redis on
$ sudo service Redis start
F. Configuring the Mail server
I note: This process is not configured by the author, please refer to the English documentation.
2. Install Ruby
Download and compile:
$ Su-
$ 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 && make install
After the installation is complete, log in to the terminal to ensure that the $path is in effect and that the installation of Ruby is successful:
$ which Ruby
/usr/local/bin/ruby
$ ruby-v
Ruby 2.0.0p353 (2013-11-22 revision 43784) [X86_64-linux]
Install Bundles:
$ sudo gem install bundler--no-ri--no-rdoc
If you are prompted to Sudo:gem:command not found, use the root account to log in to execute the command.
3. System users
Create User git
$ Su-
$ adduser--system--shell/bin/bash--comment ' GitLab '--create-home--home-dir/home/git/git
Because git users don't need to sign in, there's no need to set up a git password.
Forward all messages
I note: Because the above is not configured to send mail, also omitted here.
4. Configure Gitlab Shell
GitLab Shell is a software developed specifically for GITLAB that provides access to SSH and version management.
Use root to log in, then switch to git
$ Su-
$ su-git
Cloning Gitlab Shell
$ git clone https://github.com/gitlabhq/gitlab-shell.git
$ CD Gitlab-shell
Switch to 1.8.0 Version and edit configuration
$ git checkout v1.8.0
$ CP config.yml.example CONFIG.YML
The most important thing here is to change the Gitlab_url into a gitlab access domain name. Shaped like: http://test.gitlab.com/
I note: If Gitlab is using HTTPS access, you need to replace HTTP to HTTPS, the configuration file Self_signed_cert to be modified to true, otherwise gitlab shell in the API and Gitlab to communicate the error occurs, Cause a project push error. Because SSL is used to configure the Web server later, it is configured in the same way as SSL.
Tips: Also if the domain name used is a test domain name, do not forget to do domain mapping in the system's/etc/hosts.
Install some required directories and files
$./bin/install
5. Install the database
I use MSYQL here, for the installation of PostgreSQL please refer to the original document.
Install MySQL and set boot up:
$ Su-
$ yum install-y mysql-server Mysql-devel
$ chkconfig mysqld on
$ service Mysqld Start
To set the password for the MySQL root account:
$/usr/bin/mysql_secure_installation
Create new users and databases for Gitlab use
# Log in to database
$ mysql-u Root-p
# Enter root password
# Create a user with Gitlab
CREATE USER ' gitlab ' @ ' localhost ' identified by ' Gitlab account password ';
# Create a database used by Gitlaba
CREATE DATABASE IF not EXISTS ' gitlabhq_production ' DEFAULT CHARACTER SET ' UTF8 ' COLLATE ' utf8_unicode_ci ';
# Give Gitlab user rights
GRANT SELECT, LOCK TABLES, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER on ' gitlabhq_production '. * to ' gitlab ' @ ' Loca Lhost ';
# Log out of the database
\q
6, Installation Gitlab
Install Gitlab in Git's home directory:
$ Su-
$ su-git
A. Clone gitlab and switch branches to 6-3-stable
# clone Gitlab
$ git clone https://github.com/gitlabhq/gitlabhq.git Gitlab
# Enter the Gitlab directory
$ cd/home/git/gitlab
# Switch to 6-3-stable branch
$ git checkout 6-3-stable
B. Configuration Items
# Copy configuration file
$ CP config/gitlab.yml.example CONFIG/GITLAB.YML
# Modify the access domain name in the configuration file
(Your_domain_name is the project's access domain name)
$ Sed-i ' s|localhost|your_domain_name|g ' config/gitlab.yml
# set log and TMP directory owners and permissions
$ chown-r git log/
$ chown-r git tmp/
$ chmod-r u+rwx log/
$ chmod-r u+rwx tmp/
# Create gitlab-satellites Directory
$ mkdir/home/git/gitlab-satellites
# Create tmp/pids/and tmp/sockets/directories to ensure that Gitlab has the appropriate permissions
$ mkdir tmp/pids/
$ mkdir tmp/sockets/
$ chmod-r u+rwx tmp/pids/
$ chmod-r u+rwx tmp/sockets/
# Create public/uploads Directory
$ mkdir Public/uploads
$ chmod-r u+rwx public/uploads
# Copy Unicorn Configuration
$ CP config/unicorn.rb.example CONFIG/UNICORN.RB
# Edit Unicorn Configuration
(I use the default configuration here)
$ vim CONFIG/UNICORN.RB
# Configure users and messages for Git
$ git config--global user.name "GitLab"
$ git config--global user.email "[Email Protected]_domain_name"
$ git config--global core.autocrlf input
This side of the configuration is more complex, more careful on the line.
C. Configure database Access files
$ CP Config/database.yml.mysql CONFIG/DATABASE.YML
Edit Config/database.yml, set the account password of the connection database, the author's configuration section is as follows:
#
# PRODUCTION
#
Production
Adapter:mysql2
Encoding:utf8
Reconnect:false
Database:gitlabhq_production
Pool:10
Username:gitlab
Password: "Gitlab"
# Host:localhost
# Socket:/tmp/mysql.sock
Modify the username and password, where the password is the password for the Gitlab user created in the database step above.
Make sure that the file only has permission to read from the GIT account.
$ chmod o-rwx config/database.yml
D, install Gems
$ Su-
$ gem Install charlock_holmes--version ' 0.6.9.4 '
$ exit
Installing the MySQL Package
$ cd/home/git/gitlab/
$ bundle Install--deployment--without Development Test Postgres Puma AWS
E, initialize data and activate advanced features
$ cd/home/git/gitlab
$ bundle EXEC Rake Gitlab:setup rails_env=production
When this is done, a default administrator account will be born:
[Email protected]
5ivel!fe
F. Install the startup script
$ Su-
$ wget-o/etc/init.d/gitlab Https://raw.github.com/gitlabhq/gitlab-recipes/master/init/sysvinit/centos/gitlab-unicorn
$ chmod +x/etc/init.d/gitlab
$ chkconfig--add Gitlab
Start up at boot time
$ chkconfig Gitlab on
G. Detecting Application Status
$ su-git
$ CD gitlab/
$ bundle EXEC Rake Gitlab:env:info rails_env=production
$ exit
You can view versions of the system, Ruby, Gitlab, and gitlab shells, and other information.
Launch Gitlab Instance
$ service Gitlab Start
H, view the application for more detailed information
$ su-git
$ CD gitlab/
$ bundle EXEC Rake Gitlab:check rails_env=production
This will prompt an init script up-to-date error, as follows:
Init script up-to-date? ... no
Try Fixing it:
Redownload the init script
For more information see:
DOC/INSTALL/INSTALLATION.MD in section "Install Init Script"
Please fix the error above and rerun the checks.
The original explanation does not mind this question.
7. Install the Web server
The author chooses Nginx, please refer to the original document for Apache.
$ Su-
$ yum-y Install Nginx
$ chkconfig Nginx on
$ mkdir/etc/nginx/sites-available
$ mkdir/etc/nginx/sites-enabled
$ wget-o/etc/nginx/sites-available/gitlab Https://raw.github.com/gitlabhq/gitlab-recipes/master/web-server/nginx /gitlab-ssl
$ ln-sf/etc/nginx/sites-available/gitlab/etc/nginx/sites-enabled/gitlab
Edit/etc/nginx/nginx.conf, will include/etc/nginx/conf.d/*.conf; Replace with include/etc/nginx/sites-enabled/*, which is to modify the additional loaded configuration file directory.
Edit/etc/nginx/sites-available/gitlab to replace server_name in the configuration with the domain name actually accessed.
Adding Nginx to a git user group
$ usermod-a-G git nginx
$ chmod g+rx/home/git/
Add an SSL certificate or generate a
$ cd/etc/nginx
$ OpenSSL req-new-x509-nodes-days 3560-out gitlab.crt-keyout Gitlab.key
Start Nginx
$ service Nginx Start
8. Configure the Firewall
Configure Iptables to enable users to access HTTP, HTTPS, and SSH ports.
$ lokkit-s http-s https-s SSH
Restarting the firewall
$ Service Iptables Restart
Even if the installation is complete. Default account password:
[Email protected]
5ivel!fe
Issue record
A, the site cannot add users and create project issues?
Check the next log, found to be the issue of permissions:
Errno::eacces (Permission denied–/home/git/gitlab/log/application.log):
Modify the user and the owning user group to be git.
B, unable to push?
When installing the Gitlab shell step above, the first author is the configuration in the Gitlab_url set to http://test.gitlab.com/, the results in the push error, and then view the Gitlab project log, only to find Gitlab When the shell and Gitlab communicate, a 301 jump is generated. This can also be seen through the nginx configuration of the Gitlab. It is OK to replace HTTP with Https,self_signed_cert and set it to true later.
Summarize
The installation process is long and most of the time is spent on the download of the package. I have not contacted Ruby before, the process of installation also understand the next Ruby, Gem, bundle and other software, benefited. Generally speaking, follow the above steps to install, if the system, software and other versions are consistent, should be able to install successfully. If there is a problem, you can check the log more. The logs for the Gitlab project are in the log directory of the project. GitLab shell logs in the GitLab Shell project Gitlab-shell.log
Thank
In the process of installation thanks to the help of Friends Lei Zhiwei, less go a lot of detours. In addition, he is now in the Chinese gitlab, poor English friends are blessed, interested friends can also participate in, you can also directly use the good documents have been Chinese, address: http://git.oschina.net/linxuix/Git-Lab-Zh.
CENTOS6 Installation Gitlab full understanding and common problems resolved