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.
English documents for installation: Centos-6-5-install-gitlab.zip
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 -sudoyuminstallwget
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.txtsudo 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- $basearchmirrorlist=http:/ /puias.math.ias.edu/data/puias/computational/$releasever/$basearch/mirrorlist#baseurl =http:/ /puias.math.ias.edu/data/puias/computational/$releasever/$basearchgpgcheck=1Gpgkey =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-puiassudo 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 -$ -y groupinstall " development Tools " $ -y install vim-enhanced readline readline-devel ncurses-devel Gdbm-devel glibc-devel tcl-devel openssl-devel curl-devel expat-devel db4-devel byacc sqlite-devel GCC -c++ libyaml libyaml-devel libffi libffi-devel libxml2 libxml2-devel libxslt libxslt-devel Libicu Libicu-devel system-config-firewall-tui python-devel redis sudo wget crontabs logwatch logrotate perl -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:
sudosudo 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/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 doinstall
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/-2.0. 0p353 43784) [X86_64-linux]
Install Bundles:
sudo 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 -'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 -yuminstall -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
# Login Database $ mysql-U Root-p# Enter the root password # for Gitlab create using user create users'Gitlab'@'localhost'Identified by'password for Gitlab account'CREATE database IF not EXISTS ' gitlabhq_production ' DEFAULT CHARACTER SET ' UTF8 ' COLLATE ' Utf8_unico Gitlaba De_ci '; # Grant Gitlab User Rights Grant SELECT, LOCK TABLES, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER on ' gitlabhq_production `.* To'Gitlab'@'localhost'; # Log out 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 /home/git/gitlab# switch to 6-3-6-3-stable
B. Configuration Items
# Copy configuration file $CPConfig/gitlab.yml.example config/gitlab.yml# Modify the access domain name in the configuration file (Your_domain_name the access domain name for the project) $sed-I.'s|localhost|your_domain_name|g'config/gitlab.yml# setting 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 Catalog $mkdir/home/git/gitlab-satellites# Create TMP/pids/and tmp/sockets/directory to ensure that Gitlab has the appropriate permissionsmkdirtmp/pids/$ mkdirtmp/sockets/$ chmod-R u+rwx tmp/pids/$ chmod-R u+rwx tmp/sockets/# Create public/Uploads Catalog $mkdirpublic/uploads$chmod-R u+rwx public/uploads# Copy Unicorn configuration $CPConfig/unicorn.rb.example config/unicorn.rb# Edit Unicorn Configuration (the author uses the default configuration here) $ vim Config/unicorn.rb# Configuring Git user and mail $ 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:utf8false database: Gitlabhq_production username:gitlab "gitlab " # host:localhost /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? ... notry fixing it:redownload the init scriptfor more information see:doc/install/installation.md in section "Install Ini T 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 -yuminstallmkdir /etc/nginx/sites-mkdir /etc/nginx/sites-wget -o/etc/nginx/sites-available/gitlab https:// Raw.github.com/gitlabhq/gitlab-recipes/master/web-server/nginx/gitlab-sslLn -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.
CentOS 6.5 Installation Gitlab whole process and problem record