时间 2014-08-12 01:41:47            dzone.com: unix-linux                    相似文章 (0) 原文                 http://hungred.com/how-to/installing-gitlab-centos-6-apache-server-cpanel-dns-server/

Please take note these instruction is installed on top of cPanel DNS only server, therefore all services for both gitlab and cpanel DNS Only will still works side by side.

Instroduction to GitLab

    Before get start with the installation process , let me give a short description about   gitlab    . Gitlab is open source software to collaborate on code. It can be considered as an open source self hosted. Even gitlab is very similar to github adoption will be straightforward, but it also allows us to completely control the environment.So,   Who directly benefits from / will use this improvement?(target audiences) and the answer will be -> Developers, Doc team.    There are few advantage   why Gitlab

  • hosted on our own servers
  • better git viewer
  • integrated dreditor (comment on line level)
  • inline editing of all files
  • linking issues
  • pull requests
  • protected branches
  • private repos possible

Read this for more information regrading Gitlab

For the Installation process we believe you know some of the centos Command

      If not familiar Read Some tutorial or      Refer this link

The GitLab installation consists of setting up the following components:

  1. Install the base operating system (CentOS 6.5 Minimal) and Packages / Dependencies
  2. Ruby
  3. System Users
  4. GitLab shell(GitLab Shell is an application that allows you to execute git commands and provide ssh access to git repositories. It is not a unix shell nor a replacement for Bash or Zsh.)
  5. Database(Mysql)
  6. Gitlab
  7. Web Server(apache)

For fresh installation of the linux centos refer to the below link..

Refer this

1.Installing the operating system

    The process start with the installation of the clean CentOS 6.5 “minimal” and it    can be accomplished by downloading the appropriate installation iso file. Just boot the system of the iso file and install the system. 

Important !

Note that during the installation you use the “Configure Network” option (it’s a button in the same screen where you specify the hostname) to enable the “Connect automatically” option for the network interface and hand (usually eth0).

If you forget this option the network will NOT start at boot.

Updating and installing basic software and services

Installing EPEL repository

EPEL is a volunteer-based community effort from the Fedora project to create a repository of high-quality add-on packages

Download the GPG key for EPEL repository from fedoraproject and install it on your system:

wget -O /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 https://www.fedoraproject.org/static/0608B895.txtrpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

Verify that the key got installed successfully:

rpm -qa gpg*gpg-pubkey-0608b895-4bd22942

install the epel-release-6-8.noarch package,to be enable EPEL repository on your system:

rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

PUIAS Computational repository

The PUIAS Computational repository is a part of PUIAS/Springdale Linux, a custom Red Hat:registered: distribution maintained by Princeton University and the Institute for Advanced Study. We take advantage of the PUIAS Computational repository to obtain a git v1.8.x package since the base CentOS repositories only provide v1.7.1 which is not compatible with GitLab. Although the PUIAS offers an RPM to install the repo, it requires the other PUIAS repos as a dependency, so you’ll have to add it manually. Otherwise you can install git from source (instructions below).

Download PUIAS repo:

wget -O /etc/yum.repos.d/PUIAS_6_computational.repo https://gitlab.com/gitlab-org/gitlab-recipes/raw/master/install/centos/PUIAS_6_computational.repo

Next download and install the gpg key:

wget -O /etc/pki/rpm-gpg/RPM-GPG-KEY-puiashttp://springdale.math.ias.edu/data/puias/6/x86_64/os/RPM-GPG-KEY-puiasrpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-puias

Verify that the key got installed successfully:

rpm -qa gpg*gpg-pubkey-41a40948-4ce19266

Verify that the EPEL and PUIAS Computational repositories are enabled as shown below:

yum repolistrepo id repo name statusPUIAS_6_computational PUIAS computational Base6 - x86_64 2,018base CentOS-6 - Base4,802epel Extra Packages for Enterprise Linux 6 - x86_64 7,879extras CentOS-6 - Extras12updates CentOS-6 - Updates814repolist: 15,525

If you can’t see them listed, use the folowing command (from yum-utils package) to enable them:

yum-config-manager --enable epel --enable PUIAS_6_computational

Now install tools that required for gitlab

yum -y updateyum -y groupinstall'Development Tools'yum -y install readline readline-devel ncurses-devel gdbm-devel glibc-devel tcl-devel openssl-devel curl-devel expat-devel db4-devel byacc sqlite-devel libyaml libyaml-devel libffi libffi-devel libxml2 libxml2-devel libxslt libxslt-devel libicu libicu-devel system-config-firewall-tui redis sudo wget crontabs logwatch logrotate perl-Time-HiRes

RHEL Notes->If some packages (eg. gdbm-devel, libffi-devel and libicu-devel) are NOT installed, add the rhel6 optional packages repo to your server to get those packages:

yum-config-manager --enable rhel-6-server-optional-rpms

Note:      During this installation some files will need to be edited manually. If you are familiar with vim set it as default editor with the commands below. If you are not familiar with vim please skip this and keep using the default editor.   

optional

# Install vim and setas default editoryum -y install vim-enhancedupdate-alternatives --set editor /usr/bin/vim.basic#For reStructuredText markup language support, install required package:yum -y install python-docutils

You have to config redis start on boot :

chkconfig redis onservice redis start

    Next, need to install    Mail server

# The recommended one is postfixyum -y install postfix

if you are using exim as mail agent, try to add this command to exim configuration at /etc/exim.conf

extract_addresses_remove_arguments =false

which will allow exim to sent email.

Install Git from Source

# ---> Install the pre-requisite files for Git compilation:yum install zlib-devel perl-CPAN gettext curl-devel expat-devel gettext-devel openssl-devel## ---> Download and extract it:mkdir /tmp/git && cd /tmp/gitcurl --progress https://www.kernel.org/pub/software/scm/git/git-2.0.0.tar.gz | tar xzcd git-2.0.0/./configuremakemake prefix=/usr/local install#Make sure Git is in your $PATH:which git

      Reboot your system to make sure the installation take effect.      Note:      When editing     config/gitlab.yml      ,      change the git bin_path to /usr/local/bin/git

2.Install Ruby

      Remove completely the old Ruby      1.8 packageif present. GitLab only supports the Ruby 2.0+ release series:

#remove rubyyum remove ruby#Remove any other Ruby build if it is<b>still present</b>:which rubycd<your-ruby-source-path>make uninstall

Time to install ruby and Gem

mkdir /tmp/ruby && cd /tmp/rubycurl --progress ftp://ftp.ruby-lang.org/pub/ruby/2.1/ruby-2.1.2.tar.gz | tar xzcd ruby-2.1.2./configure--disable-install-rdocmakemake prefix=/usr/local install#Install the Bundler Gemgem install bundler--no-doc

After the installation is complete is recommended to reboot the system to make sure the $path/installation take effect

After reboot :

which ruby #-># /usr/local/bin/rubyruby -v# -> ruby 2.0.0p481 (2014-02-24 revision 45167) [x86_64-linux]#make sure the ruby version is 2+ ..the gitlab only support ruby version above 2.0+

3.System Users

    Create a    git    user for Gitlab: 

adduser --system --shell /bin/bash --comment 'GitLab' --create-home --home-dir /home/git/ git

Important : Important: In order to include /usr/local/bin to git user’s PATH, one way is to edit the sudoers file. As root run:

# type an enter :visudo#search for the line and and append <b>/usr/local/bin</b> like so:Defaults secure_path =/sbin:/bin:/usr/sbin:/usr/bin#like this ----->Defaults secure_path =/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin

save and exit

4.Database

    Install mysql and enable the mysqld service to start on boot:    Make sure you install Mysql version 5.5.14 (optional) 

mysql --version

#install the mysqlyum install -y mysql-server mysql-devel#make sure mysql servicestart on bootchkconfig mysqldon#start itservice mysqldstart#secure you mysql installationmysql_secure_installation

Login to MySQL (type the database root password) , like below

mysql -u root -p#Create auser for GitLab or any name you like(REMEMBER THE NAME) (change $YOUR_PASSWORD_HEREin the command below to areal password you #pick):CREATEUSER 'git'@'localhost' IDENTIFIEDBY '$YOUR_PASSWORD_HERE';

Ensure you can use the InnoDB engine which is necessary to support long indexes..

# If this fails, check your MySQL config files (e.g./etc/mysql/*.cnf, /etc/mysql/conf.d/*) #for the setting "innodb = off"SET storage_engine=INNODB;

Create the GitLab production database:

CREATE DATABASE IFNOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8`COLLATE `utf8_unicode_ci`;

Grant the GitLab user necessary permissions on the table:

# VERY IMPORTANT :Make sure the db name and the user name is correct !!GRANTSELECT, LOCK TABLES, INSERT, UPDATE, DELETE,CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.*TO 'git'@'localhost';#Quit the database session:\q

Now test the connection with the newly created database with new user

sudo -u git -H mysql -u git -p -D gitlabhq_production#if all ok#exit\q

5.Gitlab

# We'll install GitLab into home directory of the user "git"#git user u was created before this in(step 6)#if u missed means go back and done the thing before you continue herecd /home/git

Clone the Source

# Clone GitLab repositorysudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-ce.git -b7-1-stable gitlab#Note: You can change7-1-stable to master if you want the bleeding edge version, but do so with caution!

!Important

Now time to configure Gitlab(Important steps & make sure u done it correctly)

cd /home/git/gitlab# Copy the example GitLab config####sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml#<strong>Important</strong># Make sureto change "localhost" to the fully-qualified domain name of your# host serving GitLab where necessary## If you wantto use https make sure that you set `https` to `true`. See #using-https for all necessary details.## If you installed Gitfrom source, change the git bin_path to /usr/local/bin/gitsudo -u git -H editor config/gitlab.yml# Make sure GitLab canwrite to the log/ and tmp/ directorieschown -R git {log,tmp}chmod -R u+rwX {log,tmp}# Create directory for satellitessudo -u git -H mkdir /home/git/gitlab-satelliteschmod u+rwx,g+rx,o-rwx /home/git/gitlab-satellites# Make sure GitLab canwrite to the tmp/pids/ and tmp/sockets/ directorieschmod -R u+rwX tmp/{pids,sockets}# Make sure GitLab canwrite to the public/uploads/ directorychmod -R u+rwX public/uploads# Copy the example Unicorn configsudo -u git -H cp config/unicorn.rb.example config/unicorn.rb# Enable cluster mode if you expectto have a high load instance# Ex. change amountof workers to 3 for 2GB RAM serversudo -u git -H editor config/unicorn.rb# Copy the example Rack attack configsudo -u git -H cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb# Configure Git global settings for git user, useful when editing via web# Edituser.email according to whatis set in config/gitlab.ymlsudo -u git -H git config --globaluser.name "GitLab"sudo -u git -H git config --globaluser.email "gitlab@localhost"sudo -u git -H git config --global core.autocrlfinput

Important Note:    Make sure to edit both gitlab.yml and unicorn.rb to match your setup. 

Configure GitLab DB settings

# MySQL only:sudo -u git cp config/database.yml.mysql config/database.yml# MySQL remoteonly:# Update username/passwordin config/database.yml.# You only needto adapt the production settings (first part).# If you followed the database guidethen please do as follows:# Change 'secure password' with the value you have given to $password# You can keep the double quotes around the passwordsudo -u git -H editor config/database.yml# MySQL:# Make config/database.yml readableto git onlysudo -u git -H chmod o-rwx config/database.yml

Install Gems

Note:      As of      bundler 1.5.2      , you can invoke bundle install -jN (where N the number of your processor cores) and enjoy the parallel gems installation with measurable difference in completion time (~60% faster). Check the number of your cores with nproc. For more information check this      post      . First make sure you have bundler >= 1.5.2 (run bundle -v).   

The installation Process

cd /home/git/gitlab# For MySQL (note, the option says "without ... postgres")sudo -u git -H bundle install --deployment --without development test postgres aws

以上这一步,我在安装的时候,会出现安装某些包失败的情况,这时候可以找到包所在的地址,手动编译下包,看看是不是缺少什么库。

Install GitLab shell

GitLab Shell is an ssh access and repository management software developed specially for GitLab.

# Go to the Gitlab installation folder:cd /home/git/gitlab# Run the installation task for gitlab-shell (replace`REDIS_URL` if needed):sudo -u git -H bundle exec rake gitlab:shell:install[v1.9.6] REDIS_URL=redis://localhost:6379 RAILS_ENV=production#By default, the gitlab-shell configis generated from your main gitlab config.## Note:When using GitLab with HTTPS please change the following:# - Provide paths to the certificates under `ca_file` and `ca_path options.# - The `gitlab_url` option must point to the https endpoint of GitLab.# - In case you are using self signed certificate set `self_signed_cert` to `true`.# See #using-https for all necessary details.## You can review (and modify) it as follows:sudo -u git -H editor /home/git/gitlab-shell/config.yml# Ensure the correct SELinux contexts are set# Read http://wiki.centos.org/HowTos/Network/SecuringSSHrestorecon -Rv /home/git/.ssh

Initialize Database and Activate Advanced Features

sudo -u git -H bundleexec rake gitlab:setup RAILS_ENV=production#Type yesto create the database.When done you see Administrator account created

Install Init Script

Download the init script (will be /etc/init.d/gitlab):

#download the filewget -O /etc/init.d/gitlab https://gitlab.com/gitlab-org/gitlab-recipes/raw/master/init/sysvinit/centos/gitlab-unicorn#giveexecute permissionchmod +x /etc/init.d/gitlabchkconfig --add gitlab#Make GitLabstart on boot:chkconfig gitlabon#Set up logrotatecp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab

Check Application Status

#Check if GitLab and its environment are configured correctly:sudo -u git -H bundleexec rake gitlab:env:info RAILS_ENV=production#Compile assetssudo -u git -H bundleexec rake assets:precompile RAILS_ENV=production#Start your GitLab instanceservice gitlabstart

6. Configure the web server(Apache)

We will configure apache with module mod_proxy which is loaded by default when installing apache and mod_ssl which will provide ssl support:

yum -y install httpd mod_sslchkconfig httpd onwget -O /etc/httpd/conf.d/gitlab.conf https://gitlab.com/gitlab-org/gitlab-recipes/raw/master/web-server/apache/gitlab-ssl.confmv /etc/httpd/conf.d/ssl.conf{,.bak}mkdir /var/log/httpd/logs/

Open /etc/httpd/conf.d/gitlab.conf with your editor and replace git.example.org with your FQDN. Also make sure the path to your certificates is valid.

Add LoadModule ssl_module /etc/httpd/modules/mod_ssl.so in /etc/httpd/conf/httpd.conf.

    In    /etc/httpd/conf/httpd.conf       Change the DocumentRoot to /home/git/gitlab/public/ 

AND

in Directory –> /home/git/gitlab/public

Finally, start apache:

service httpd start

Please take note that, the above configuration is a http setup rather than a ssl setup. the configuration file for ssl is a little buggy but can be found on https://github.com/gitlabhq/gitlab-recipes/tree/master/web-server/apache

Done!

    Double-check Application Status    To make sure you didn’t miss anything run a more thorough check with: 

cd /home/git/gitlabsudo -u git -H bundleexec rake gitlab:check RAILS_ENV=production

Initial Login

Visit YOUR_SERVER:8080 in your web browser for your first GitLab login. The setup has created an admin account for you. You can use it to log in:

root5iveL!fe

Important Note: Please go over to your profile page and immediately change the password, so nobody can access your GitLab by using this login information later on.

Potential Errors

In case the when start the httpd(apache service),it may throw exception (SSL ERROR) or anything regarding Self-Signed Certificates(ssl) – > it because you may miss the or not generate the Self-Signed Certificates. Here the solution for that

#make sure you installed the mod_ssl yum install mod_ssl#Next, we need tocreate a new directory where we will store the server key and certificatemkdir /etc/httpd/ssl#When we request a new certificate, we can specify how long the certificate should remain #validby changing the 365 to the number of days we prefer.As it stands this certificate #will expire after oneyear.openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/httpd/ssl/apache.key -out /etc/httpd/ssl/apache.crt

With this command, we will be both creating the self-signed SSL certificate and the server key that protects it, and placing both of them into the new directory.

This command will prompt terminal to display a lists of fields that need to be filled in.

The most important line is “Common Name”. Enter your official domain name here or, if you don’t have one yet, your site’s IP address.

You are about to be asked to enter information that will be incorporatedinto your certificate request.What you are about to enter is what is called aDistinguished Name or a DN.There are quite a few fields but you can leave some blankFor some fields there will be a default value,If you enter'.', the field will be left blank.-----CountryName (2 letter code) [AU]:USStateor Province Name (full name) [Some-State]:NewYorkLocality Name (eg, city) []:NYCOrganizationName (eg, company) [InternetWidgits Pty Ltd]:Awesome IncOrganizationalUnit Name (eg, section) []:Dept ofMerrimentCommon Name (e.g. server FQDN or YOUR name) []:example.comEmailAddress []:webmaster@awesomeinc.com

    Now open and edit the file    /etc/httpd/conf.d/gitlab.conf

Under section

Uncomment the DocumentRoot and ServerName line and replace example.com with your DNS approved domain name or server IP address (it should be the same as the common name on the certificate):

ServerName example.com:443

Find the following three lines, and make sure that they match the extensions below:

SSLEngine onSSLCertificateFile /etc/httpd/ssl/apache.crtSSLCertificateKeyFile /etc/httpd/ssl/apache.key

    Now just Restart Apache –>    service httpd restart and run

Very Important    **CHECK LIST** 

    • in /home/git/gitlab/config/unicorn.rb change the listen to “YOUR_SERVER_IP_ADDR:8080″

    • change to ur ipaddr and server name in /etc/httpd/conf.d/gitlab.conf

 

 

Logo

更多推荐